0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 00:54:39 +03:00

Merge branch '1.4_ChartItem' into develop

This commit is contained in:
Arin Alex 2017-07-13 14:40:40 +03:00
commit e5e873eb40
10 changed files with 1853 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -41,5 +41,6 @@
<file alias="ImageItem">images/imageItem4.png</file> <file alias="ImageItem">images/imageItem4.png</file>
<file alias="ShapeItem">images/shapes7.png</file> <file alias="ShapeItem">images/shapes7.png</file>
<file alias="BarcodeItem">images/barcode5.png</file> <file alias="BarcodeItem">images/barcode5.png</file>
<file alias="ChartItem">images/pie_chart2.png</file>
</qresource> </qresource>
</RCC> </RCC>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,208 @@
#ifndef LRCHARTITEM_H
#define LRCHARTITEM_H
#include "lritemdesignintf.h"
namespace LimeReport{
QColor generateColor();
extern QColor color_map[39];
class IDataSource;
class SeriesItemData : public QObject{
Q_OBJECT
public:
QList<qreal>& values(){ return m_values;}
QList<QString>& labels(){ return m_labels;}
QList<QColor>& colors() { return m_colors;}
private:
QList<qreal> m_values;
QList<QString> m_labels;
QList<QColor> m_colors;
};
class SeriesItem : public QObject{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString valuesColumn READ valuesColumn WRITE setValuesColumn )
Q_PROPERTY(QString labelsColumn READ labelsColumn WRITE setLabelsColumn )
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
SeriesItem(QObject* parent = 0):QObject(parent){}
QString name() const;
void setName(const QString &name);
QString valuesColumn() const;
void setValuesColumn(const QString &valuesColumn);
QString labelsColumn() const;
void setLabelsColumn(const QString &labelsColumn);
SeriesItem* clone();
void fillSeriesData(IDataSource* dataSource);
SeriesItemData* data(){ return &m_data;}
QColor color() const;
void setColor(const QColor &color);
private:
QString m_name;
QString m_valuesColumn;
QString m_labelsColumn;
SeriesItemData m_data;
QColor m_color;
};
class ChartItem;
class AbstractChart {
public:
AbstractChart(ChartItem* chartItem);
virtual ~AbstractChart(){}
virtual void paintChart(QPainter *painter, QRectF rect) = 0;
virtual void paintChartLegend(QPainter *painter, QRectF legendRect) =0;
virtual QSizeF calcChartLegendSize(const QFont &font) = 0;
virtual QRectF calcChartLegendRect(const QFont& font, const QRectF& parentRect, bool takeAllRect, qreal borderMargin, qreal titleOffset);
protected:
virtual void prepareLegendToPaint(QRectF& legendRect, QPainter *painter);
protected:
ChartItem* m_chartItem;
QList<QString> m_designLabels;
};
class AbstractSeriesChart: public AbstractChart{
public:
AbstractSeriesChart(ChartItem* chartItem);
protected:
qreal maxValue();
qreal minValue();
int valuesCount();
int seriesCount();
QSizeF calcChartLegendSize(const QFont &font);
qreal* designValues(){ return m_designValues;}
private:
qreal m_designValues [9];
};
class PieChart : public AbstractChart{
public:
PieChart(ChartItem* chartItem):AbstractChart(chartItem){}
QSizeF calcChartLegendSize(const QFont &font);
void paintChart(QPainter *painter, QRectF chartRect);
void paintChartLegend(QPainter *painter, QRectF legendRect);
protected:
void drawPercent(QPainter *painter, QRectF chartRect, qreal startAngle, qreal angle);
};
class AbstractBarChart: public AbstractSeriesChart{
public:
AbstractBarChart(ChartItem* chartItem):AbstractSeriesChart(chartItem){}
qreal hPadding(QRectF chartRect);
qreal vPadding(QRectF chartRect);
void paintChartLegend(QPainter *painter, QRectF legendRect);
};
class HorizontalBarChart: public AbstractBarChart{
public:
HorizontalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
qreal valuesHMargin(QPainter *painter);
qreal valuesVMargin(QPainter *painter);
void paintChart(QPainter *painter, QRectF chartRect);
void paintHorizontalGrid(QPainter *painter, QRectF gridRect);
void paintHorizontalBars(QPainter *painter, QRectF barsRect);
QRectF labelsRect(QPainter* painter, QRectF labelsRect);
void paintLabels(QPainter *painter, QRectF labelsRect);
protected:
QFont adaptLabelsFont(QRectF rect, QFont font);
QFont adaptValuesFont(qreal width, QFont font);
};
class VerticalBarChart: public AbstractBarChart{
public:
VerticalBarChart(ChartItem* chartItem):AbstractBarChart(chartItem){}
qreal valuesHMargin(QPainter *painter);
qreal valuesVMargin(QPainter *painter);
QRectF labelsRect(QPainter* painter, QRectF labelsRect);
void paintChart(QPainter *painter, QRectF chartRect);
void paintVerticalGrid(QPainter *painter, QRectF gridRect);
void paintVerticalBars(QPainter *painter, QRectF barsRect);
void paintLabels(QPainter *painter, QRectF labelsRect);
};
class ChartItem : public LimeReport::ItemDesignIntf
{
Q_OBJECT
Q_ENUMS(LegendAlign)
Q_ENUMS(TitleAlign)
Q_ENUMS(ChartType)
Q_PROPERTY(ACollectionProperty series READ fakeCollectionReader)
Q_PROPERTY(QString datasource READ datasource WRITE setDatasource)
Q_PROPERTY(QString chartTitle READ chartTitle WRITE setChartTitle)
Q_PROPERTY(bool drawLegendBorder READ drawLegendBorder WRITE setDrawLegendBorder)
Q_PROPERTY(LegendAlign legendAlign READ legendAlign WRITE setLegendAlign)
Q_PROPERTY(TitleAlign titleAlign READ titleAlign WRITE setTitleAlign)
Q_PROPERTY(ChartType chartType READ chartType WRITE setChartType)
Q_PROPERTY(QString labelsField READ labelsField WRITE setLabelsField)
friend class AbstractChart;
public:
enum LegendAlign{LegendAlignTop,LegendAlignCenter,LegendAlignBottom};
enum TitleAlign{TitleAlignLeft, TitleAlignCenter, TitleAlignRight};
enum ChartType{Pie, VerticalBar, HorizontalBar};
ChartItem(QObject* owner, QGraphicsItem* parent);
~ChartItem();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QList<SeriesItem *> &series();
void setSeries(const QList<SeriesItem *> &series);
bool isSeriesExists(const QString& name);
QString datasource() const;
void setDatasource(const QString &datasource);
QString chartTitle() const;
void setChartTitle(const QString &chartTitle);
bool drawLegendBorder() const;
void setDrawLegendBorder(bool drawLegendBorder);
LegendAlign legendAlign() const;
void setLegendAlign(const LegendAlign &legendAlign);
TitleAlign titleAlign() const;
void setTitleAlign(const TitleAlign &titleAlign);
ChartType chartType() const;
void setChartType(const ChartType &chartType);
QString labelsField() const;
void setLabelsField(const QString &labelsField);
QList<QString> labels() const;
void setLabels(const QList<QString> &labels);
protected:
void paintChartTitle(QPainter* painter, QRectF titleRect);
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
//ICollectionContainer
QObject* createElement(const QString& collectionName,const QString& elementType);
int elementsCount(const QString& collectionName);
QObject* elementAt(const QString& collectionName,int index);
void collectionLoadFinished(const QString& collectionName){Q_UNUSED(collectionName)}
void updateItemSize(DataSourceManager *dataManager, RenderPass, int);
void fillLabels(IDataSource* dataSource);
QWidget* defaultEditor();
private:
QList<SeriesItem*> m_series;
// QList< QPointer<SeriesItem> > m_series;
QString m_datasource;
QPixmap m_chartImage;
QString m_title;
AbstractChart* m_chart;
bool m_legendBorder;
LegendAlign m_legendAlign;
TitleAlign m_titleAlign;
ChartType m_chartType;
QString m_labelsField;
QList<QString> m_labels;
};
} //namespace LimeReport
#endif // LRCHARTITEM_H

