mirror of
https://github.com/fralx/LimeReport.git
synced 2025-09-23 08:29:07 +03:00
ChartItem: Series property editor has been added
This commit is contained in:
@@ -95,13 +95,17 @@ void ObjectInspectorTreeView::mousePressEvent(QMouseEvent *event)
|
||||
if ((event->button()==Qt::LeftButton)){
|
||||
QModelIndex index=indexAt(event->pos());
|
||||
if (index.isValid()){
|
||||
if (event->pos().x()<indentation()) {
|
||||
if (event->pos().x() < indentation()) {
|
||||
if (!nodeFromIndex(index)->isHaveValue())
|
||||
setExpanded(index,!isExpanded(index));
|
||||
} else {
|
||||
if ((index.column()==1)&&(!nodeFromIndex(index)->isHaveChildren())) {
|
||||
setCurrentIndex(index);
|
||||
edit(index);
|
||||
|
||||
Qt::ItemFlags flags = index.model()->flags(index);
|
||||
if ( !(((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0)) )
|
||||
edit(index);
|
||||
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
@@ -363,14 +363,14 @@ QModelIndex QObjectPropertyModel::parent(const QModelIndex &child) const
|
||||
|
||||
Qt::ItemFlags QObjectPropertyModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if ((index.column()==1)&&(!nodeFromIndex(index)->isValueReadonly())) return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||
if ((index.column() == 1) && (!nodeFromIndex(index)->isValueReadonly())) return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||
else return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
}
|
||||
|
||||
CreatePropItem QObjectPropertyModel::propertyItemCreator(QMetaProperty prop)
|
||||
{
|
||||
CreatePropItem creator=0;
|
||||
creator=ObjectPropFactory::instance().objectCreator(APropIdent(prop.name(),prop.enclosingMetaObject()->className()));
|
||||
CreatePropItem creator = 0;
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.name(),prop.enclosingMetaObject()->className()));
|
||||
if (!creator){
|
||||
if (prop.isFlagType()){
|
||||
creator=ObjectPropFactory::instance().objectCreator(APropIdent("flags",""));
|
||||
@@ -390,7 +390,7 @@ CreatePropItem QObjectPropertyModel::propertyItemCreator(QMetaProperty prop)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
creator=ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(),""));
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(),""));
|
||||
if (!creator) {qDebug()<<"Editor for propperty name = \""<<prop.name()<<"\" & property type =\""<<prop.typeName()<<"\" not found!";}
|
||||
}
|
||||
return creator;
|
||||
@@ -409,7 +409,7 @@ ObjectPropItem * QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QO
|
||||
QString(tr(prop.name())),
|
||||
object->property(prop.name()),
|
||||
parent,
|
||||
!(prop.isWritable()&&prop.isDesignable())
|
||||
!(prop.isWritable() && prop.isDesignable())
|
||||
);
|
||||
} else {
|
||||
propertyItem=new ObjectPropItem(
|
||||
|
@@ -48,12 +48,12 @@ QWidget* ImagePropItem::createProperyEditor(QWidget *parent) const
|
||||
|
||||
QString ImagePropItem::displayValue() const
|
||||
{
|
||||
return (propertyValue().isNull())?"":"Picture";
|
||||
return (propertyValue().isNull()) ? "" : QObject::tr("image");
|
||||
}
|
||||
|
||||
void ImagePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ImageEditor *editor =qobject_cast<ImageEditor*>(propertyEditor);
|
||||
ImageEditor *editor = qobject_cast<ImageEditor*>(propertyEditor);
|
||||
editor->setImage(propertyValue().value<QImage>());
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,51 @@
|
||||
#include "lrseriespropitem.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <lrchartitemeditor.h>
|
||||
#include <lrpagedesignintf.h>
|
||||
#include <lrreportengine_p.h>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createSeriesPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::SeriesPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredSeriesProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("series", "LimeReport::ChartItem"), QObject::tr("series"), createSeriesPropItem);
|
||||
}
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *SeriesPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new SeriesPropEditor(qobject_cast<ChartItem*>(object()), parent);
|
||||
}
|
||||
|
||||
QString SeriesPropItem::displayValue() const
|
||||
{
|
||||
return QObject::tr("Series");
|
||||
}
|
||||
|
||||
SeriesPropEditor::SeriesPropEditor(ChartItem *chart, QWidget *parent)
|
||||
: QWidget(parent), m_button(new QPushButton(this)), m_chart(chart)
|
||||
{
|
||||
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 SeriesPropEditor::slotButtonClicked()
|
||||
{
|
||||
m_chart->showEditorDialog();
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
|
||||
}
|
41
limereport/objectinspector/propertyItems/lrseriespropitem.h
Normal file
41
limereport/objectinspector/propertyItems/lrseriespropitem.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef SERIESPROPITEM_H
|
||||
#define SERIESPROPITEM_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <lrobjectpropitem.h>
|
||||
#include <lrchartitem.h>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class SeriesPropEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SeriesPropEditor(ChartItem* chart, QWidget *parent = 0);
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
private:
|
||||
QPushButton* m_button;
|
||||
ChartItem* m_chart;
|
||||
};
|
||||
|
||||
class SeriesPropItem : public LimeReport::ObjectPropItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SeriesPropItem():ObjectPropItem(){}
|
||||
SeriesPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
QString displayValue() const;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // SERIESPROPITEM_H
|
@@ -54,7 +54,7 @@ QWidget * StringPropItem::createProperyEditor(QWidget *parent) const
|
||||
|
||||
void StringPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ButtonLineEditor *editor =qobject_cast<ButtonLineEditor *>(propertyEditor);
|
||||
ButtonLineEditor *editor = qobject_cast<ButtonLineEditor *>(propertyEditor);
|
||||
editor->setText(propertyValue().toString());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user