mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 12:12:59 +03:00
Add axis property dialog
This commit is contained in:
parent
8d4b1aaadc
commit
a77225af5d
@ -30,6 +30,7 @@ SOURCES += \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrcontentpropitem.cpp \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrmarginpropitem.cpp \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrseriespropitem.cpp \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lraxispropitem.cpp \
|
||||
$$REPORT_PATH/objectinspector/editors/lrtextitempropertyeditor.cpp \
|
||||
$$REPORT_PATH/objectinspector/editors/lrcomboboxeditor.cpp \
|
||||
$$REPORT_PATH/objectinspector/editors/lrcheckboxeditor.cpp \
|
||||
@ -80,6 +81,7 @@ HEADERS += \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrcolorpropitem.h \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrmarginpropitem.h \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lrseriespropitem.h \
|
||||
$$REPORT_PATH/objectinspector/propertyItems/lraxispropitem.h \
|
||||
$$REPORT_PATH/objectinspector/editors/lrtextitempropertyeditor.h \
|
||||
$$REPORT_PATH/objectinspector/editors/lrcomboboxeditor.h \
|
||||
$$REPORT_PATH/objectinspector/editors/lrcheckboxeditor.h \
|
||||
|
135
limereport/items/lrchartaxiseditor.cpp
Normal file
135
limereport/items/lrchartaxiseditor.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
#include "lrchartaxiseditor.h"
|
||||
|
||||
#include "ui_lrchartaxiseditor.h"
|
||||
#include "lraxisdata.h"
|
||||
|
||||
ChartAxisEditor::ChartAxisEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, bool isXAxis, QSettings *settings, QWidget *parent):
|
||||
QWidget(parent), ui(new Ui::ChartAxisEditor), m_chartItem(item), m_page(page),
|
||||
m_settings(settings), m_isXAxis(isXAxis)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
readSetting();
|
||||
init();
|
||||
}
|
||||
|
||||
ChartAxisEditor::~ChartAxisEditor()
|
||||
{
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
writeSetting();
|
||||
#endif
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QSettings* ChartAxisEditor::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
return m_settings;
|
||||
}
|
||||
m_settings = new QSettings("LimeReport",QCoreApplication::applicationName());
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
void ChartAxisEditor::readSetting()
|
||||
{
|
||||
if (settings() == 0) return;
|
||||
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
if (v.isValid()) {
|
||||
restoreGeometry(v.toByteArray());
|
||||
}
|
||||
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void ChartAxisEditor::writeSetting()
|
||||
{
|
||||
if (settings() == 0) {
|
||||
return;
|
||||
}
|
||||
settings()->beginGroup("ChartAxisEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void ChartAxisEditor::init()
|
||||
{
|
||||
ui->gbAxis->setTitle(m_isXAxis ? QObject::tr("X Axis") : QObject::tr("Y Axis"));
|
||||
ui->direction_checkbox->setVisible(!m_isXAxis);
|
||||
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
|
||||
ui->minimumSpinBox->setValue(axisData->rangeMin());
|
||||
ui->maximumSpinBox->setValue(axisData->rangeMax());
|
||||
ui->stepSpinBox->setValue(axisData->step());
|
||||
|
||||
ui->minimumCheckBox->setChecked(axisData->isMinimumAutomatic());
|
||||
ui->maximumCheckBox->setChecked(axisData->isMaximumAutomatic());
|
||||
ui->stepCheckBox->setChecked(axisData->isStepAutomatic());
|
||||
|
||||
ui->direction_checkbox->setChecked(axisData->reverseDirection());
|
||||
|
||||
const bool isScaleCalcEnabled = axisData->calculateAxisScale();
|
||||
ui->enableScaleCalculation_checkbox->setChecked(isScaleCalcEnabled);
|
||||
on_enableScaleCalculation_checkbox_stateChanged(isScaleCalcEnabled);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_minimumCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
const bool isAutomatic = (bool)arg1;
|
||||
ui->minimumSpinBox->setEnabled(!isAutomatic);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_maximumCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
const bool isAutomatic = (bool)arg1;
|
||||
ui->maximumSpinBox->setEnabled(!isAutomatic);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_stepCheckBox_stateChanged(int arg1)
|
||||
{
|
||||
const bool isAutomatic = (bool)arg1;
|
||||
ui->stepSpinBox->setEnabled(!isAutomatic);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_pushButtonOk_clicked()
|
||||
{
|
||||
LimeReport::AxisData *axisData = m_isXAxis ? m_chartItem->xAxisData() : m_chartItem->yAxisData();
|
||||
if (!m_isXAxis) {
|
||||
axisData->setReverseDirection(ui->direction_checkbox->isChecked());
|
||||
}
|
||||
|
||||
axisData->setIsStepAutomatic(ui->stepCheckBox->isChecked());
|
||||
axisData->setManualStep(ui->stepSpinBox->value());
|
||||
axisData->setIsMinimumAutomatic(ui->minimumCheckBox->isChecked());
|
||||
axisData->setManualMinimum(ui->minimumSpinBox->value());
|
||||
axisData->setIsMaximumAutomatic(ui->maximumCheckBox->isChecked());
|
||||
axisData->setManualMaximum(ui->maximumSpinBox->value());
|
||||
|
||||
axisData->setCalculateAxisScale(ui->enableScaleCalculation_checkbox->isChecked());
|
||||
|
||||
axisData->update();
|
||||
close();
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_enableScaleCalculation_checkbox_stateChanged(int arg1)
|
||||
{
|
||||
const bool isEnabled = (bool)arg1;
|
||||
ui->minimumCheckBox->setEnabled(isEnabled);
|
||||
ui->maximumCheckBox->setEnabled(isEnabled);
|
||||
ui->stepCheckBox->setEnabled(isEnabled);
|
||||
|
||||
ui->minimumSpinBox->setEnabled(!ui->minimumCheckBox->isChecked() && isEnabled);
|
||||
ui->maximumSpinBox->setEnabled(!ui->maximumCheckBox->isChecked() && isEnabled);
|
||||
ui->stepSpinBox->setEnabled(!ui->stepCheckBox->isChecked() && isEnabled);
|
||||
|
||||
ui->minimumCheckBox->setEnabled(isEnabled);
|
||||
ui->maximumCheckBox->setEnabled(isEnabled);
|
||||
ui->stepCheckBox->setEnabled(isEnabled);
|
||||
}
|
||||
|
||||
void ChartAxisEditor::on_cancelButton_clicked()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
41
limereport/items/lrchartaxiseditor.h
Normal file
41
limereport/items/lrchartaxiseditor.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef CHARTAXISEDITOR_H
|
||||
#define CHARTAXISEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrchartitem.h"
|
||||
|
||||
namespace Ui {
|
||||
class ChartAxisEditor;
|
||||
}
|
||||
|
||||
class ChartAxisEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ChartAxisEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page, bool isXAxis,
|
||||
QSettings* settings=0, QWidget *parent = 0);
|
||||
~ChartAxisEditor();
|
||||
|
||||
QSettings *settings();
|
||||
private slots:
|
||||
void on_minimumCheckBox_stateChanged(int arg1);
|
||||
void on_maximumCheckBox_stateChanged(int arg1);
|
||||
void on_stepCheckBox_stateChanged(int arg1);
|
||||
void on_pushButtonOk_clicked();
|
||||
void on_enableScaleCalculation_checkbox_stateChanged(int arg1);
|
||||
|
||||
void on_cancelButton_clicked();
|
||||
|
||||
private:
|
||||
void readSetting();
|
||||
void writeSetting();
|
||||
void init();
|
||||
|
||||
Ui::ChartAxisEditor *ui;
|
||||
LimeReport::ChartItem* m_chartItem;
|
||||
LimeReport::PageDesignIntf* m_page;
|
||||
QSettings* m_settings;
|
||||
bool m_isXAxis;
|
||||
};
|
||||
|
||||
#endif // CHARTAXISEDITOR_H
|
212
limereport/items/lrchartaxiseditor.ui
Executable file
212
limereport/items/lrchartaxiseditor.ui
Executable file
@ -0,0 +1,212 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ChartAxisEditor</class>
|
||||
<widget class="QWidget" name="ChartAxisEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>268</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Axis editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbAxis">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Axis</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="direction_checkbox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reverse direction</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enableScaleCalculation_checkbox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable scale calculation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="stepLabel">
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="maximumLabel">
|
||||
<property name="text">
|
||||
<string>Maximum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QDoubleSpinBox" name="minimumSpinBox">
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-99999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="minimumLabel">
|
||||
<property name="text">
|
||||
<string>Minimum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QCheckBox" name="stepCheckBox">
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="minimumCheckBox">
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="maximumCheckBox">
|
||||
<property name="text">
|
||||
<string>Automatic</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="stepSpinBox">
|
||||
<property name="minimum">
|
||||
<double>-9999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>9999999.990000000223517</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSpinBox" name="maximumSpinBox">
|
||||
<property name="minimum">
|
||||
<double>-9999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonOk">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>slotAddSeries()</slot>
|
||||
<slot>slotDeleteSeries()</slot>
|
||||
</slots>
|
||||
</ui>
|
@ -8,6 +8,7 @@
|
||||
#include "lrpagedesignintf.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrdatadesignintf.h"
|
||||
#include "lrchartaxiseditor.h"
|
||||
|
||||
#include "charts/lrpiechart.h"
|
||||
#include "charts/lrverticalbarchart.h"
|
||||
@ -263,6 +264,11 @@ AxisData *ChartItem::yAxisData()
|
||||
return m_yAxisData;
|
||||
}
|
||||
|
||||
void ChartItem::showAxisEditorDialog(bool isXAxis)
|
||||
{
|
||||
showDialog(new ChartAxisEditor(this, page(), isXAxis, settings()));
|
||||
}
|
||||
|
||||
BaseDesignIntf *ChartItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
ChartItem* result = new ChartItem(owner,parent);
|
||||
@ -797,25 +803,26 @@ void AbstractSeriesChart::updateMinAndMaxValues()
|
||||
qreal maxXValue = 0;
|
||||
qreal minXValue = 0;
|
||||
if (m_chartItem->itemMode() == DesignMode) {
|
||||
maxYValue = 40;
|
||||
maxXValue = 40;
|
||||
} else {
|
||||
for (SeriesItem* series : m_chartItem->series()){
|
||||
for (qreal value : series->data()->values()){
|
||||
minYValue = std::min(minYValue, value);
|
||||
maxYValue = std::max(maxYValue, value);
|
||||
}
|
||||
if (series->data()->xAxisValues().isEmpty()) {
|
||||
// Grid plot starts from 0 on x axis so x range must be decresed by 1
|
||||
const bool startingFromZero = m_chartItem->chartType() == ChartItem::GridLines;
|
||||
const qreal valuesCount = this->valuesCount() - (startingFromZero ? 1 : 0);
|
||||
minXValue = std::min(0.0, minXValue);
|
||||
maxXValue = std::max(valuesCount, maxXValue);
|
||||
} else {
|
||||
for (qreal value : series->data()->xAxisValues()){
|
||||
minXValue = std::min(value, minXValue);
|
||||
maxXValue = std::max(value, maxXValue);
|
||||
}
|
||||
m_chartItem->xAxisData()->updateForDesignMode();
|
||||
m_chartItem->yAxisData()->updateForDesignMode();
|
||||
return;
|
||||
}
|
||||
|
||||
for (SeriesItem* series : m_chartItem->series()){
|
||||
for (qreal value : series->data()->values()){
|
||||
minYValue = std::min(minYValue, value);
|
||||
maxYValue = std::max(maxYValue, value);
|
||||
}
|
||||
if (series->data()->xAxisValues().isEmpty()) {
|
||||
// Grid plot starts from 0 on x axis so x range must be decresed by 1
|
||||
const bool startingFromZero = m_chartItem->chartType() == ChartItem::GridLines;
|
||||
const qreal valuesCount = this->valuesCount() - (startingFromZero ? 1 : 0);
|
||||
minXValue = std::min(0.0, minXValue);
|
||||
maxXValue = std::max(valuesCount, maxXValue);
|
||||
} else {
|
||||
for (qreal value : series->data()->xAxisValues()){
|
||||
minXValue = std::min(value, minXValue);
|
||||
maxXValue = std::max(value, maxXValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +209,9 @@ public:
|
||||
|
||||
AxisData *xAxisData();
|
||||
AxisData *yAxisData();
|
||||
|
||||
void showAxisEditorDialog(bool isXAxis);
|
||||
|
||||
QList<SeriesItem *> &series();
|
||||
void setSeries(const QList<SeriesItem *> &series);
|
||||
bool isSeriesExists(const QString& name);
|
||||
|
@ -47,6 +47,7 @@ SOURCES += \
|
||||
$$REPORT_PATH/items/lrabstractlayout.cpp \
|
||||
$$REPORT_PATH/items/lrchartitem.cpp \
|
||||
$$REPORT_PATH/items/lrchartitemeditor.cpp \
|
||||
$$REPORT_PATH/items/lrchartaxiseditor.cpp \
|
||||
$$REPORT_PATH/items/charts/lrhorizontalbarchart.cpp \
|
||||
$$REPORT_PATH/items/charts/lrlineschart.cpp \
|
||||
$$REPORT_PATH/items/charts/lrgridlineschart.cpp \
|
||||
@ -131,6 +132,7 @@ HEADERS += \
|
||||
$$REPORT_PATH/items/lrabstractlayout.h \
|
||||
$$REPORT_PATH/items/lrchartitem.h \
|
||||
$$REPORT_PATH/items/lrchartitemeditor.h \
|
||||
$$REPORT_PATH/items/lrchartaxiseditor.h \
|
||||
$$REPORT_PATH/items/charts/lrhorizontalbarchart.h \
|
||||
$$REPORT_PATH/items/charts/lrlineschart.h \
|
||||
$$REPORT_PATH/items/charts/lrgridlineschart.h \
|
||||
@ -195,6 +197,7 @@ FORMS += \
|
||||
$$REPORT_PATH/lraboutdialog.ui \
|
||||
$$REPORT_PATH/lrsettingdialog.ui \
|
||||
$$REPORT_PATH/items/lrchartitemeditor.ui \
|
||||
$$REPORT_PATH/items/lrchartaxiseditor.ui \
|
||||
$$REPORT_PATH/items/lrimageitemeditor.ui \
|
||||
$$REPORT_PATH/scripteditor/lrscripteditor.ui
|
||||
|
||||
|
@ -43,6 +43,16 @@ void AxisData::update(qreal minValue, qreal maxValue)
|
||||
update();
|
||||
}
|
||||
|
||||
void AxisData::updateForDesignMode()
|
||||
{
|
||||
m_minValue = 0;
|
||||
m_maxValue = 40;
|
||||
bool tmp = m_calculateAxisScale;
|
||||
m_calculateAxisScale = false;
|
||||
update();
|
||||
m_calculateAxisScale = tmp;
|
||||
}
|
||||
|
||||
int AxisData::segmentCount() const
|
||||
{
|
||||
return m_segmentCount;
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
void copy(AxisData *other);
|
||||
void update();
|
||||
void update(qreal minValue, qreal maxValue);
|
||||
void updateForDesignMode();
|
||||
|
||||
int segmentCount() const;
|
||||
|
||||
|
57
limereport/objectinspector/propertyItems/lraxispropitem.cpp
Normal file
57
limereport/objectinspector/propertyItems/lraxispropitem.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include "lraxispropitem.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <lrchartitemeditor.h>
|
||||
#include <lrpagedesignintf.h>
|
||||
#include <lrreportengine_p.h>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem * createYAxisPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::AxisPropItem(object, objects, name, displayName, data, parent, readonly, false);
|
||||
}
|
||||
|
||||
LimeReport::ObjectPropItem * createXAxisPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::AxisPropItem(object, objects, name, displayName, data, parent, readonly, true);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredXAxisProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("xAxisSettings", "LimeReport::ChartItem"), QObject::tr("X axis"), createXAxisPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredYAxisProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("yAxisSettings", "LimeReport::ChartItem"), QObject::tr("Y axis"), createYAxisPropItem);
|
||||
}
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *AxisPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new AxisPropEditor(qobject_cast<ChartItem*>(object()), m_isXAxis, parent);
|
||||
}
|
||||
|
||||
QString AxisPropItem::displayValue() const
|
||||
{
|
||||
return QObject::tr("Axis");
|
||||
}
|
||||
|
||||
AxisPropEditor::AxisPropEditor(ChartItem *chart, bool isXAxis, QWidget *parent)
|
||||
: QWidget(parent), m_button(new QPushButton(this)), m_chart(chart), m_isXAxis(isXAxis)
|
||||
{
|
||||
m_button->setText("...");
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_button);
|
||||
layout->setSpacing(1);
|
||||
layout->setContentsMargins(1,0,1,1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
}
|
||||
|
||||
void AxisPropEditor::slotButtonClicked()
|
||||
{
|
||||
m_chart->showAxisEditorDialog(m_isXAxis);
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
}
|
43
limereport/objectinspector/propertyItems/lraxispropitem.h
Normal file
43
limereport/objectinspector/propertyItems/lraxispropitem.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef AXISPROPITEM_H
|
||||
#define AXISPROPITEM_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <lrobjectpropitem.h>
|
||||
#include <lrchartitem.h>
|
||||
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class AxisPropEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AxisPropEditor(ChartItem* chart, bool isXAxis, QWidget *parent = 0);
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
private:
|
||||
QPushButton* m_button;
|
||||
ChartItem* m_chart;
|
||||
bool m_isXAxis;
|
||||
};
|
||||
|
||||
class AxisPropItem: public LimeReport::ObjectPropItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AxisPropItem():ObjectPropItem(){}
|
||||
AxisPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly, bool isXAxis)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly), m_isXAxis(isXAxis){}
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
QString displayValue() const;
|
||||
|
||||
private:
|
||||
bool m_isXAxis = false;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // AXISPROPITEM_H
|
Loading…
Reference in New Issue
Block a user