View File

@ -0,0 +1,249 @@
#include "lrchartitemeditor.h"
#include "ui_lrchartitemeditor.h"
#include "lrchartitem.h"
#include "lrpagedesignintf.h"
#include <QColorDialog>
ChartItemEditor::ChartItemEditor(LimeReport::ChartItem *item, LimeReport::PageDesignIntf *page, QSettings *settings, QWidget *parent):
QWidget(parent), ui(new Ui::ChartItemEditor), m_charItem(item), m_page(page),
m_settings(settings), m_ownedSettings(false), m_isReadingSetting(false)
{
ui->setupUi(this);
QHBoxLayout* colorLayout = new QHBoxLayout();
colorLayout->setMargin(0);
m_colorButton = new QToolButton();
m_colorButton->setText("...");
m_colorButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
m_colorIndicator = new ColorIndicator();
m_colorIndicator->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
ui->colorWidget->setLayout(colorLayout);
colorLayout->addWidget(m_colorIndicator);
colorLayout->addWidget(m_colorButton);
colorLayout->insertStretch(0);
readSetting();
init();
connect(m_colorButton, SIGNAL(clicked(bool)), this, SLOT(slotChangeSeriesColor()));
}
ChartItemEditor::~ChartItemEditor()
{
#ifdef Q_OS_WIN
writeSetting();
#endif
#ifdef Q_OS_MAC
writeSetting();
#endif
delete ui;
}
QSettings* ChartItemEditor::settings()
{
if (m_settings){
return m_settings;
} else {
m_settings = new QSettings("LimeReport",QApplication::applicationName());
m_ownedSettings = true;
return m_settings;
}
}
void ChartItemEditor::readSetting()
{
if (settings()==0) return;
m_isReadingSetting = true;
settings()->beginGroup("ChartItemEditor");
QVariant v = settings()->value("Geometry");
if (v.isValid()){
restoreGeometry(v.toByteArray());
}
v = settings()->value("State");
if (v.isValid()){
ui->splitter->restoreState(v.toByteArray());
}
settings()->endGroup();
m_isReadingSetting = false;
}
void ChartItemEditor::writeSetting()
{
if (settings()!=0){
settings()->beginGroup("ChartItemEditor");
settings()->setValue("Geometry",saveGeometry());
settings()->setValue("State",ui->splitter->saveState());
settings()->endGroup();
}
}
void ChartItemEditor::rebuildTable()
{
ui->tableWidget->clearContents();
ui->tableWidget->setRowCount(m_charItem->series().count());
for( int i=0;i<m_charItem->series().count();++i){
QTableWidgetItem* newRow = new QTableWidgetItem(m_charItem->series().at(i)->name());
ui->tableWidget->setItem(i,0,newRow);
}
}
void ChartItemEditor::init()
{
m_initing = true;
ui->tableWidget->setColumnCount(1);
ui->tableWidget->setRowCount(m_charItem->series().count());
ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
ui->tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Series name"));
rebuildTable();
if (!m_charItem->datasource().isEmpty()){
if (m_page && m_page->datasourceManager()){
LimeReport::IDataSource* ds = m_page->datasourceManager()->dataSource(m_charItem->datasource());
if (ds){
for (int i=0;i<ds->columnCount();++i){
ui->valuesFieldComboBox->addItem(ds->columnNameByIndex(i));
ui->labelsFieldComboBox->addItem(ds->columnNameByIndex(i));
}
}
}
}
ui->labelsFieldComboBox->setCurrentText(m_charItem->labelsField());
if (!m_charItem->series().isEmpty()){
enableSeriesEditor();
ui->tableWidget->selectRow(0);
} else {
disableSeriesEditor();
}
m_initing = false;
}
void ChartItemEditor::enableSeriesEditor()
{
ui->seriesNameLineEdit->setEnabled(true);
ui->valuesFieldComboBox->setEnabled(true);
m_colorButton->setEnabled(true);
m_colorIndicator->setEnabled(true);
}
void ChartItemEditor::disableSeriesEditor()
{
ui->seriesNameLineEdit->setText("");
ui->seriesNameLineEdit->setDisabled(true);
ui->valuesFieldComboBox->setDisabled(true);
m_colorButton->setDisabled(true);
m_colorIndicator->setDisabled(true);
ui->valuesFieldComboBox->setCurrentText("");
}
LimeReport::SeriesItem *ChartItemEditor::currentSeries()
{
int curRow = ui->tableWidget->currentRow();
if ((curRow>-1) && !m_charItem->series().isEmpty() && m_charItem->series().count()>curRow){
return m_charItem->series().at(curRow);
}
return 0;
}
void ChartItemEditor::resizeEvent(QResizeEvent *)
{
#ifdef Q_OS_UNIX
writeSetting();
#endif
}
void ChartItemEditor::moveEvent(QMoveEvent *)
{
#ifdef Q_OS_UNIX
writeSetting();
#endif
}
void ChartItemEditor::on_splitter_splitterMoved(int , int )
{
#ifdef Q_OS_UNIX
writeSetting();
#endif
}
void ChartItemEditor::on_pbOk_clicked()
{
close();
}
void ChartItemEditor::slotAddSeries()
{
LimeReport::SeriesItem* series = new LimeReport::SeriesItem();
int curSeriesNumber = m_charItem->series().count();
while (m_charItem->isSeriesExists("Series"+QString::number(curSeriesNumber))) curSeriesNumber++;
series->setName("Series"+QString::number(curSeriesNumber));
series->setValuesColumn("");
series->setLabelsColumn("");
series->setColor((m_charItem->series().count()<32)?LimeReport::color_map[m_charItem->series().count()]:LimeReport::generateColor());
m_charItem->series().append(series);
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);
ui->valuesFieldComboBox->setCurrentText("");
}
void ChartItemEditor::slotDeleteSeries()
{
QList<LimeReport::SeriesItem*> itemsToRemove;
foreach(QModelIndex index,ui->tableWidget->selectionModel()->selectedRows()){
itemsToRemove.append(m_charItem->series().at(index.row()));
};
foreach (LimeReport::SeriesItem* series, itemsToRemove){
m_charItem->series().removeOne(series);
delete series;
}
rebuildTable();
disableSeriesEditor();
}
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());
ui->valuesFieldComboBox->setCurrentText(series->valuesColumn());
m_colorIndicator->setColor(series->color());
enableSeriesEditor();
}
}
void ChartItemEditor::on_seriesNameLineEdit_textChanged(const QString &arg1)
{
if (currentSeries()){
currentSeries()->setName(arg1);
ui->tableWidget->currentItem()->setText(arg1);
}
}
void ChartItemEditor::on_valuesFieldComboBox_currentTextChanged(const QString &arg1)
{
if (currentSeries()){
currentSeries()->setValuesColumn(arg1);
}
}
void ChartItemEditor::on_labelsFieldComboBox_currentTextChanged(const QString &arg1)
{
if (!m_initing)
m_charItem->setLabelsField(arg1);
}
void ChartItemEditor::slotChangeSeriesColor()
{
QColorDialog colorDialog;
if (colorDialog.exec()){
currentSeries()->setColor(colorDialog.selectedColor());
m_colorIndicator->setColor(colorDialog.selectedColor());
}
}

View File

@ -0,0 +1,57 @@
#ifndef CHARITEMEDITOR_H
#define CHARITEMEDITOR_H
#include <QWidget>
#include "lrchartitem.h"
#include "lrcolorindicator.h"
#include <QTableWidgetItem>
#include <QToolButton>
namespace Ui {
class ChartItemEditor;
}
class ChartItemEditor : public QWidget
{
Q_OBJECT
public:
ChartItemEditor(LimeReport::ChartItem* item, LimeReport::PageDesignIntf* page,
QSettings* settings=0, QWidget *parent = 0);
~ChartItemEditor();
public:
QSettings *settings();
void rebuildTable();
protected:
void resizeEvent(QResizeEvent *);
void moveEvent(QMoveEvent *);
private slots:
void on_splitter_splitterMoved(int, int);
void on_pbOk_clicked();
void slotAddSeries();
void slotDeleteSeries();
void on_tableWidget_itemSelectionChanged();
void on_seriesNameLineEdit_textChanged(const QString &arg1);
void on_valuesFieldComboBox_currentTextChanged(const QString &arg1);
void on_labelsFieldComboBox_currentTextChanged(const QString &arg1);
void slotChangeSeriesColor();
private:
void readSetting();
void writeSetting();
void init();
void enableSeriesEditor();
void disableSeriesEditor();
LimeReport::SeriesItem* currentSeries();
private:
Ui::ChartItemEditor *ui;
LimeReport::ChartItem* m_charItem;
LimeReport::PageDesignIntf* m_page;
QSettings* m_settings;
bool m_ownedSettings;
bool m_isReadingSetting;
QToolButton* m_colorButton;
ColorIndicator* m_colorIndicator;
bool m_initing;
};
#endif // CHARITEMEDITOR_H

View File

@ -0,0 +1,223 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChartItemEditor</class>
<widget class="QWidget" name="ChartItemEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>268</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="gbSeries">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Series</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="rightMargin">
<number>4</number>
</property>
<item>
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbAddSeries">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbDeleteSeries">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QFormLayout" name="seriesData">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="seriesNameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="valuesFieldLabel">
<property name="text">
<string>Values field</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="valuesFieldComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="colorWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelsFieldLabel">
<property name="text">
<string>Labels field</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="labelsFieldComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</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="pbOk">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pbAddSeries</sender>
<signal>clicked()</signal>
<receiver>ChartItemEditor</receiver>
<slot>slotAddSeries()</slot>
<hints>
<hint type="sourcelabel">
<x>57</x>
<y>136</y>
</hint>
<hint type="destinationlabel">
<x>8</x>
<y>75</y>
</hint>
</hints>
</connection>
<connection>
<sender>pbDeleteSeries</sender>
<signal>clicked()</signal>
<receiver>ChartItemEditor</receiver>
<slot>slotDeleteSeries()</slot>
<hints>
<hint type="sourcelabel">
<x>142</x>
<y>136</y>
</hint>
<hint type="destinationlabel">
<x>372</x>
<y>137</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>slotAddSeries()</slot>
<slot>slotDeleteSeries()</slot>
</slots>
</ui>

View File

@ -94,8 +94,11 @@ SOURCES += \
$$REPORT_PATH/lrsimplecrypt.cpp \ $$REPORT_PATH/lrsimplecrypt.cpp \
$$REPORT_PATH/lraboutdialog.cpp \ $$REPORT_PATH/lraboutdialog.cpp \
$$REPORT_PATH/lrsettingdialog.cpp \ $$REPORT_PATH/lrsettingdialog.cpp \
$$REPORT_PATH/lritemscontainerdesignitf.cpp $$REPORT_PATH/lritemscontainerdesignitf.cpp \
$$REPORT_PATH/lrcolorindicator.cpp \
$$REPORT_PATH/items/lrchartitem.cpp \
$$REPORT_PATH/items/lrchartitemeditor.cpp
contains(CONFIG, staticlib){ contains(CONFIG, staticlib){
SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp SOURCES += $$REPORT_PATH/lrfactoryinitializer.cpp
} }
@ -199,8 +202,11 @@ HEADERS += \
$$REPORT_PATH/lrcallbackdatasourceintf.h \ $$REPORT_PATH/lrcallbackdatasourceintf.h \
$$REPORT_PATH/lrsettingdialog.h \ $$REPORT_PATH/lrsettingdialog.h \
$$REPORT_PATH/lrpreviewreportwidget_p.h \ $$REPORT_PATH/lrpreviewreportwidget_p.h \
$$REPORT_PATH/lritemscontainerdesignitf.h $$REPORT_PATH/lritemscontainerdesignitf.h \
$$REPORT_PATH/lrcolorindicator.h \
$$REPORT_PATH/items/lrchartitem.h \
$$REPORT_PATH/items/lrchartitemeditor.h
contains(CONFIG, staticlib){ contains(CONFIG, staticlib){
HEADERS += $$REPORT_PATH/lrfactoryinitializer.h HEADERS += $$REPORT_PATH/lrfactoryinitializer.h
} }
@ -221,6 +227,7 @@ FORMS += \
$$REPORT_PATH/lraboutdialog.ui \ $$REPORT_PATH/lraboutdialog.ui \
$$REPORT_PATH/lrsettingdialog.ui \ $$REPORT_PATH/lrsettingdialog.ui \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.ui \ $$REPORT_PATH/scriptbrowser/lrscriptbrowser.ui \
$$REPORT_PATH/items/lrchartitemeditor.ui
RESOURCES += \ RESOURCES += \
$$REPORT_PATH/objectinspector/lobjectinspector.qrc \ $$REPORT_PATH/objectinspector/lobjectinspector.qrc \

View File

@ -0,0 +1,38 @@
#include "lrcolorindicator.h"
#include <QPainter>
void ColorIndicator::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.save();
painter.setBrush(m_color);
painter.setPen(Qt::gray);
QRect rect = event->rect().adjusted(3,3,-4,-4);
rect.setWidth(rect.height());
painter.setRenderHint(QPainter::Antialiasing);
painter.drawEllipse(rect);
painter.restore();
}
ColorIndicator::ColorIndicator(QWidget *parent)
:QWidget(parent), m_color(Qt::white){
setAttribute(Qt::WA_StaticContents);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
setFocusPolicy(Qt::NoFocus);
}
QColor ColorIndicator::color() const
{
return m_color;
}
void ColorIndicator::setColor(const QColor &color)
{
m_color = color;
update();
}
QSize ColorIndicator::sizeHint() const
{
return QSize(20,20);
}

View File

@ -0,0 +1,20 @@
#ifndef COLORINDICATOR_H
#define COLORINDICATOR_H
#include <QWidget>
#include <QPaintEvent>
class ColorIndicator : public QWidget{
Q_OBJECT
public:
ColorIndicator(QWidget* parent = 0);
QColor color() const;
void setColor(const QColor &color);
QSize sizeHint() const;
protected:
void paintEvent(QPaintEvent *event);
private:
QColor m_color;
};
#endif // COLORINDICATOR_H