mirror of
https://github.com/fralx/LimeReport.git
synced 2025-11-25 00:18:06 +03:00
Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
This commit is contained in:
@@ -28,23 +28,26 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbuttonlineeditor.h"
|
||||
#include <QMessageBox>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QFocusEvent>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QStyle>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
#include <QDesktopWidget>
|
||||
#else
|
||||
#include <QScreen>
|
||||
#endif
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent) :
|
||||
QWidget(parent), m_overButton(false), m_propertyName(propertyName)
|
||||
ButtonLineEditor::ButtonLineEditor(const QString& propertyName, QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_overButton(false),
|
||||
m_propertyName(propertyName)
|
||||
{
|
||||
m_lineEdit = new QLineEdit(this);
|
||||
m_lineEdit->installEventFilter(this);
|
||||
@@ -54,55 +57,53 @@ ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent)
|
||||
m_buttonEdit->installEventFilter(this);
|
||||
m_buttonEdit->setAttribute(Qt::WA_Hover);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_lineEdit);
|
||||
layout->addWidget(m_buttonEdit);
|
||||
layout->setContentsMargins(1,1,1,1);
|
||||
layout->setContentsMargins(1, 1, 1, 1);
|
||||
layout->setSpacing(0);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_buttonEdit,SIGNAL(clicked()),this,SLOT(editButtonClicked()));
|
||||
//connect(m_lineEdit,SIGNAL(editingFinished()),this,SLOT(lineEditEditingFinished()));
|
||||
connect(m_buttonEdit, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
|
||||
// connect(m_lineEdit,SIGNAL(editingFinished()),this,SLOT(lineEditEditingFinished()));
|
||||
}
|
||||
|
||||
ButtonLineEditor::~ButtonLineEditor(){}
|
||||
ButtonLineEditor::~ButtonLineEditor() { }
|
||||
|
||||
void ButtonLineEditor::editButtonClicked()
|
||||
{
|
||||
TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,12,3)
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 3)
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(),
|
||||
QApplication::desktop()->availableGeometry()));
|
||||
#else
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QGuiApplication::screens().first()->availableGeometry()));
|
||||
editor->setGeometry(
|
||||
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(),
|
||||
QGuiApplication::screens().first()->availableGeometry()));
|
||||
#endif
|
||||
editor->setWindowTitle(m_propertyName);
|
||||
editor->setText(m_lineEdit->text());
|
||||
connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished()));
|
||||
connect(editor, SIGNAL(accepted()), this, SLOT(editingByEditorFinished()));
|
||||
editor->exec();
|
||||
}
|
||||
|
||||
void ButtonLineEditor::setText(const QString &value){
|
||||
m_lineEdit->setText(value);
|
||||
}
|
||||
void ButtonLineEditor::setText(const QString& value) { m_lineEdit->setText(value); }
|
||||
|
||||
QString ButtonLineEditor::text()
|
||||
{
|
||||
return m_lineEdit->text();
|
||||
}
|
||||
QString ButtonLineEditor::text() { return m_lineEdit->text(); }
|
||||
|
||||
bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
|
||||
bool ButtonLineEditor::eventFilter(QObject* target, QEvent* event)
|
||||
{
|
||||
|
||||
if (target==m_buttonEdit) {
|
||||
if (target == m_buttonEdit) {
|
||||
|
||||
if (event->type()==QEvent::HoverEnter){
|
||||
m_overButton=true;
|
||||
if (event->type() == QEvent::HoverEnter) {
|
||||
m_overButton = true;
|
||||
}
|
||||
if (event->type()==QEvent::HoverLeave){
|
||||
m_overButton=false;
|
||||
if (event->type() == QEvent::HoverLeave) {
|
||||
m_overButton = false;
|
||||
}
|
||||
if (event->type()==QEvent::FocusOut){
|
||||
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
|
||||
if (event->type() == QEvent::FocusOut) {
|
||||
if (static_cast<QFocusEvent*>(event)->reason() != Qt::MouseFocusReason) {
|
||||
m_lineEdit->setFocus();
|
||||
}
|
||||
}
|
||||
@@ -110,29 +111,27 @@ bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
|
||||
enterKeys.insert(Qt::Key_Enter);
|
||||
enterKeys.insert(Qt::Key_Return);
|
||||
|
||||
if (event->type()==QEvent::KeyPress){
|
||||
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())){
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())) {
|
||||
m_buttonEdit->click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (target==m_lineEdit){
|
||||
if (event->type()==QEvent::FocusOut){
|
||||
switch (static_cast<QFocusEvent*>(event)->reason()){
|
||||
if (target == m_lineEdit) {
|
||||
if (event->type() == QEvent::FocusOut) {
|
||||
switch (static_cast<QFocusEvent*>(event)->reason()) {
|
||||
case Qt::TabFocusReason:
|
||||
m_overButton=true;
|
||||
m_overButton = true;
|
||||
break;
|
||||
case Qt::MouseFocusReason:
|
||||
break;
|
||||
default:
|
||||
m_overButton=false;
|
||||
m_overButton = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
void ButtonLineEditor::editingByEditorFinished()
|
||||
@@ -142,4 +141,4 @@ void ButtonLineEditor::editingByEditorFinished()
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,41 +30,44 @@
|
||||
#ifndef LRBUTTONLINEEDIT_H
|
||||
#define LRBUTTONLINEEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ButtonLineEditor : public QWidget
|
||||
{
|
||||
class ButtonLineEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ButtonLineEditor(const QString& propertyName,QWidget *parent = 0);
|
||||
explicit ButtonLineEditor(const QString& propertyName, QWidget* parent = 0);
|
||||
~ButtonLineEditor();
|
||||
void setText(const QString &value);
|
||||
void setText(const QString& value);
|
||||
QString text();
|
||||
signals:
|
||||
void editingFinished();
|
||||
public slots:
|
||||
virtual void editButtonClicked();
|
||||
void editingByEditorFinished();
|
||||
|
||||
protected:
|
||||
QString propertyName(){return m_propertyName;}
|
||||
QString propertyName() { return m_propertyName; }
|
||||
|
||||
private:
|
||||
QLineEdit* m_lineEdit;
|
||||
QToolButton* m_buttonEdit;
|
||||
bool m_overButton;
|
||||
QString m_propertyName;
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
//QHBoxLayout* m_layout;
|
||||
bool eventFilter(QObject*, QEvent*);
|
||||
// QHBoxLayout* m_layout;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRBUTTONLINEEDIT_H
|
||||
|
||||
@@ -28,33 +28,34 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcheckboxeditor.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
CheckBoxEditor::CheckBoxEditor(QWidget *parent)
|
||||
:QWidget(parent), m_editing(false)
|
||||
{
|
||||
CheckBoxEditor::CheckBoxEditor(QWidget* parent): QWidget(parent), m_editing(false)
|
||||
{
|
||||
m_checkBox = new QCheckBox(this);
|
||||
init();
|
||||
}
|
||||
CheckBoxEditor::CheckBoxEditor(const QString &text, QWidget *parent)
|
||||
:QWidget(parent), m_editing(false)
|
||||
CheckBoxEditor::CheckBoxEditor(const QString& text, QWidget* parent):
|
||||
QWidget(parent),
|
||||
m_editing(false)
|
||||
{
|
||||
m_checkBox = new QCheckBox(text,this);
|
||||
m_checkBox = new QCheckBox(text, this);
|
||||
init();
|
||||
}
|
||||
|
||||
CheckBoxEditor::~CheckBoxEditor(){}
|
||||
CheckBoxEditor::~CheckBoxEditor() { }
|
||||
|
||||
void CheckBoxEditor::init()
|
||||
{
|
||||
QVBoxLayout *layout=new QVBoxLayout(this);
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->addStretch();
|
||||
layout->addWidget(m_checkBox);
|
||||
#ifdef HAVE_QT5
|
||||
@@ -62,56 +63,45 @@ void CheckBoxEditor::init()
|
||||
#endif
|
||||
connect(m_checkBox, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
|
||||
layout->addStretch();
|
||||
layout->setContentsMargins(2,1,1,1);
|
||||
layout->setContentsMargins(2, 1, 1, 1);
|
||||
layout->setSpacing(0);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::setEditing(bool value)
|
||||
{
|
||||
m_editing=value;
|
||||
}
|
||||
void CheckBoxEditor::setEditing(bool value) { m_editing = value; }
|
||||
|
||||
void CheckBoxEditor::setChecked(bool value)
|
||||
{
|
||||
m_checkBox->setChecked(value);
|
||||
}
|
||||
void CheckBoxEditor::setChecked(bool value) { m_checkBox->setChecked(value); }
|
||||
|
||||
bool CheckBoxEditor::isChecked()
|
||||
{
|
||||
return m_checkBox->isChecked();
|
||||
}
|
||||
bool CheckBoxEditor::isChecked() { return m_checkBox->isChecked(); }
|
||||
|
||||
void CheckBoxEditor::mousePressEvent(QMouseEvent *)
|
||||
void CheckBoxEditor::mousePressEvent(QMouseEvent*)
|
||||
{
|
||||
m_checkBox->setChecked(!m_checkBox->isChecked());
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
void CheckBoxEditor::keyPressEvent(QKeyEvent *event)
|
||||
void CheckBoxEditor::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key()==Qt::Key_Space) m_checkBox->setChecked(!m_checkBox->isChecked());
|
||||
if ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)){
|
||||
if (event->key() == Qt::Key_Space)
|
||||
m_checkBox->setChecked(!m_checkBox->isChecked());
|
||||
if ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down)) {
|
||||
emit editingFinished();
|
||||
}
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::showEvent(QShowEvent *)
|
||||
void CheckBoxEditor::showEvent(QShowEvent*)
|
||||
{
|
||||
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth))/2
|
||||
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth)) / 2
|
||||
#ifdef Q_OS_MAC
|
||||
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
+ QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
#endif
|
||||
;
|
||||
layout()->setContentsMargins(border,0,0,0);
|
||||
;
|
||||
layout()->setContentsMargins(border, 0, 0, 0);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::slotStateChanged(int)
|
||||
{
|
||||
emit editingFinished();
|
||||
}
|
||||
void CheckBoxEditor::slotStateChanged(int) { emit editingFinished(); }
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -32,33 +32,33 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class CheckBoxEditor : public QWidget
|
||||
{
|
||||
class CheckBoxEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CheckBoxEditor(QWidget * parent = 0);
|
||||
CheckBoxEditor(const QString & text, QWidget * parent = 0);
|
||||
CheckBoxEditor(QWidget* parent = 0);
|
||||
CheckBoxEditor(const QString& text, QWidget* parent = 0);
|
||||
~CheckBoxEditor();
|
||||
void setEditing(bool value);
|
||||
void setChecked(bool value);
|
||||
bool isChecked();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void showEvent(QShowEvent *);
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void showEvent(QShowEvent*);
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotStateChanged(int);
|
||||
|
||||
private:
|
||||
QCheckBox* m_checkBox;
|
||||
bool m_editing;
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRCHECKBOXEDITOR_H
|
||||
|
||||
@@ -28,50 +28,50 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcoloreditor.h"
|
||||
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
ColorEditor::ColorEditor(QWidget *parent) :
|
||||
QWidget(parent), m_buttonPressed(false)
|
||||
ColorEditor::ColorEditor(QWidget* parent): QWidget(parent), m_buttonPressed(false)
|
||||
{
|
||||
m_colorIndicator = new ColorIndicator(this);
|
||||
m_colorIndicator->setColor(m_color);
|
||||
m_button = new QToolButton(this);
|
||||
m_button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||
m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_button->setText("...");
|
||||
m_button->installEventFilter(this);
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_colorIndicator);
|
||||
layout->addWidget(m_button);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(1,1,1,1);
|
||||
layout->setContentsMargins(1, 1, 1, 1);
|
||||
setFocusProxy(m_button);
|
||||
setAutoFillBackground(true);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotClicked()));
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(slotClicked()));
|
||||
}
|
||||
|
||||
void ColorEditor::setColor(const QColor &value)
|
||||
void ColorEditor::setColor(const QColor& value)
|
||||
{
|
||||
m_color=value;
|
||||
m_color = value;
|
||||
m_colorIndicator->setColor(m_color);
|
||||
}
|
||||
|
||||
bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
|
||||
bool ColorEditor::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj == m_button){
|
||||
if (event->type() == QEvent::FocusOut && !m_buttonPressed){
|
||||
if (obj == m_button) {
|
||||
if (event->type() == QEvent::FocusOut && !m_buttonPressed) {
|
||||
QFocusEvent* focusEvent = dynamic_cast<QFocusEvent*>(event);
|
||||
if (focusEvent && focusEvent->reason()!=Qt::MouseFocusReason){
|
||||
if (focusEvent && focusEvent->reason() != Qt::MouseFocusReason) {
|
||||
setFocusToParent();
|
||||
emit(editingFinished());
|
||||
}
|
||||
@@ -81,7 +81,8 @@ bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ColorEditor::setFocusToParent(){
|
||||
void ColorEditor::setFocusToParent()
|
||||
{
|
||||
if (parentWidget())
|
||||
parentWidget()->setFocus();
|
||||
}
|
||||
@@ -91,7 +92,8 @@ void ColorEditor::slotClicked()
|
||||
m_buttonPressed = true;
|
||||
QColorDialog* dialog = new QColorDialog(this);
|
||||
dialog->setCurrentColor(m_color);
|
||||
if (dialog->exec()) m_color=dialog->currentColor();
|
||||
if (dialog->exec())
|
||||
m_color = dialog->currentColor();
|
||||
delete dialog;
|
||||
setFocusToParent();
|
||||
emit(editingFinished());
|
||||
@@ -107,36 +109,27 @@ void ColorIndicator::paintEvent(QPaintEvent* event)
|
||||
QColor penColor = isColorDark(m_color) ? Qt::transparent : Qt::darkGray;
|
||||
|
||||
painter.setPen(penColor);
|
||||
int border = (event->rect().height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
int border = (event->rect().height() - style->pixelMetric(QStyle::PM_IndicatorWidth)) / 2;
|
||||
|
||||
QRect rect(event->rect().x()+border, event->rect().y()+border,
|
||||
QRect rect(event->rect().x() + border, event->rect().y() + border,
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth));// = option.rect.adjusted(4,4,-4,-6);
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth)); // = option.rect.adjusted(4,4,-4,-6);
|
||||
|
||||
painter.drawRect(rect);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
ColorIndicator::ColorIndicator(QWidget *parent)
|
||||
:QWidget(parent), m_color(Qt::white){
|
||||
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;
|
||||
}
|
||||
QColor ColorIndicator::color() const { return m_color; }
|
||||
|
||||
void ColorIndicator::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
void ColorIndicator::setColor(const QColor& color) { m_color = color; }
|
||||
|
||||
QSize ColorIndicator::sizeHint() const
|
||||
{
|
||||
return QSize(20,20);
|
||||
}
|
||||
QSize ColorIndicator::sizeHint() const { return QSize(20, 20); }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,45 +30,49 @@
|
||||
#ifndef LRCOLOREDITOR_H
|
||||
#define LRCOLOREDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ColorIndicator : public QWidget{
|
||||
class ColorIndicator: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorIndicator(QWidget* parent = 0);
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
void setColor(const QColor& color);
|
||||
QSize sizeHint() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
class ColorEditor : public QWidget
|
||||
{
|
||||
class ColorEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ColorEditor(QWidget *parent = 0);
|
||||
QColor color(){return m_color;}
|
||||
explicit ColorEditor(QWidget* parent = 0);
|
||||
QColor color() { return m_color; }
|
||||
void setColor(const QColor& value);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private:
|
||||
void setFocusToParent();
|
||||
signals:
|
||||
void editingFinished();
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotClicked();
|
||||
void slotClicked();
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
QToolButton* m_button;
|
||||
ColorIndicator* m_colorIndicator;
|
||||
bool m_buttonPressed;
|
||||
QColor m_color;
|
||||
QToolButton* m_button;
|
||||
ColorIndicator* m_colorIndicator;
|
||||
bool m_buttonPressed;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -27,19 +27,20 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include "lrcomboboxeditor.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include "lrcomboboxeditor.h"
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
|
||||
ComboBoxEditor::ComboBoxEditor(QWidget* parent, bool clearable):
|
||||
QWidget(parent),
|
||||
m_comboBox(new InternalComboBox(this)),
|
||||
m_buttonClear(0),
|
||||
@@ -51,37 +52,41 @@ ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
|
||||
m_buttonClear = new QToolButton(this);
|
||||
m_buttonClear->setIcon(QIcon(":/items/clear.png"));
|
||||
m_buttonClear->installEventFilter(this);
|
||||
m_buttonClear->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
|
||||
m_buttonClear->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
m_buttonClear->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
connect(m_buttonClear,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
|
||||
connect(m_buttonClear, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
connect(m_comboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
connect(m_comboBox, SIGNAL(currentTextChanged(QString)), this,
|
||||
SLOT(slotCurrentIndexChanged(QString)));
|
||||
#else
|
||||
connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
|
||||
connect(m_comboBox, SIGNAL(currentIndexChanged(QString)), this,
|
||||
SLOT(slotCurrentIndexChanged(QString)));
|
||||
#endif
|
||||
|
||||
m_comboBox->installEventFilter(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_comboBox);
|
||||
if (clearable)
|
||||
layout->addWidget(m_buttonClear);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(2);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
void ComboBoxEditor::addItems(const QStringList &values){
|
||||
void ComboBoxEditor::addItems(const QStringList& values)
|
||||
{
|
||||
m_settingValues = true;
|
||||
m_comboBox->addItems(values);
|
||||
m_settingValues = false;
|
||||
}
|
||||
|
||||
void ComboBoxEditor::setTextValue(const QString &value){
|
||||
void ComboBoxEditor::setTextValue(const QString& value)
|
||||
{
|
||||
m_settingValues = true;
|
||||
if (m_comboBox->findText(value)>0){
|
||||
if (m_comboBox->findText(value) > 0) {
|
||||
m_comboBox->setCurrentIndex(m_comboBox->findText(value));
|
||||
} else {
|
||||
m_comboBox->setEditText(value);
|
||||
@@ -89,20 +94,16 @@ void ComboBoxEditor::setTextValue(const QString &value){
|
||||
m_settingValues = false;
|
||||
}
|
||||
|
||||
void ComboBoxEditor::slotClearButtonClicked(){
|
||||
m_comboBox->setCurrentIndex(-1);
|
||||
}
|
||||
void ComboBoxEditor::slotClearButtonClicked() { m_comboBox->setCurrentIndex(-1); }
|
||||
|
||||
void ComboBoxEditor::slotCurrentIndexChanged(const QString& value)
|
||||
{
|
||||
if (!m_settingValues){
|
||||
if (!m_settingValues) {
|
||||
emit currentIndexChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
QString ComboBoxEditor::text(){
|
||||
return m_comboBox->currentText();
|
||||
}
|
||||
QString ComboBoxEditor::text() { return m_comboBox->currentText(); }
|
||||
|
||||
void ComboBoxEditor::setEditable(bool value)
|
||||
{
|
||||
@@ -111,10 +112,11 @@ void ComboBoxEditor::setEditable(bool value)
|
||||
}
|
||||
}
|
||||
|
||||
bool ComboBoxEditor::eventFilter(QObject *target, QEvent *event){
|
||||
if (target == m_buttonClear){
|
||||
if (event->type()==QEvent::FocusOut){
|
||||
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
|
||||
bool ComboBoxEditor::eventFilter(QObject* target, QEvent* event)
|
||||
{
|
||||
if (target == m_buttonClear) {
|
||||
if (event->type() == QEvent::FocusOut) {
|
||||
if (static_cast<QFocusEvent*>(event)->reason() != Qt::MouseFocusReason) {
|
||||
m_comboBox->setFocus();
|
||||
}
|
||||
}
|
||||
@@ -122,28 +124,27 @@ bool ComboBoxEditor::eventFilter(QObject *target, QEvent *event){
|
||||
enterKeys.insert(Qt::Key_Enter);
|
||||
enterKeys.insert(Qt::Key_Return);
|
||||
|
||||
if (event->type()==QEvent::KeyPress){
|
||||
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())){
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
if (enterKeys.contains(static_cast<QKeyEvent*>(event)->key())) {
|
||||
m_buttonClear->click();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target == m_comboBox){
|
||||
if (event->type() == QEvent::FocusOut){
|
||||
if (target == m_comboBox) {
|
||||
if (event->type() == QEvent::FocusOut) {
|
||||
if (!m_comboBox->isPopup() || (m_buttonClear && m_buttonClear->hasFocus()))
|
||||
emit editingFinished();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
|
||||
void ComboBoxEditor::resizeEvent(QResizeEvent *e)
|
||||
void ComboBoxEditor::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
if (m_buttonClear)
|
||||
m_buttonClear->setMinimumHeight(e->size().height()-4);
|
||||
m_buttonClear->setMinimumHeight(e->size().height() - 4);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,32 +30,39 @@
|
||||
#ifndef LRCOMBOBOXEDITOR_H
|
||||
#define LRCOMBOBOXEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <QWidget>
|
||||
//#include <QPushButton>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class InternalComboBox :public QComboBox{
|
||||
class InternalComboBox: public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InternalComboBox(QWidget* parent=0):QComboBox(parent),m_popup(false){}
|
||||
void showPopup(){m_popup = true;QComboBox::showPopup();}
|
||||
void hidePopup(){QComboBox::hidePopup(); m_popup = false;}
|
||||
bool isPopup(){return m_popup;}
|
||||
InternalComboBox(QWidget* parent = 0): QComboBox(parent), m_popup(false) { }
|
||||
void showPopup()
|
||||
{
|
||||
m_popup = true;
|
||||
QComboBox::showPopup();
|
||||
}
|
||||
void hidePopup()
|
||||
{
|
||||
QComboBox::hidePopup();
|
||||
m_popup = false;
|
||||
}
|
||||
bool isPopup() { return m_popup; }
|
||||
|
||||
private:
|
||||
bool m_popup;
|
||||
|
||||
};
|
||||
|
||||
class ComboBoxEditor : public QWidget
|
||||
{
|
||||
class ComboBoxEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
//explicit ComboBoxEditor(QWidget *parent = 0);
|
||||
ComboBoxEditor(QWidget *parent=0, bool clearable=false);
|
||||
// explicit ComboBoxEditor(QWidget *parent = 0);
|
||||
ComboBoxEditor(QWidget* parent = 0, bool clearable = false);
|
||||
void addItems(const QStringList& values);
|
||||
void setTextValue(const QString& value);
|
||||
QString text();
|
||||
@@ -63,13 +70,15 @@ public:
|
||||
signals:
|
||||
void editingFinished();
|
||||
void currentIndexChanged(const QString&);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void resizeEvent(QResizeEvent* e);
|
||||
private slots:
|
||||
void slotClearButtonClicked();
|
||||
void slotCurrentIndexChanged(const QString& value);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *target, QEvent *event);
|
||||
bool eventFilter(QObject* target, QEvent* event);
|
||||
InternalComboBox* m_comboBox;
|
||||
QToolButton* m_buttonClear;
|
||||
bool m_settingValues;
|
||||
|
||||
@@ -28,58 +28,57 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrfonteditor.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFontDialog>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFontDialog>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
FontEditor::FontEditor(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
FontEditor::FontEditor(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
//m_button = new QPushButton(this);
|
||||
// m_button = new QPushButton(this);
|
||||
m_button = new QToolButton(this);
|
||||
m_button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
||||
m_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_button);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(1,1,1,1);
|
||||
layout->setContentsMargins(1, 1, 1, 1);
|
||||
setFocusProxy(m_button);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonCliked()));
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(slotButtonCliked()));
|
||||
}
|
||||
|
||||
FontEditor::~FontEditor()
|
||||
{}
|
||||
FontEditor::~FontEditor() { }
|
||||
|
||||
void FontEditor::setFontValue(const QFont &font)
|
||||
void FontEditor::setFontValue(const QFont& font)
|
||||
{
|
||||
m_font=font;
|
||||
m_font = font;
|
||||
m_button->setText(toString(font));
|
||||
}
|
||||
|
||||
QFont FontEditor::fontValue()
|
||||
{
|
||||
return m_font;
|
||||
}
|
||||
QFont FontEditor::fontValue() { return m_font; }
|
||||
|
||||
void FontEditor::slotButtonCliked()
|
||||
{
|
||||
QFontDialog* dialog = new QFontDialog(this);
|
||||
dialog->setCurrentFont(m_font);
|
||||
if (dialog->exec()) m_font=dialog->currentFont();
|
||||
if (dialog->exec())
|
||||
m_font = dialog->currentFont();
|
||||
delete dialog;
|
||||
emit(editingFinished());
|
||||
}
|
||||
|
||||
QString FontEditor::toString(const QFont &value) const
|
||||
QString FontEditor::toString(const QFont& value) const
|
||||
{
|
||||
QString attribs="[";
|
||||
if (value.bold()) (attribs=="[") ? attribs+="b":attribs+=",b";
|
||||
if (value.italic()) (attribs=="[") ? attribs+="i":attribs+=",i";
|
||||
attribs+="]";
|
||||
return value.family()+" "+QString::number(value.pointSize())+" "+attribs;
|
||||
QString attribs = "[";
|
||||
if (value.bold())
|
||||
(attribs == "[") ? attribs += "b" : attribs += ",b";
|
||||
if (value.italic())
|
||||
(attribs == "[") ? attribs += "i" : attribs += ",i";
|
||||
attribs += "]";
|
||||
return value.family() + " " + QString::number(value.pointSize()) + " " + attribs;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,28 +30,29 @@
|
||||
#ifndef LRFONTEDITOR_H
|
||||
#define LRFONTEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class FontEditor : public QWidget
|
||||
{
|
||||
class FontEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditor(QWidget *parent = 0);
|
||||
explicit FontEditor(QWidget* parent = 0);
|
||||
~FontEditor();
|
||||
void setFontValue(const QFont &font);
|
||||
void setFontValue(const QFont& font);
|
||||
QFont fontValue();
|
||||
signals:
|
||||
void editingFinished();
|
||||
public slots:
|
||||
void slotButtonCliked();
|
||||
|
||||
private:
|
||||
QString toString(const QFont& value) const;
|
||||
|
||||
private:
|
||||
//QPushButton* m_button;
|
||||
// QPushButton* m_button;
|
||||
QToolButton* m_button;
|
||||
QFont m_font;
|
||||
};
|
||||
|
||||
@@ -27,14 +27,14 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
#include "lrimageeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
ImageEditor::ImageEditor(QWidget* parent)
|
||||
:QWidget(parent)
|
||||
namespace LimeReport {
|
||||
|
||||
ImageEditor::ImageEditor(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
m_button.setIcon(QIcon(":items/ImageItem"));
|
||||
m_clearButton.setIcon(QIcon(":items/clear.png"));
|
||||
@@ -42,18 +42,15 @@ ImageEditor::ImageEditor(QWidget* parent)
|
||||
layout->addWidget(&m_button);
|
||||
layout->addWidget(&m_clearButton);
|
||||
layout->setSpacing(1);
|
||||
layout->setContentsMargins(1,0,1,1);
|
||||
layout->setContentsMargins(1, 0, 1, 1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(&m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
|
||||
connect(&m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
connect(&m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
|
||||
}
|
||||
|
||||
QImage ImageEditor::image()
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
QImage ImageEditor::image() { return m_image; }
|
||||
|
||||
void ImageEditor::slotButtonClicked()
|
||||
{
|
||||
@@ -67,4 +64,4 @@ void ImageEditor::slotClearButtonClicked()
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -29,24 +29,24 @@
|
||||
****************************************************************************/
|
||||
#ifndef LRIMAGEEDITOR_H
|
||||
#define LRIMAGEEDITOR_H
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ImageEditor : public QWidget
|
||||
{
|
||||
class ImageEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageEditor(QWidget *parent=0);
|
||||
ImageEditor(QWidget* parent = 0);
|
||||
QImage image();
|
||||
void setImage(const QImage& image){m_image=image;}
|
||||
void setImage(const QImage& image) { m_image = image; }
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
void slotClearButtonClicked();
|
||||
|
||||
private:
|
||||
QPushButton m_button;
|
||||
QPushButton m_clearButton;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "lrsvgeditor.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "lrimageeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QFileDialog>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
SvgEditor::SvgEditor(QWidget* parent)
|
||||
:QWidget(parent)
|
||||
namespace LimeReport {
|
||||
|
||||
SvgEditor::SvgEditor(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
m_button.setIcon(QIcon(":items/ImageItem"));
|
||||
m_clearButton.setIcon(QIcon(":items/clear.png"));
|
||||
@@ -14,25 +15,23 @@ SvgEditor::SvgEditor(QWidget* parent)
|
||||
layout->addWidget(&m_button);
|
||||
layout->addWidget(&m_clearButton);
|
||||
layout->setSpacing(1);
|
||||
layout->setContentsMargins(1,0,1,1);
|
||||
layout->setContentsMargins(1, 0, 1, 1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(&m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
|
||||
connect(&m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
connect(&m_clearButton, SIGNAL(clicked()), this, SLOT(slotClearButtonClicked()));
|
||||
}
|
||||
|
||||
QByteArray SvgEditor::image()
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
QByteArray SvgEditor::image() { return m_image; }
|
||||
|
||||
void SvgEditor::slotButtonClicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)");
|
||||
if (!fileName.isEmpty()){
|
||||
QString fileName
|
||||
= QFileDialog::getOpenFileName(this, tr("Select image file"), "", "SVG (*.svg)");
|
||||
if (!fileName.isEmpty()) {
|
||||
QFile file(fileName);
|
||||
if (file.open(QIODevice::ReadOnly)){
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
m_image = file.readAll();
|
||||
}
|
||||
}
|
||||
@@ -45,4 +44,4 @@ void SvgEditor::slotClearButtonClicked()
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
#ifndef SVGEDITOR_H
|
||||
#define SVGEDITOR_H
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class SvgEditor : public QWidget
|
||||
{
|
||||
class SvgEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SvgEditor(QWidget *parent=0);
|
||||
SvgEditor(QWidget* parent = 0);
|
||||
QByteArray image();
|
||||
void setImage(const QByteArray& image){m_image=image;}
|
||||
void setImage(const QByteArray& image) { m_image = image; }
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
void slotClearButtonClicked();
|
||||
|
||||
private:
|
||||
QPushButton m_button;
|
||||
QPushButton m_clearButton;
|
||||
QByteArray m_image;
|
||||
QByteArray m_image;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
****************************************************************************/
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
#include "ui_ltextitempropertyeditor.h"
|
||||
|
||||
#include <QCompleter>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
|
||||
TextItemPropertyEditor::TextItemPropertyEditor(QWidget* parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::TextItemPropertyEditor)
|
||||
{
|
||||
@@ -41,19 +42,10 @@ TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
|
||||
ui->textEdit->setAcceptRichText(false);
|
||||
}
|
||||
|
||||
TextItemPropertyEditor::~TextItemPropertyEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
TextItemPropertyEditor::~TextItemPropertyEditor() { delete ui; }
|
||||
|
||||
void TextItemPropertyEditor::setText(const QString &value)
|
||||
{
|
||||
ui->textEdit->setPlainText(value);
|
||||
}
|
||||
void TextItemPropertyEditor::setText(const QString& value) { ui->textEdit->setPlainText(value); }
|
||||
|
||||
QString TextItemPropertyEditor::text()
|
||||
{
|
||||
return ui->textEdit->toPlainText();
|
||||
}
|
||||
QString TextItemPropertyEditor::text() { return ui->textEdit->toPlainText(); }
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -33,28 +33,28 @@
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
namespace Ui {
|
||||
class TextItemPropertyEditor;
|
||||
}
|
||||
|
||||
class TextItemPropertyEditor : public QDialog
|
||||
{
|
||||
class TextItemPropertyEditor: public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextItemPropertyEditor(QWidget *parent = 0);
|
||||
explicit TextItemPropertyEditor(QWidget* parent = 0);
|
||||
~TextItemPropertyEditor();
|
||||
void setText(const QString &value);
|
||||
void setText(const QString& value);
|
||||
QString text();
|
||||
public slots:
|
||||
void pbSaveCliked(){ emit editingFinished();}
|
||||
void pbSaveCliked() { emit editingFinished(); }
|
||||
signals:
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
Ui::TextItemPropertyEditor *ui;
|
||||
Ui::TextItemPropertyEditor* ui;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // ATEXTITEMPROPERTYEDITOR_H
|
||||
|
||||
@@ -28,24 +28,21 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbasedesignobjectmodel.h"
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
BaseDesignPropertyModel::BaseDesignPropertyModel(QObject *parent)
|
||||
: QObjectPropertyModel(parent)
|
||||
{}
|
||||
BaseDesignPropertyModel::BaseDesignPropertyModel(QObject* parent): QObjectPropertyModel(parent) { }
|
||||
|
||||
void BaseDesignPropertyModel::setObject(QObject *object)
|
||||
void BaseDesignPropertyModel::setObject(QObject* object)
|
||||
{
|
||||
BaseDesignIntf* reportItem = dynamic_cast<BaseDesignIntf*>(object);
|
||||
if (reportItem){
|
||||
connect(reportItem,SIGNAL(propertyChanged(QString,QVariant,QVariant)),this,SLOT(slotPropertyChanged(QString,QVariant,QVariant)));
|
||||
|
||||
if (reportItem) {
|
||||
connect(reportItem, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
|
||||
}
|
||||
QObjectPropertyModel::setObject(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
#define LRBASEDESIGNOBJECTSMODEL_H
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
#include <QObject>
|
||||
namespace LimeReport{
|
||||
class BaseDesignPropertyModel : public QObjectPropertyModel
|
||||
{
|
||||
namespace LimeReport {
|
||||
class BaseDesignPropertyModel: public QObjectPropertyModel {
|
||||
public:
|
||||
explicit BaseDesignPropertyModel(QObject* parent=0);
|
||||
virtual void setObject(QObject *object);
|
||||
explicit BaseDesignPropertyModel(QObject* parent = 0);
|
||||
virtual void setObject(QObject* object);
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRBASEDESIGNOBJECTSMODEL_H
|
||||
|
||||
@@ -27,86 +27,88 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QMenu>
|
||||
#include "lrobjectinspectorwidget.h"
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrobjectinspectorwidget.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
ObjectInspectorTreeView::ObjectInspectorTreeView(QWidget *parent)
|
||||
:QTreeView(parent), m_propertyDelegate(0)
|
||||
namespace LimeReport {
|
||||
|
||||
ObjectInspectorTreeView::ObjectInspectorTreeView(QWidget* parent):
|
||||
QTreeView(parent),
|
||||
m_propertyDelegate(0)
|
||||
{
|
||||
setRootIsDecorated(false);
|
||||
initColorMap();
|
||||
setEditTriggers(
|
||||
QAbstractItemView::DoubleClicked |
|
||||
QAbstractItemView::SelectedClicked |
|
||||
QAbstractItemView::EditKeyPressed
|
||||
);
|
||||
setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked
|
||||
| QAbstractItemView::EditKeyPressed);
|
||||
m_propertyDelegate = new PropertyDelegate(this);
|
||||
setItemDelegate(m_propertyDelegate);
|
||||
QPalette p = palette();
|
||||
p.setColor(QPalette::AlternateBase,QColor(229,255,214));
|
||||
p.setColor(QPalette::AlternateBase, QColor(229, 255, 214));
|
||||
setPalette(p);
|
||||
}
|
||||
|
||||
ObjectInspectorTreeView::~ObjectInspectorTreeView(){}
|
||||
ObjectInspectorTreeView::~ObjectInspectorTreeView() { }
|
||||
|
||||
void ObjectInspectorTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const
|
||||
void ObjectInspectorTreeView::drawRow(QPainter* painter, const QStyleOptionViewItem& options,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
ObjectPropItem *node = nodeFromIndex(index);
|
||||
ObjectPropItem* node = nodeFromIndex(index);
|
||||
StyleOptionViewItem so = options;
|
||||
bool alternate = so.features & StyleOptionViewItem::Alternate;
|
||||
if (node){
|
||||
if ((!node->isHaveValue())){
|
||||
if (node) {
|
||||
if ((!node->isHaveValue())) {
|
||||
const QColor c = options.palette.color(QPalette::Dark);
|
||||
painter->fillRect(options.rect,c);
|
||||
so.palette.setColor(QPalette::AlternateBase,c);
|
||||
painter->fillRect(options.rect, c);
|
||||
so.palette.setColor(QPalette::AlternateBase, c);
|
||||
} else {
|
||||
if ( index.isValid()&&(nodeFromIndex(index)->colorIndex()!=-1) ){
|
||||
QColor fillColor(getColor(nodeFromIndex(index)->colorIndex()%m_colors.count()));
|
||||
so.palette.setColor(QPalette::AlternateBase,fillColor.lighter(115));
|
||||
if (!alternate){
|
||||
painter->fillRect(options.rect,fillColor);
|
||||
if (index.isValid() && (nodeFromIndex(index)->colorIndex() != -1)) {
|
||||
QColor fillColor(getColor(nodeFromIndex(index)->colorIndex() % m_colors.count()));
|
||||
so.palette.setColor(QPalette::AlternateBase, fillColor.lighter(115));
|
||||
if (!alternate) {
|
||||
painter->fillRect(options.rect, fillColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QTreeView::drawRow(painter,so,index);
|
||||
QTreeView::drawRow(painter, so, index);
|
||||
painter->save();
|
||||
QColor gridLineColor = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor,&so));
|
||||
QColor gridLineColor
|
||||
= static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &so));
|
||||
painter->setPen(gridLineColor);
|
||||
painter->drawLine(so.rect.x(),so.rect.bottom(),so.rect.right(),so.rect.bottom());
|
||||
painter->drawLine(so.rect.x(), so.rect.bottom(), so.rect.right(), so.rect.bottom());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void ObjectInspectorTreeView::mousePressEvent(QMouseEvent *event)
|
||||
void ObjectInspectorTreeView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
|
||||
if ((event->button()==Qt::LeftButton)){
|
||||
QModelIndex index=indexAt(event->pos());
|
||||
if (index.isValid()){
|
||||
if ((event->button() == Qt::LeftButton)) {
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
if (index.isValid()) {
|
||||
if (event->pos().x() < indentation()) {
|
||||
if (!nodeFromIndex(index)->isHaveValue())
|
||||
setExpanded(index,!isExpanded(index));
|
||||
setExpanded(index, !isExpanded(index));
|
||||
} else {
|
||||
if ((index.column()==1)&&(!nodeFromIndex(index)->isHaveChildren())) {
|
||||
if ((index.column() == 1) && (!nodeFromIndex(index)->isHaveChildren())) {
|
||||
setCurrentIndex(index);
|
||||
|
||||
Qt::ItemFlags flags = index.model()->flags(index);
|
||||
if ( !(((flags & Qt::ItemIsEditable) == 0) || ((flags & Qt::ItemIsEnabled) == 0)) )
|
||||
if (!(((flags & Qt::ItemIsEditable) == 0)
|
||||
|| ((flags & Qt::ItemIsEnabled) == 0)))
|
||||
edit(index);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,56 +120,56 @@ void ObjectInspectorTreeView::mousePressEvent(QMouseEvent *event)
|
||||
void ObjectInspectorTreeView::initColorMap()
|
||||
{
|
||||
m_colors.reserve(6);
|
||||
m_colors.push_back(QColor(255,230,191));
|
||||
m_colors.push_back(QColor(255,255,191));
|
||||
m_colors.push_back(QColor(191,255,191));
|
||||
m_colors.push_back(QColor(199,255,255));
|
||||
m_colors.push_back(QColor(234,191,255));
|
||||
m_colors.push_back(QColor(255,191,239));
|
||||
m_colors.push_back(QColor(255, 230, 191));
|
||||
m_colors.push_back(QColor(255, 255, 191));
|
||||
m_colors.push_back(QColor(191, 255, 191));
|
||||
m_colors.push_back(QColor(199, 255, 255));
|
||||
m_colors.push_back(QColor(234, 191, 255));
|
||||
m_colors.push_back(QColor(255, 191, 239));
|
||||
}
|
||||
|
||||
QColor ObjectInspectorTreeView::getColor(const int index) const
|
||||
{
|
||||
return m_colors[index];
|
||||
}
|
||||
QColor ObjectInspectorTreeView::getColor(const int index) const { return m_colors[index]; }
|
||||
|
||||
void ObjectInspectorTreeView::reset()
|
||||
{
|
||||
QTreeView::reset();
|
||||
for (int i=0;i<model()->rowCount();i++){
|
||||
if (!nodeFromIndex(model()->index(i,0))->isHaveValue()){
|
||||
setFirstColumnSpanned(i,model()->index(i,0).parent(),true);
|
||||
for (int i = 0; i < model()->rowCount(); i++) {
|
||||
if (!nodeFromIndex(model()->index(i, 0))->isHaveValue()) {
|
||||
setFirstColumnSpanned(i, model()->index(i, 0).parent(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObjectPropItem * ObjectInspectorTreeView::nodeFromIndex(QModelIndex index) const
|
||||
ObjectPropItem* ObjectInspectorTreeView::nodeFromIndex(QModelIndex index) const
|
||||
{
|
||||
return qvariant_cast<LimeReport::ObjectPropItem*>(index.data(Qt::UserRole));
|
||||
}
|
||||
|
||||
void ObjectInspectorTreeView::keyPressEvent(QKeyEvent *event)
|
||||
void ObjectInspectorTreeView::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key()==Qt::Key_Return){
|
||||
if(!m_propertyDelegate->isEditing()){
|
||||
QModelIndex index = currentIndex().model()->index(currentIndex().row(),
|
||||
1,currentIndex().parent());
|
||||
if (event->key() == Qt::Key_Return) {
|
||||
if (!m_propertyDelegate->isEditing()) {
|
||||
QModelIndex index
|
||||
= currentIndex().model()->index(currentIndex().row(), 1, currentIndex().parent());
|
||||
edit(index);
|
||||
event->accept();
|
||||
}
|
||||
} else QTreeView::keyPressEvent(event);
|
||||
} else
|
||||
QTreeView::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void ObjectInspectorTreeView::commitActiveEditorData(){
|
||||
if (state()==QAbstractItemView::EditingState){
|
||||
void ObjectInspectorTreeView::commitActiveEditorData()
|
||||
{
|
||||
if (state() == QAbstractItemView::EditingState) {
|
||||
commitData(indexWidget(currentIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
if (sourceParent.isValid()) return true;
|
||||
if (sourceParent.isValid())
|
||||
return true;
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
return sourceModel()->data(index).toString().contains(filterRegExp());
|
||||
#else
|
||||
@@ -175,8 +177,7 @@ bool PropertyFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sou
|
||||
#endif
|
||||
}
|
||||
|
||||
ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
:QWidget(parent), m_filterModel(0)
|
||||
ObjectInspectorWidget::ObjectInspectorWidget(QWidget* parent): QWidget(parent), m_filterModel(0)
|
||||
{
|
||||
m_objectInspectorView = new ObjectInspectorTreeView(this);
|
||||
m_propertyModel = new BaseDesignPropertyModel(this);
|
||||
@@ -185,17 +186,19 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
m_filterModel->setFilterRegExp(QRegExp("", Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
#else
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression("", QRegularExpression::CaseInsensitiveOption));
|
||||
m_filterModel->setFilterRegularExpression(
|
||||
QRegularExpression("", QRegularExpression::CaseInsensitiveOption));
|
||||
#endif
|
||||
m_objectInspectorView->setModel(m_filterModel);
|
||||
QVBoxLayout* l = new QVBoxLayout();
|
||||
QLineEdit* le = new QLineEdit(this);
|
||||
QToolButton * pbClear = new QToolButton(this);
|
||||
QToolButton* pbClear = new QToolButton(this);
|
||||
pbClear->setToolTip(tr("Clear"));
|
||||
pbClear->setIcon(QIcon(":/items/clear.png"));
|
||||
connect(pbClear, SIGNAL(clicked()), le, SLOT(clear()));
|
||||
le->setPlaceholderText(tr("Filter"));
|
||||
connect(le, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterTextChanged(const QString&)));
|
||||
connect(le, SIGNAL(textChanged(const QString&)), this,
|
||||
SLOT(slotFilterTextChanged(const QString&)));
|
||||
|
||||
QToolButton* settingButton = new QToolButton(this);
|
||||
settingButton->setIcon(QIcon(":/items/images/settings.png"));
|
||||
@@ -204,8 +207,8 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
m_translateProperties->setCheckable(true);
|
||||
m_translateProperties->setChecked(translateProperties());
|
||||
|
||||
connect(m_translateProperties, SIGNAL(toggled(bool)),
|
||||
this, SLOT(slotTranslatePropertiesChecked(bool)));
|
||||
connect(m_translateProperties, SIGNAL(toggled(bool)), this,
|
||||
SLOT(slotTranslatePropertiesChecked(bool)));
|
||||
|
||||
settingButton->setMenu(settingMenu);
|
||||
settingButton->setPopupMode(QToolButton::InstantPopup);
|
||||
@@ -223,11 +226,10 @@ ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
this->setLayout(l);
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::setModel(QAbstractItemModel *model)
|
||||
void ObjectInspectorWidget::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
|
||||
m_filterModel->setSourceModel(model);
|
||||
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::setAlternatingRowColors(bool value)
|
||||
@@ -260,15 +262,12 @@ void ObjectInspectorWidget::commitActiveEditorData()
|
||||
m_objectInspectorView->commitActiveEditorData();
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::setValidator(ValidatorIntf *validator)
|
||||
void ObjectInspectorWidget::setValidator(ValidatorIntf* validator)
|
||||
{
|
||||
m_propertyModel->setValidator(validator);
|
||||
}
|
||||
|
||||
bool ObjectInspectorWidget::subclassesAsLevel()
|
||||
{
|
||||
return m_propertyModel->subclassesAsLevel();
|
||||
}
|
||||
bool ObjectInspectorWidget::subclassesAsLevel() { return m_propertyModel->subclassesAsLevel(); }
|
||||
|
||||
void ObjectInspectorWidget::setSubclassesAsLevel(bool value)
|
||||
{
|
||||
@@ -287,37 +286,30 @@ void ObjectInspectorWidget::setTranslateProperties(bool value)
|
||||
update();
|
||||
}
|
||||
|
||||
const QObject *ObjectInspectorWidget::object(){
|
||||
return m_propertyModel->currentObject();
|
||||
}
|
||||
const QObject* ObjectInspectorWidget::object() { return m_propertyModel->currentObject(); }
|
||||
|
||||
void ObjectInspectorWidget::setObject(QObject *object)
|
||||
{
|
||||
m_propertyModel->setObject(object);
|
||||
}
|
||||
void ObjectInspectorWidget::setObject(QObject* object) { m_propertyModel->setObject(object); }
|
||||
|
||||
void ObjectInspectorWidget::setMultiObjects(QList<QObject *> *list)
|
||||
void ObjectInspectorWidget::setMultiObjects(QList<QObject*>* list)
|
||||
{
|
||||
m_propertyModel->setMultiObjects(list);
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::clearObjectsList()
|
||||
{
|
||||
m_propertyModel->clearObjectsList();
|
||||
}
|
||||
void ObjectInspectorWidget::clearObjectsList() { m_propertyModel->clearObjectsList(); }
|
||||
|
||||
void ObjectInspectorWidget::updateProperty(const QString &propertyName)
|
||||
void ObjectInspectorWidget::updateProperty(const QString& propertyName)
|
||||
{
|
||||
m_propertyModel->updateProperty(propertyName);
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::slotFilterTextChanged(const QString &filter)
|
||||
void ObjectInspectorWidget::slotFilterTextChanged(const QString& filter)
|
||||
{
|
||||
if (m_filterModel)
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1))
|
||||
m_filterModel->setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||
#else
|
||||
m_filterModel->setFilterRegularExpression(QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
|
||||
m_filterModel->setFilterRegularExpression(
|
||||
QRegularExpression(filter, QRegularExpression::CaseInsensitiveOption));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -326,4 +318,4 @@ void ObjectInspectorWidget::slotTranslatePropertiesChecked(bool value)
|
||||
setTranslateProperties(value);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,46 +30,49 @@
|
||||
#ifndef LROBJECTINSPECTORWIDGET_H
|
||||
#define LROBJECTINSPECTORWIDGET_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QMap>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include "lrbasedesignobjectmodel.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include "lrpropertydelegate.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QMap>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTreeView>
|
||||
|
||||
class ObjectInspectorTreeView : public QTreeView
|
||||
{
|
||||
namespace LimeReport {
|
||||
|
||||
class ObjectInspectorTreeView: public QTreeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObjectInspectorTreeView(QWidget * parent=0);
|
||||
ObjectInspectorTreeView(QWidget* parent = 0);
|
||||
~ObjectInspectorTreeView();
|
||||
QColor getColor(const int index) const;
|
||||
virtual void reset();
|
||||
virtual void commitActiveEditorData();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const;
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void drawRow(QPainter* painter, const QStyleOptionViewItem& options,
|
||||
const QModelIndex& index) const;
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
private:
|
||||
void initColorMap();
|
||||
LimeReport::ObjectPropItem* nodeFromIndex(QModelIndex index) const;
|
||||
|
||||
private:
|
||||
QVector<QColor> m_colors;
|
||||
PropertyDelegate *m_propertyDelegate;
|
||||
PropertyDelegate* m_propertyDelegate;
|
||||
};
|
||||
|
||||
class PropertyFilterModel: public QSortFilterProxyModel{
|
||||
class PropertyFilterModel: public QSortFilterProxyModel {
|
||||
public:
|
||||
PropertyFilterModel(QObject* parent = 0): QSortFilterProxyModel(parent){}
|
||||
PropertyFilterModel(QObject* parent = 0): QSortFilterProxyModel(parent) { }
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow,const QModelIndex &sourceParent) const;
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
|
||||
};
|
||||
|
||||
class ObjectInspectorWidget: public QWidget{
|
||||
class ObjectInspectorWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObjectInspectorWidget(QWidget* parent = 0);
|
||||
@@ -77,30 +80,30 @@ public:
|
||||
void setAlternatingRowColors(bool value);
|
||||
void setRootIsDecorated(bool value);
|
||||
void setColumnWidth(int column, int width);
|
||||
int columnWidth(int column);
|
||||
int columnWidth(int column);
|
||||
void expandToDepth(int depth);
|
||||
void commitActiveEditorData();
|
||||
void setValidator(ValidatorIntf *validator);
|
||||
void setValidator(ValidatorIntf* validator);
|
||||
bool subclassesAsLevel();
|
||||
void setSubclassesAsLevel(bool value);
|
||||
bool translateProperties();
|
||||
void setTranslateProperties(bool value);
|
||||
void setObject(QObject* setObject);
|
||||
const QObject* object();
|
||||
void setMultiObjects(QList<QObject *>* list);
|
||||
void setMultiObjects(QList<QObject*>* list);
|
||||
void clearObjectsList();
|
||||
void updateProperty(const QString &propertyName);
|
||||
void updateProperty(const QString& propertyName);
|
||||
private slots:
|
||||
void slotFilterTextChanged(const QString& filter);
|
||||
void slotTranslatePropertiesChecked(bool value);
|
||||
|
||||
private:
|
||||
ObjectInspectorTreeView* m_objectInspectorView;
|
||||
QSortFilterProxyModel* m_filterModel;
|
||||
BaseDesignPropertyModel* m_propertyModel;
|
||||
QAction* m_translateProperties;
|
||||
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LROBJECTINSPECTORWIDGET_H
|
||||
|
||||
@@ -28,10 +28,11 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include <QMetaProperty>
|
||||
#include <QPainter>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaProperty>
|
||||
#include <QPainter>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
@@ -178,48 +179,48 @@ void QObjectPropertyModel::translatePropertyName()
|
||||
tr("borderStyle");
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::clearObjectsList()
|
||||
void QObjectPropertyModel::clearObjectsList() { m_objects.clear(); }
|
||||
|
||||
QObjectPropertyModel::QObjectPropertyModel(QObject* parent /*=0*/):
|
||||
QAbstractItemModel(parent),
|
||||
m_rootNode(0),
|
||||
m_object(0),
|
||||
m_dataChanging(false),
|
||||
m_subclassesAsLevel(true),
|
||||
m_validator(0),
|
||||
m_translateProperties(true)
|
||||
{
|
||||
m_objects.clear();
|
||||
}
|
||||
|
||||
QObjectPropertyModel::QObjectPropertyModel(QObject *parent/*=0*/)
|
||||
:QAbstractItemModel(parent),m_rootNode(0), m_object(0), m_dataChanging(false),
|
||||
m_subclassesAsLevel(true), m_validator(0), m_translateProperties(true)
|
||||
{}
|
||||
|
||||
QObjectPropertyModel::~QObjectPropertyModel()
|
||||
{
|
||||
delete m_rootNode;
|
||||
}
|
||||
QObjectPropertyModel::~QObjectPropertyModel() { delete m_rootNode; }
|
||||
|
||||
void QObjectPropertyModel::initModel()
|
||||
{
|
||||
beginResetModel();
|
||||
delete m_rootNode;
|
||||
m_rootNode=0;
|
||||
m_rootNode = 0;
|
||||
if (m_object) {
|
||||
connect(m_object,SIGNAL(destroyed(QObject*)),this,SLOT(slotObjectDestroyed(QObject*)));
|
||||
m_rootNode=new ObjectPropItem(0,0,"root","root",QVariant(),0);
|
||||
connect(m_object, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
|
||||
m_rootNode = new ObjectPropItem(0, 0, "root", "root", QVariant(), 0);
|
||||
m_rootNode->setModel(this);
|
||||
foreach(QObject* item, m_objects)
|
||||
connect(item,SIGNAL(destroyed(QObject*)),this,SLOT(slotObjectDestroyed(QObject*)));
|
||||
foreach (QObject* item, m_objects)
|
||||
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
|
||||
addObjectProperties(m_object->metaObject(), m_object, &m_objects);
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setObject(QObject *object)
|
||||
void QObjectPropertyModel::setObject(QObject* object)
|
||||
{
|
||||
m_objects.clear();
|
||||
if (m_object!=object){
|
||||
if (m_object != object) {
|
||||
submit();
|
||||
m_object=object;
|
||||
m_object = object;
|
||||
initModel();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setMultiObjects(QList<QObject *>* list)
|
||||
void QObjectPropertyModel::setMultiObjects(QList<QObject*>* list)
|
||||
{
|
||||
m_objects.clear();
|
||||
submit();
|
||||
@@ -228,28 +229,29 @@ void QObjectPropertyModel::setMultiObjects(QList<QObject *>* list)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!list->contains(m_object)){
|
||||
m_object=list->at(0);
|
||||
if (!list->contains(m_object)) {
|
||||
m_object = list->at(0);
|
||||
list->removeAt(0);
|
||||
} else {
|
||||
list->removeOne(m_object);
|
||||
}
|
||||
|
||||
foreach(QObject* item, *list)
|
||||
foreach (QObject* item, *list)
|
||||
m_objects.append(item);
|
||||
//initModel();
|
||||
// initModel();
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotObjectDestroyed(QObject *obj)
|
||||
void QObjectPropertyModel::slotObjectDestroyed(QObject* obj)
|
||||
{
|
||||
m_objects.removeOne(obj);
|
||||
if (m_object == obj){
|
||||
m_object=0;
|
||||
initModel();
|
||||
if (m_object == obj) {
|
||||
m_object = 0;
|
||||
initModel();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotPropertyChanged(const QString &propertyName, const QVariant& oldValue, const QVariant& newValue)
|
||||
void QObjectPropertyModel::slotPropertyChanged(const QString& propertyName,
|
||||
const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue);
|
||||
Q_UNUSED(newValue);
|
||||
@@ -257,7 +259,8 @@ void QObjectPropertyModel::slotPropertyChanged(const QString &propertyName, cons
|
||||
updateProperty(propertyName);
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotPropertyObjectNameChanged(const QString &oldName, const QString &newName)
|
||||
void QObjectPropertyModel::slotPropertyObjectNameChanged(const QString& oldName,
|
||||
const QString& newName)
|
||||
{
|
||||
Q_UNUSED(oldName)
|
||||
Q_UNUSED(newName)
|
||||
@@ -265,45 +268,43 @@ void QObjectPropertyModel::slotPropertyObjectNameChanged(const QString &oldName,
|
||||
updateProperty("objectName");
|
||||
}
|
||||
|
||||
|
||||
int QObjectPropertyModel::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
int QObjectPropertyModel::columnCount(const QModelIndex& /*parent*/) const { return 2; }
|
||||
|
||||
QVariant QObjectPropertyModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(orientation==Qt::Horizontal&&role==Qt::DisplayRole){
|
||||
if (section==0) return tr("Property Name");
|
||||
else return tr("Property value");
|
||||
} else return QVariant();
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
if (section == 0)
|
||||
return tr("Property Name");
|
||||
else
|
||||
return tr("Property value");
|
||||
} else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
ObjectPropItem * QObjectPropertyModel::nodeFromIndex(const QModelIndex &index) const
|
||||
ObjectPropItem* QObjectPropertyModel::nodeFromIndex(const QModelIndex& index) const
|
||||
{
|
||||
if(index.isValid()){
|
||||
if (index.isValid()) {
|
||||
return static_cast<ObjectPropItem*>(index.internalPointer());
|
||||
} else return m_rootNode;
|
||||
} else
|
||||
return m_rootNode;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::updateProperty(const QString &propertyName)
|
||||
void QObjectPropertyModel::updateProperty(const QString& propertyName)
|
||||
{
|
||||
if (!m_dataChanging&&m_rootNode){
|
||||
if (!m_dataChanging && m_rootNode) {
|
||||
ObjectPropItem* propItem = m_rootNode->findPropertyItem(propertyName);
|
||||
if (propItem)
|
||||
propItem->updatePropertyValue();
|
||||
propItem->updatePropertyValue();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setSubclassesAsLevel(bool value)
|
||||
{
|
||||
m_subclassesAsLevel = value;
|
||||
}
|
||||
void QObjectPropertyModel::setSubclassesAsLevel(bool value) { m_subclassesAsLevel = value; }
|
||||
|
||||
int QObjectPropertyModel::rowCount(const QModelIndex &parent) const
|
||||
int QObjectPropertyModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if (!m_rootNode) return 0;
|
||||
ObjectPropItem *parentNode;
|
||||
if (!m_rootNode)
|
||||
return 0;
|
||||
ObjectPropItem* parentNode;
|
||||
if (parent.isValid())
|
||||
parentNode = nodeFromIndex(parent);
|
||||
else
|
||||
@@ -311,23 +312,26 @@ int QObjectPropertyModel::rowCount(const QModelIndex &parent) const
|
||||
return parentNode->childCount();
|
||||
}
|
||||
|
||||
QVariant QObjectPropertyModel::data(const QModelIndex &index, int role) const
|
||||
QVariant QObjectPropertyModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
ObjectPropItem *node = nodeFromIndex(index);
|
||||
ObjectPropItem* node = nodeFromIndex(index);
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (!node) return QVariant();
|
||||
if (!node)
|
||||
return QVariant();
|
||||
node->setTranslateProperty(isTranslateProperties());
|
||||
if (index.column()==0){
|
||||
if (index.column() == 0) {
|
||||
return node->displayName();
|
||||
} else {
|
||||
return node->displayValue();
|
||||
}
|
||||
case Qt::DecorationRole :
|
||||
if (!node) return QIcon();
|
||||
if (index.column()==1){
|
||||
case Qt::DecorationRole:
|
||||
if (!node)
|
||||
return QIcon();
|
||||
if (index.column() == 1) {
|
||||
return node->iconValue();
|
||||
} else return QIcon();
|
||||
} else
|
||||
return QIcon();
|
||||
case Qt::UserRole:
|
||||
return QVariant::fromValue(node);
|
||||
default:
|
||||
@@ -335,184 +339,179 @@ QVariant QObjectPropertyModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex QObjectPropertyModel::index(int row, int column, const QModelIndex &parent) const
|
||||
QModelIndex QObjectPropertyModel::index(int row, int column, const QModelIndex& parent) const
|
||||
{
|
||||
if(!m_rootNode)
|
||||
if (!m_rootNode)
|
||||
return QModelIndex();
|
||||
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
ObjectPropItem *parentNode;
|
||||
ObjectPropItem* parentNode;
|
||||
if (parent.isValid())
|
||||
parentNode = nodeFromIndex(parent);
|
||||
else
|
||||
parentNode = m_rootNode;
|
||||
|
||||
ObjectPropItem *childItem=parentNode->child(row);
|
||||
ObjectPropItem* childItem = parentNode->child(row);
|
||||
|
||||
if (childItem){
|
||||
QModelIndex modelIndex=createIndex(row,column,childItem);
|
||||
if (column==1){
|
||||
if (childItem->modelIndex()!=modelIndex){
|
||||
if (childItem) {
|
||||
QModelIndex modelIndex = createIndex(row, column, childItem);
|
||||
if (column == 1) {
|
||||
if (childItem->modelIndex() != modelIndex) {
|
||||
childItem->setModelIndex(modelIndex);
|
||||
}
|
||||
}
|
||||
return modelIndex;
|
||||
}
|
||||
else return QModelIndex();
|
||||
} else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex QObjectPropertyModel::parent(const QModelIndex &child) const
|
||||
{
|
||||
if (!child.isValid()) return QModelIndex();
|
||||
|
||||
ObjectPropItem *childNode = nodeFromIndex(child);
|
||||
if (!childNode) return QModelIndex();
|
||||
|
||||
ObjectPropItem *parentNode = childNode->parent();
|
||||
if ((parentNode == m_rootNode) || (!parentNode)) return QModelIndex();
|
||||
|
||||
return createIndex(parentNode->row(),0,parentNode);
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags QObjectPropertyModel::flags(const QModelIndex &index) const
|
||||
QModelIndex QObjectPropertyModel::parent(const QModelIndex& child) const
|
||||
{
|
||||
if ((index.column() == 1) && (!nodeFromIndex(index)->isValueReadonly())) return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
||||
else return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
if (!child.isValid())
|
||||
return QModelIndex();
|
||||
|
||||
ObjectPropItem* childNode = nodeFromIndex(child);
|
||||
if (!childNode)
|
||||
return QModelIndex();
|
||||
|
||||
ObjectPropItem* parentNode = childNode->parent();
|
||||
if ((parentNode == m_rootNode) || (!parentNode))
|
||||
return QModelIndex();
|
||||
|
||||
return createIndex(parentNode->row(), 0, parentNode);
|
||||
}
|
||||
|
||||
Qt::ItemFlags QObjectPropertyModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
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()));
|
||||
if (!creator){
|
||||
if (prop.isFlagType()){
|
||||
creator=ObjectPropFactory::instance().objectCreator(APropIdent("flags",""));
|
||||
if (creator){
|
||||
return creator;
|
||||
} else {
|
||||
qDebug()<<"flags prop editor not found";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (prop.isEnumType()){
|
||||
creator=ObjectPropFactory::instance().objectCreator(APropIdent("enum",""));
|
||||
if (creator){
|
||||
creator = ObjectPropFactory::instance().objectCreator(
|
||||
APropIdent(prop.name(), prop.enclosingMetaObject()->className()));
|
||||
if (!creator) {
|
||||
if (prop.isFlagType()) {
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent("flags", ""));
|
||||
if (creator) {
|
||||
return creator;
|
||||
} else {
|
||||
qDebug()<<"enum prop editor not found";
|
||||
qDebug() << "flags prop editor not found";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(),""));
|
||||
if (!creator) {qDebug()<<"Editor for propperty name = \""<<prop.name()<<"\" & property type =\""<<prop.typeName()<<"\" not found!";}
|
||||
if (prop.isEnumType()) {
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent("enum", ""));
|
||||
if (creator) {
|
||||
return creator;
|
||||
} else {
|
||||
qDebug() << "enum prop editor not found";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
creator = ObjectPropFactory::instance().objectCreator(APropIdent(prop.typeName(), ""));
|
||||
if (!creator) {
|
||||
qDebug() << "Editor for propperty name = \"" << prop.name() << "\" & property type =\""
|
||||
<< prop.typeName() << "\" not found!";
|
||||
}
|
||||
}
|
||||
return creator;
|
||||
}
|
||||
|
||||
ObjectPropItem * QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QObject *object, ObjectPropItem::ObjectsList *objects, ObjectPropItem *parent)
|
||||
ObjectPropItem* QObjectPropertyModel::createPropertyItem(QMetaProperty prop, QObject* object,
|
||||
ObjectPropItem::ObjectsList* objects,
|
||||
ObjectPropItem* parent)
|
||||
{
|
||||
ObjectPropItem* propertyItem=0;
|
||||
CreatePropItem creator=propertyItemCreator(prop);
|
||||
ObjectPropItem* propertyItem = 0;
|
||||
CreatePropItem creator = propertyItemCreator(prop);
|
||||
|
||||
if (creator) {
|
||||
propertyItem=creator(
|
||||
object,
|
||||
objects,
|
||||
QString(prop.name()),
|
||||
QString(tr(prop.name())),
|
||||
object->property(prop.name()),
|
||||
parent,
|
||||
!(prop.isWritable() && prop.isDesignable())
|
||||
);
|
||||
propertyItem = creator(object, objects, QString(prop.name()), QString(tr(prop.name())),
|
||||
object->property(prop.name()), parent,
|
||||
!(prop.isWritable() && prop.isDesignable()));
|
||||
} else {
|
||||
propertyItem=new ObjectPropItem(
|
||||
0,
|
||||
0,
|
||||
QString(prop.name()),
|
||||
QString(tr(prop.name())),
|
||||
object->property(prop.name()),
|
||||
parent
|
||||
);
|
||||
propertyItem = new ObjectPropItem(0, 0, QString(prop.name()), QString(tr(prop.name())),
|
||||
object->property(prop.name()), parent);
|
||||
}
|
||||
return propertyItem;
|
||||
}
|
||||
|
||||
bool QObjectPropertyModel::isTranslateProperties() const
|
||||
{
|
||||
return m_translateProperties;
|
||||
}
|
||||
bool QObjectPropertyModel::isTranslateProperties() const { return m_translateProperties; }
|
||||
|
||||
void QObjectPropertyModel::setTranslateProperties(bool translateProperties)
|
||||
{
|
||||
m_translateProperties = translateProperties;
|
||||
}
|
||||
ValidatorIntf *QObjectPropertyModel::validator() const
|
||||
{
|
||||
return m_validator;
|
||||
}
|
||||
ValidatorIntf* QObjectPropertyModel::validator() const { return m_validator; }
|
||||
|
||||
void QObjectPropertyModel::setValidator(ValidatorIntf *validator)
|
||||
{
|
||||
m_validator = validator;
|
||||
}
|
||||
void QObjectPropertyModel::setValidator(ValidatorIntf* validator) { m_validator = validator; }
|
||||
|
||||
void QObjectPropertyModel::addObjectProperties(const QMetaObject *metaObject, QObject *object, ObjectPropItem::ObjectsList *objects, int level)
|
||||
void QObjectPropertyModel::addObjectProperties(const QMetaObject* metaObject, QObject* object,
|
||||
ObjectPropItem::ObjectsList* objects, int level)
|
||||
{
|
||||
if (metaObject->propertyCount()>metaObject->propertyOffset()){
|
||||
if (metaObject->propertyCount() > metaObject->propertyOffset()) {
|
||||
ObjectPropItem* objectNode;
|
||||
if (m_subclassesAsLevel){
|
||||
objectNode=new ObjectPropItem(0,0,metaObject->className(),metaObject->className(),m_rootNode,true);
|
||||
if (m_subclassesAsLevel) {
|
||||
objectNode = new ObjectPropItem(0, 0, metaObject->className(), metaObject->className(),
|
||||
m_rootNode, true);
|
||||
m_rootNode->appendItem(objectNode);
|
||||
} else {
|
||||
objectNode = m_rootNode;
|
||||
}
|
||||
|
||||
for (int i=metaObject->propertyOffset();i<metaObject->propertyCount();i++){
|
||||
if (metaObject->property(i).isDesignable()){
|
||||
ObjectPropItem* prop=createPropertyItem(metaObject->property(i),object,objects,objectNode);
|
||||
for (int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); i++) {
|
||||
if (metaObject->property(i).isDesignable()) {
|
||||
ObjectPropItem* prop
|
||||
= createPropertyItem(metaObject->property(i), object, objects, objectNode);
|
||||
objectNode->appendItem(prop);
|
||||
}
|
||||
}
|
||||
if (m_subclassesAsLevel){
|
||||
if (m_subclassesAsLevel) {
|
||||
objectNode->setColorIndex(level);
|
||||
objectNode->sortItem();
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
||||
if (metaObject->superClass()) addObjectProperties(metaObject->superClass(),object,objects,level);
|
||||
if (metaObject->superClass())
|
||||
addObjectProperties(metaObject->superClass(), object, objects, level);
|
||||
m_rootNode->sortItem();
|
||||
}
|
||||
|
||||
bool QObjectPropertyModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool QObjectPropertyModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (index.isValid()&&role==Qt::EditRole){
|
||||
m_dataChanging=true;
|
||||
ObjectPropItem * propItem = nodeFromIndex(index);
|
||||
if (propItem->propertyValue()!=value){
|
||||
if (index.isValid() && role == Qt::EditRole) {
|
||||
m_dataChanging = true;
|
||||
ObjectPropItem* propItem = nodeFromIndex(index);
|
||||
if (propItem->propertyValue() != value) {
|
||||
QString msg;
|
||||
if (validator() && !validator()->validate(propItem->propertyName(),value.toString(),m_object,msg)){
|
||||
QMessageBox::information(0,tr("Warning"),msg);
|
||||
if (validator()
|
||||
&& !validator()->validate(propItem->propertyName(), value.toString(), m_object,
|
||||
msg)) {
|
||||
QMessageBox::information(0, tr("Warning"), msg);
|
||||
return true;
|
||||
}
|
||||
QVariant oldValue=propItem->propertyValue();
|
||||
QVariant oldValue = propItem->propertyValue();
|
||||
propItem->setPropertyValue(value);
|
||||
emit dataChanged(index,index);
|
||||
emit objectPropetyChanged(propItem->propertyName(),oldValue,propItem->propertyValue());
|
||||
emit dataChanged(index, index);
|
||||
emit objectPropetyChanged(propItem->propertyName(), oldValue,
|
||||
propItem->propertyValue());
|
||||
}
|
||||
m_dataChanging=false;
|
||||
m_dataChanging = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::itemDataChanged(const QModelIndex &index)
|
||||
void QObjectPropertyModel::itemDataChanged(const QModelIndex& index)
|
||||
{
|
||||
emit dataChanged(index,index);
|
||||
}
|
||||
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,70 +30,77 @@
|
||||
#ifndef LROBJECTITEMMODEL_H
|
||||
#define LROBJECTITEMMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QVariant>
|
||||
#include <QObject>
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QAbstractItemModel>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ValidatorIntf {
|
||||
public:
|
||||
virtual bool validate(const QString& propName, const QVariant& propValue, QObject* object, QString& msg) = 0;
|
||||
virtual ~ValidatorIntf(){}
|
||||
virtual bool validate(const QString& propName, const QVariant& propValue, QObject* object,
|
||||
QString& msg)
|
||||
= 0;
|
||||
virtual ~ValidatorIntf() { }
|
||||
};
|
||||
|
||||
class QObjectPropertyModel : public QAbstractItemModel
|
||||
{
|
||||
class QObjectPropertyModel: public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QObjectPropertyModel(QObject *parent=0);
|
||||
QObjectPropertyModel(QObject* parent = 0);
|
||||
~QObjectPropertyModel();
|
||||
virtual void setObject(QObject *object);
|
||||
virtual void setMultiObjects(QList<QObject*>* list);
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
virtual QModelIndex parent(const QModelIndex &child) const;
|
||||
virtual int columnCount(const QModelIndex &parent) const;
|
||||
virtual int rowCount(const QModelIndex &parent) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||
void itemDataChanged(const QModelIndex &index);
|
||||
void initModel();
|
||||
const QObject* currentObject(){return m_object;}
|
||||
LimeReport::ObjectPropItem* nodeFromIndex(const QModelIndex &index) const;
|
||||
LimeReport::ObjectPropItem* rootNode(){return m_rootNode;}
|
||||
void updateProperty(const QString& propertyName);
|
||||
void setSubclassesAsLevel(bool value);
|
||||
bool subclassesAsLevel(){return m_subclassesAsLevel;}
|
||||
ValidatorIntf* validator() const;
|
||||
void setValidator(ValidatorIntf* validator);
|
||||
void translatePropertyName();
|
||||
void clearObjectsList();
|
||||
bool isTranslateProperties() const;
|
||||
void setTranslateProperties(bool isTranslateProperties);
|
||||
virtual void setObject(QObject* object);
|
||||
virtual void setMultiObjects(QList<QObject*>* list);
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex& parent) const;
|
||||
virtual QModelIndex parent(const QModelIndex& child) const;
|
||||
virtual int columnCount(const QModelIndex& parent) const;
|
||||
virtual int rowCount(const QModelIndex& parent) const;
|
||||
virtual QVariant data(const QModelIndex& index, int role) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
virtual bool setData(const QModelIndex& index, const QVariant& value, int role);
|
||||
void itemDataChanged(const QModelIndex& index);
|
||||
void initModel();
|
||||
const QObject* currentObject() { return m_object; }
|
||||
LimeReport::ObjectPropItem* nodeFromIndex(const QModelIndex& index) const;
|
||||
LimeReport::ObjectPropItem* rootNode() { return m_rootNode; }
|
||||
void updateProperty(const QString& propertyName);
|
||||
void setSubclassesAsLevel(bool value);
|
||||
bool subclassesAsLevel() { return m_subclassesAsLevel; }
|
||||
ValidatorIntf* validator() const;
|
||||
void setValidator(ValidatorIntf* validator);
|
||||
void translatePropertyName();
|
||||
void clearObjectsList();
|
||||
bool isTranslateProperties() const;
|
||||
void setTranslateProperties(bool isTranslateProperties);
|
||||
|
||||
signals:
|
||||
void objectPropetyChanged(const QString& , const QVariant&, const QVariant&);
|
||||
void objectPropetyChanged(const QString&, const QVariant&, const QVariant&);
|
||||
private slots:
|
||||
void slotObjectDestroyed(QObject* obj);
|
||||
void slotPropertyChanged(const QString& propertyName, const QVariant &oldValue, const QVariant &newValue);
|
||||
void slotPropertyChanged(const QString& propertyName, const QVariant& oldValue,
|
||||
const QVariant& newValue);
|
||||
void slotPropertyObjectNameChanged(const QString& oldName, const QString& newName);
|
||||
|
||||
private:
|
||||
void addObjectProperties(const QMetaObject *metaObject, QObject *object, ObjectPropItem::ObjectsList* objects, int level=0);
|
||||
LimeReport::CreatePropItem propertyItemCreator(QMetaProperty prop);
|
||||
LimeReport::ObjectPropItem* createPropertyItem(QMetaProperty prop, QObject *object, ObjectPropItem::ObjectsList* objects, ObjectPropItem* parent);
|
||||
void addObjectProperties(const QMetaObject* metaObject, QObject* object,
|
||||
ObjectPropItem::ObjectsList* objects, int level = 0);
|
||||
LimeReport::CreatePropItem propertyItemCreator(QMetaProperty prop);
|
||||
LimeReport::ObjectPropItem* createPropertyItem(QMetaProperty prop, QObject* object,
|
||||
ObjectPropItem::ObjectsList* objects,
|
||||
ObjectPropItem* parent);
|
||||
|
||||
private:
|
||||
LimeReport::ObjectPropItem* m_rootNode;
|
||||
QObject* m_object;
|
||||
QList<QObject*> m_objects;
|
||||
bool m_dataChanging;
|
||||
bool m_subclassesAsLevel;
|
||||
ValidatorIntf* m_validator;
|
||||
bool m_translateProperties;
|
||||
LimeReport::ObjectPropItem* m_rootNode;
|
||||
QObject* m_object;
|
||||
QList<QObject*> m_objects;
|
||||
bool m_dataChanging;
|
||||
bool m_subclassesAsLevel;
|
||||
ValidatorIntf* m_validator;
|
||||
bool m_translateProperties;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LROBJECTITEMMODEL_H
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
#include "lrbasedesignintf.h"
|
||||
@@ -36,175 +37,193 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
bool lesThen(ObjectPropItem* v1, ObjectPropItem* v2){
|
||||
return v1->displayName().compare(v2->displayName())<0;
|
||||
bool lesThen(ObjectPropItem* v1, ObjectPropItem* v2)
|
||||
{
|
||||
return v1->displayName().compare(v2->displayName()) < 0;
|
||||
}
|
||||
|
||||
ObjectPropItem::ObjectPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, ObjectPropItem *parent, bool isClass)
|
||||
:m_object(object), m_name(name), m_displayName(displayName), m_haveValue(false), m_parent(parent), m_colorIndex(-1),
|
||||
m_readonly(true), m_model(0), m_isClass(isClass), m_changingValue(false),
|
||||
m_translatePropperty(true)
|
||||
ObjectPropItem::ObjectPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, ObjectPropItem* parent, bool isClass):
|
||||
m_object(object),
|
||||
m_name(name),
|
||||
m_displayName(displayName),
|
||||
m_haveValue(false),
|
||||
m_parent(parent),
|
||||
m_colorIndex(-1),
|
||||
m_readonly(true),
|
||||
m_model(0),
|
||||
m_isClass(isClass),
|
||||
m_changingValue(false),
|
||||
m_translatePropperty(true)
|
||||
{
|
||||
if (parent) setModel(parent->model());
|
||||
m_index=QModelIndex();
|
||||
//if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
if (parent)
|
||||
setModel(parent->model());
|
||||
m_index = QModelIndex();
|
||||
// if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
m_objects = objects;
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
BaseDesignIntf * item = dynamic_cast<BaseDesignIntf*>(object);
|
||||
if (item){
|
||||
connect(item,SIGNAL(propertyChanged(QString,QVariant,QVariant)),this,SLOT(slotPropertyChanged(QString,QVariant,QVariant)));
|
||||
connect(item,SIGNAL(propertyObjectNameChanged(QString,QString)),this,SLOT(slotPropertyObjectName(QString,QString)));
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(object);
|
||||
if (item) {
|
||||
connect(item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
|
||||
connect(item, SIGNAL(propertyObjectNameChanged(QString, QString)), this,
|
||||
SLOT(slotPropertyObjectName(QString, QString)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ObjectPropItem::ObjectPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly)
|
||||
:m_object(object), m_name(name), m_displayName(displayName), m_value(value),
|
||||
m_haveValue(true), m_parent(parent), m_colorIndex(-1),
|
||||
m_readonly(readonly), m_model(0), m_isClass(false), m_changingValue(false),
|
||||
m_translatePropperty(true)
|
||||
ObjectPropItem::ObjectPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
m_object(object),
|
||||
m_name(name),
|
||||
m_displayName(displayName),
|
||||
m_value(value),
|
||||
m_haveValue(true),
|
||||
m_parent(parent),
|
||||
m_colorIndex(-1),
|
||||
m_readonly(readonly),
|
||||
m_model(0),
|
||||
m_isClass(false),
|
||||
m_changingValue(false),
|
||||
m_translatePropperty(true)
|
||||
{
|
||||
if (parent) setModel(parent->model());
|
||||
m_index=QModelIndex();
|
||||
//if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
if (parent)
|
||||
setModel(parent->model());
|
||||
m_index = QModelIndex();
|
||||
// if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
m_objects = objects;
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
BaseDesignIntf * item = dynamic_cast<BaseDesignIntf*>(object);
|
||||
if (item){
|
||||
connect(item,SIGNAL(propertyChanged(QString,QVariant,QVariant)),this,SLOT(slotPropertyChanged(QString,QVariant,QVariant)));
|
||||
connect(item,SIGNAL(propertyObjectNameChanged(QString,QString)),this,SLOT(slotPropertyObjectName(QString,QString)));
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(object);
|
||||
if (item) {
|
||||
connect(item, SIGNAL(propertyChanged(QString, QVariant, QVariant)), this,
|
||||
SLOT(slotPropertyChanged(QString, QVariant, QVariant)));
|
||||
connect(item, SIGNAL(propertyObjectNameChanged(QString, QString)), this,
|
||||
SLOT(slotPropertyObjectName(QString, QString)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ObjectPropItem::~ObjectPropItem(){
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
ObjectPropItem::~ObjectPropItem() { qDeleteAll(m_childItems); }
|
||||
|
||||
int ObjectPropItem::childCount() { return m_childItems.count(); }
|
||||
|
||||
int ObjectPropItem::childCount(){
|
||||
return m_childItems.count();
|
||||
}
|
||||
|
||||
void ObjectPropItem::appendItem(ObjectPropItem *item){
|
||||
m_childItems.append(item);
|
||||
if (m_parent && (!item->isClass())) m_parent->m_globalPropList.append(item);
|
||||
}
|
||||
|
||||
void ObjectPropItem::sortItem()
|
||||
void ObjectPropItem::appendItem(ObjectPropItem* item)
|
||||
{
|
||||
std::sort(m_childItems.begin(), m_childItems.end(), lesThen);
|
||||
m_childItems.append(item);
|
||||
if (m_parent && (!item->isClass()))
|
||||
m_parent->m_globalPropList.append(item);
|
||||
}
|
||||
|
||||
QVariant ObjectPropItem::propertyValue() const {
|
||||
return m_value;
|
||||
}
|
||||
void ObjectPropItem::sortItem() { std::sort(m_childItems.begin(), m_childItems.end(), lesThen); }
|
||||
|
||||
void ObjectPropItem::setPropertyValue(QVariant value){
|
||||
m_value=value;
|
||||
LimeReport::QObjectPropertyModel *itemModel=dynamic_cast<LimeReport::QObjectPropertyModel *>(model());
|
||||
if (itemModel){
|
||||
QVariant ObjectPropItem::propertyValue() const { return m_value; }
|
||||
|
||||
void ObjectPropItem::setPropertyValue(QVariant value)
|
||||
{
|
||||
m_value = value;
|
||||
LimeReport::QObjectPropertyModel* itemModel
|
||||
= dynamic_cast<LimeReport::QObjectPropertyModel*>(model());
|
||||
if (itemModel) {
|
||||
itemModel->itemDataChanged(modelIndex());
|
||||
foreach(ObjectPropItem*item, children()){
|
||||
if (item->modelIndex().isValid()) itemModel->itemDataChanged(item->modelIndex());
|
||||
foreach (ObjectPropItem* item, children()) {
|
||||
if (item->modelIndex().isValid())
|
||||
itemModel->itemDataChanged(item->modelIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString ObjectPropItem::displayName() const {
|
||||
QString ObjectPropItem::displayName() const
|
||||
{
|
||||
return isTranslateProperty() ? m_displayName : propertyName();
|
||||
}
|
||||
|
||||
int ObjectPropItem::row(){
|
||||
int ObjectPropItem::row()
|
||||
{
|
||||
if (m_parent)
|
||||
return m_parent->m_childItems.indexOf(const_cast<ObjectPropItem*>(this));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ObjectPropItem * ObjectPropItem::child(int row){
|
||||
return m_childItems[row];
|
||||
}
|
||||
ObjectPropItem* ObjectPropItem::child(int row) { return m_childItems[row]; }
|
||||
|
||||
void ObjectPropItem::setColorIndex(int value)
|
||||
{
|
||||
m_colorIndex=value;
|
||||
for (int i=0;i<m_childItems.count();i++){
|
||||
m_colorIndex = value;
|
||||
for (int i = 0; i < m_childItems.count(); i++) {
|
||||
m_childItems[i]->setColorIndex(value);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
void ObjectPropItem::slotPropertyChanged(const QString &name, QVariant, QVariant newValue)
|
||||
void ObjectPropItem::slotPropertyChanged(const QString& name, QVariant, QVariant newValue)
|
||||
{
|
||||
if (name.compare(propertyName(),Qt::CaseInsensitive)==0 && !isValueChanging()){
|
||||
if (name.compare(propertyName(), Qt::CaseInsensitive) == 0 && !isValueChanging()) {
|
||||
setPropertyValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectPropItem::slotPropertyObjectName(const QString &oldValue, const QString &newValue)
|
||||
void ObjectPropItem::slotPropertyObjectName(const QString& oldValue, const QString& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
if (propertyName().compare("objectName",Qt::CaseInsensitive)==0 && !isValueChanging()){
|
||||
if (propertyName().compare("objectName", Qt::CaseInsensitive) == 0 && !isValueChanging()) {
|
||||
setPropertyValue(newValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ObjectPropItem::setValueToObject(const QString &propertyName, QVariant propertyValue)
|
||||
void ObjectPropItem::setValueToObject(const QString& propertyName, QVariant propertyValue)
|
||||
{
|
||||
object()->setProperty(propertyName.toLatin1(),propertyValue);
|
||||
if (objects()){
|
||||
object()->setProperty(propertyName.toLatin1(), propertyValue);
|
||||
if (objects()) {
|
||||
foreach (QObject* item, *objects()) {
|
||||
if (item->metaObject()->indexOfProperty(propertyName.toLatin1())!=-1)
|
||||
if (item->metaObject()->indexOfProperty(propertyName.toLatin1()) != -1)
|
||||
item->setProperty(propertyName.toLatin1(), propertyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectPropItem::isTranslateProperty() const
|
||||
{
|
||||
return m_translatePropperty;
|
||||
}
|
||||
bool ObjectPropItem::isTranslateProperty() const { return m_translatePropperty; }
|
||||
|
||||
void ObjectPropItem::setTranslateProperty(bool translatePropperty)
|
||||
{
|
||||
m_translatePropperty = translatePropperty;
|
||||
}
|
||||
|
||||
ObjectPropItem * ObjectPropItem::findChild(const QString &name)
|
||||
ObjectPropItem* ObjectPropItem::findChild(const QString& name)
|
||||
{
|
||||
foreach(ObjectPropItem* item,m_childItems){
|
||||
if (item->propertyName()==name) return item;
|
||||
foreach (ObjectPropItem* item, m_childItems) {
|
||||
if (item->propertyName() == name)
|
||||
return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ObjectPropItem *ObjectPropItem::findPropertyItem(const QString &propertyName)
|
||||
ObjectPropItem* ObjectPropItem::findPropertyItem(const QString& propertyName)
|
||||
{
|
||||
foreach(ObjectPropItem* item,m_globalPropList){
|
||||
if (item->propertyName()==propertyName) return item;
|
||||
foreach (ObjectPropItem* item, m_globalPropList) {
|
||||
if (item->propertyName() == propertyName)
|
||||
return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ObjectPropItem::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
|
||||
void ObjectPropItem::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,
|
||||
const QModelIndex&) const
|
||||
{
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
void ObjectPropItem::updatePropertyValue()
|
||||
{
|
||||
m_model->setData(m_index,m_object->property(m_name.toLatin1()));
|
||||
m_model->setData(m_index, m_object->property(m_name.toLatin1()));
|
||||
}
|
||||
|
||||
bool ObjectPropItem::paint(QPainter *, const StyleOptionViewItem &, const QModelIndex &)
|
||||
bool ObjectPropItem::paint(QPainter*, const StyleOptionViewItem&, const QModelIndex&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ObjectPropItem::displayValue() const
|
||||
{
|
||||
return m_value.toString();
|
||||
}
|
||||
QString ObjectPropItem::displayValue() const { return m_value.toString(); }
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,116 +30,135 @@
|
||||
#ifndef LROBJECTPROPITEM_H
|
||||
#define LROBJECTPROPITEM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QModelIndex>
|
||||
#include <QMetaProperty>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDebug>
|
||||
|
||||
#include "lrattribsabstractfactory.h"
|
||||
#include "lrsingleton.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDebug>
|
||||
#include <QMetaProperty>
|
||||
#include <QModelIndex>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
class ObjectPropItem : public QObject
|
||||
namespace LimeReport {
|
||||
|
||||
class ObjectPropItem: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef QList<QObject*> ObjectsList;
|
||||
ObjectPropItem() { invalidate(); }
|
||||
ObjectPropItem(QObject* object, ObjectsList* objects, const QString& propertyName,
|
||||
const QString& displayName, const QVariant& propertyValue,
|
||||
ObjectPropItem* parent, bool readonly = true);
|
||||
ObjectPropItem(QObject* object, ObjectsList* objects, const QString& propertyName,
|
||||
const QString& displayName, ObjectPropItem* parent, bool isClass = false);
|
||||
~ObjectPropItem();
|
||||
|
||||
virtual QVariant propertyValue() const;
|
||||
virtual void setPropertyValue(QVariant value);
|
||||
virtual QString propertyName() const { return m_name; }
|
||||
virtual QString displayName() const;
|
||||
virtual QString displayValue() const;
|
||||
virtual QIcon iconValue() const { return QIcon(); }
|
||||
virtual bool isHaveChildren() const { return m_childItems.count() > 0; }
|
||||
virtual bool isHaveValue() const { return m_haveValue; }
|
||||
virtual bool isValueReadonly() const { return m_readonly; }
|
||||
void setValueReadOnly(bool value) { m_readonly = value; }
|
||||
virtual bool isValueModified() const { return false; }
|
||||
virtual QWidget* createProperyEditor(QWidget* /*parent*/) const { return 0; }
|
||||
virtual void setPropertyEditorData(QWidget*, const QModelIndex&) const { }
|
||||
virtual void setModelData(QWidget* /*editor*/, QAbstractItemModel* /*model*/,
|
||||
const QModelIndex& /*index*/)
|
||||
{
|
||||
Q_OBJECT
|
||||
}
|
||||
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& /*index*/) const;
|
||||
virtual void updatePropertyValue();
|
||||
virtual bool paint(QPainter*, const StyleOptionViewItem&, const QModelIndex&);
|
||||
|
||||
public:
|
||||
typedef QList< QObject* > ObjectsList;
|
||||
ObjectPropItem(){invalidate();}
|
||||
ObjectPropItem(QObject *object, ObjectsList* objects, const QString& propertyName, const QString& displayName, const QVariant& propertyValue, ObjectPropItem* parent, bool readonly=true);
|
||||
ObjectPropItem(QObject *object, ObjectsList* objects, const QString& propertyName, const QString& displayName, ObjectPropItem *parent, bool isClass = false);
|
||||
~ObjectPropItem();
|
||||
|
||||
virtual QVariant propertyValue() const;
|
||||
virtual void setPropertyValue(QVariant value);
|
||||
virtual QString propertyName() const {return m_name;}
|
||||
virtual QString displayName() const;
|
||||
virtual QString displayValue() const;
|
||||
virtual QIcon iconValue() const{return QIcon();}
|
||||
virtual bool isHaveChildren() const {return m_childItems.count()>0;}
|
||||
virtual bool isHaveValue() const {return m_haveValue;}
|
||||
virtual bool isValueReadonly() const {return m_readonly;}
|
||||
void setValueReadOnly(bool value){m_readonly=value;}
|
||||
virtual bool isValueModified() const {return false;}
|
||||
virtual QWidget* createProperyEditor(QWidget * /*parent*/) const {return 0;}
|
||||
virtual void setPropertyEditorData(QWidget *, const QModelIndex &) const{}
|
||||
virtual void setModelData(QWidget * /*editor*/, QAbstractItemModel * /*model*/, const QModelIndex &/*index*/){}
|
||||
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const;
|
||||
virtual void updatePropertyValue();
|
||||
virtual bool paint(QPainter *, const StyleOptionViewItem &, const QModelIndex &);
|
||||
|
||||
ObjectPropItem* parent() const{ return m_parent;}
|
||||
QObject* object() const{return m_object;}
|
||||
ObjectsList* objects() {return m_objects;}
|
||||
ObjectPropItem* child(int row);
|
||||
QList<ObjectPropItem*> children(){return m_childItems;}
|
||||
ObjectPropItem* findChild(const QString& propertyName);
|
||||
ObjectPropItem* findPropertyItem(const QString& propertyName);
|
||||
int childCount();
|
||||
void appendItem(ObjectPropItem* item);
|
||||
void sortItem();
|
||||
int row();
|
||||
bool isValid(){return m_valid;}
|
||||
int colorIndex(){return m_colorIndex;}
|
||||
void setColorIndex(int propertyValue);
|
||||
void setModel(QAbstractItemModel* model){m_model=model;}
|
||||
QAbstractItemModel* model(){return m_model;}
|
||||
void setModelIndex(const QModelIndex& index){m_index=index;}
|
||||
QModelIndex modelIndex(){return m_index;}
|
||||
bool isClass(){return m_isClass;}
|
||||
bool isTranslateProperty() const;
|
||||
void setTranslateProperty(bool translatePropperty);
|
||||
ObjectPropItem* parent() const { return m_parent; }
|
||||
QObject* object() const { return m_object; }
|
||||
ObjectsList* objects() { return m_objects; }
|
||||
ObjectPropItem* child(int row);
|
||||
QList<ObjectPropItem*> children() { return m_childItems; }
|
||||
ObjectPropItem* findChild(const QString& propertyName);
|
||||
ObjectPropItem* findPropertyItem(const QString& propertyName);
|
||||
int childCount();
|
||||
void appendItem(ObjectPropItem* item);
|
||||
void sortItem();
|
||||
int row();
|
||||
bool isValid() { return m_valid; }
|
||||
int colorIndex() { return m_colorIndex; }
|
||||
void setColorIndex(int propertyValue);
|
||||
void setModel(QAbstractItemModel* model) { m_model = model; }
|
||||
QAbstractItemModel* model() { return m_model; }
|
||||
void setModelIndex(const QModelIndex& index) { m_index = index; }
|
||||
QModelIndex modelIndex() { return m_index; }
|
||||
bool isClass() { return m_isClass; }
|
||||
bool isTranslateProperty() const;
|
||||
void setTranslateProperty(bool translatePropperty);
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
private slots:
|
||||
void slotPropertyChanged(const QString& name, QVariant, QVariant newValue);
|
||||
void slotPropertyObjectName(const QString& oldValue, const QString& newValue);
|
||||
private slots:
|
||||
void slotPropertyChanged(const QString& name, QVariant, QVariant newValue);
|
||||
void slotPropertyObjectName(const QString& oldValue, const QString& newValue);
|
||||
#endif
|
||||
private:
|
||||
bool m_valid;
|
||||
void invalidate(){m_object=0; m_objects=0; m_valid = false; m_name = ""; m_value=QVariant(); m_isClass=false;}
|
||||
|
||||
protected:
|
||||
void beginChangeValue(){ m_changingValue = true; }
|
||||
void endChangeValue(){ m_changingValue = false; }
|
||||
bool isValueChanging(){ return m_changingValue; }
|
||||
void setValueToObject(const QString& propertyName, QVariant propertyValue);
|
||||
private:
|
||||
QObject* m_object;
|
||||
ObjectsList* m_objects;
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
QVariant m_value;
|
||||
bool m_haveValue;
|
||||
ObjectPropItem* m_parent;
|
||||
QList<ObjectPropItem*> m_childItems;
|
||||
QList<ObjectPropItem*> m_globalPropList;
|
||||
int m_colorIndex;
|
||||
bool m_readonly;
|
||||
QAbstractItemModel* m_model;
|
||||
QModelIndex m_index;
|
||||
bool m_isClass;
|
||||
bool m_changingValue;
|
||||
bool m_translatePropperty;
|
||||
};
|
||||
|
||||
typedef QPair<QString,QString> APropIdent;
|
||||
typedef ObjectPropItem* (*CreatePropItem)(QObject *object, ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly);
|
||||
|
||||
class ObjectPropFactory : public AttribsAbstractFactory<LimeReport::ObjectPropItem, APropIdent, CreatePropItem, QString>
|
||||
private:
|
||||
bool m_valid;
|
||||
void invalidate()
|
||||
{
|
||||
private:
|
||||
friend class Singleton<ObjectPropFactory>;
|
||||
private:
|
||||
ObjectPropFactory(){}
|
||||
~ObjectPropFactory(){}
|
||||
ObjectPropFactory(const ObjectPropFactory&){}
|
||||
ObjectPropFactory& operator = (const ObjectPropFactory&){return *this;}
|
||||
};
|
||||
m_object = 0;
|
||||
m_objects = 0;
|
||||
m_valid = false;
|
||||
m_name = "";
|
||||
m_value = QVariant();
|
||||
m_isClass = false;
|
||||
}
|
||||
|
||||
}
|
||||
protected:
|
||||
void beginChangeValue() { m_changingValue = true; }
|
||||
void endChangeValue() { m_changingValue = false; }
|
||||
bool isValueChanging() { return m_changingValue; }
|
||||
void setValueToObject(const QString& propertyName, QVariant propertyValue);
|
||||
|
||||
private:
|
||||
QObject* m_object;
|
||||
ObjectsList* m_objects;
|
||||
QString m_name;
|
||||
QString m_displayName;
|
||||
QVariant m_value;
|
||||
bool m_haveValue;
|
||||
ObjectPropItem* m_parent;
|
||||
QList<ObjectPropItem*> m_childItems;
|
||||
QList<ObjectPropItem*> m_globalPropList;
|
||||
int m_colorIndex;
|
||||
bool m_readonly;
|
||||
QAbstractItemModel* m_model;
|
||||
QModelIndex m_index;
|
||||
bool m_isClass;
|
||||
bool m_changingValue;
|
||||
bool m_translatePropperty;
|
||||
};
|
||||
|
||||
typedef QPair<QString, QString> APropIdent;
|
||||
typedef ObjectPropItem* (*CreatePropItem)(QObject* object, ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
|
||||
class ObjectPropFactory:
|
||||
public AttribsAbstractFactory<LimeReport::ObjectPropItem, APropIdent, CreatePropItem, QString> {
|
||||
private:
|
||||
friend class Singleton<ObjectPropFactory>;
|
||||
|
||||
private:
|
||||
ObjectPropFactory() { }
|
||||
~ObjectPropFactory() { }
|
||||
ObjectPropFactory(const ObjectPropFactory&) { }
|
||||
ObjectPropFactory& operator=(const ObjectPropFactory&) { return *this; }
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
Q_DECLARE_METATYPE(LimeReport::ObjectPropItem*)
|
||||
|
||||
|
||||
@@ -28,20 +28,28 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpropertydelegate.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include "lrobjectinspectorwidget.h"
|
||||
#include <QPainter>
|
||||
#include <QLineEdit>
|
||||
#include <QApplication>
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrobjectinspectorwidget.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent)
|
||||
:QStyledItemDelegate(parent), m_objectInspector(NULL), m_editingItem(0), m_isEditing(false)
|
||||
{}
|
||||
#include <QApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QPainter>
|
||||
|
||||
void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
LimeReport::PropertyDelegate::PropertyDelegate(QObject* parent):
|
||||
QStyledItemDelegate(parent),
|
||||
m_objectInspector(NULL),
|
||||
m_editingItem(0),
|
||||
m_isEditing(false)
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QStyleOptionViewItem opt = option;
|
||||
@@ -49,147 +57,146 @@ void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionVi
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
#endif
|
||||
|
||||
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
|
||||
QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
|
||||
|
||||
LimeReport::ObjectPropItem *node = qvariant_cast<LimeReport::ObjectPropItem*>(index.data(Qt::UserRole));
|
||||
if (node){
|
||||
if (!node->isHaveValue()){
|
||||
if (index.column()==0) {
|
||||
LimeReport::ObjectPropItem* node
|
||||
= qvariant_cast<LimeReport::ObjectPropItem*>(index.data(Qt::UserRole));
|
||||
if (node) {
|
||||
if (!node->isHaveValue()) {
|
||||
if (index.column() == 0) {
|
||||
StyleOptionViewItem cellOpt = option;
|
||||
QTreeView const *tree = dynamic_cast<const QTreeView*>(cellOpt.widget);
|
||||
QTreeView const* tree = dynamic_cast<const QTreeView*>(cellOpt.widget);
|
||||
QStyleOptionViewItem primitiveOpt = cellOpt;
|
||||
primitiveOpt.rect.setWidth(tree->indentation());
|
||||
painter->save();
|
||||
painter->setPen(option.palette.color(QPalette::HighlightedText));
|
||||
painter->setBackground(QBrush(option.palette.color(QPalette::Highlight)));
|
||||
cellOpt.widget->style()->drawPrimitive(QStyle::PE_IndicatorBranch,&primitiveOpt,painter);
|
||||
cellOpt.rect.adjust(primitiveOpt.rect.width(),0,0,0);
|
||||
cellOpt.widget->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &primitiveOpt,
|
||||
painter);
|
||||
cellOpt.rect.adjust(primitiveOpt.rect.width(), 0, 0, 0);
|
||||
cellOpt.font.setBold(true);
|
||||
cellOpt.palette.setColor(QPalette::Text,cellOpt.palette.color(QPalette::BrightText));
|
||||
cellOpt.palette.setColor(QPalette::Text,
|
||||
cellOpt.palette.color(QPalette::BrightText));
|
||||
cellOpt.text = LimeReport::extractClassName(node->propertyName());
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &cellOpt, painter, cellOpt.widget);
|
||||
painter->restore();
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
|
||||
StyleOptionViewItem so = option;
|
||||
if ((node->isValueReadonly())&&(!node->isHaveChildren())) {
|
||||
so.palette.setColor(QPalette::Text,so.palette.color(QPalette::Dark));
|
||||
}
|
||||
StyleOptionViewItem so = option;
|
||||
if ((node->isValueReadonly()) && (!node->isHaveChildren())) {
|
||||
so.palette.setColor(QPalette::Text, so.palette.color(QPalette::Dark));
|
||||
}
|
||||
|
||||
QColor backgroundColor = (so.features & StyleOptionViewItem::Alternate) ?
|
||||
so.palette.alternateBase().color() :
|
||||
so.palette.base().color();
|
||||
QColor backgroundColor = (so.features & StyleOptionViewItem::Alternate)
|
||||
? so.palette.alternateBase().color()
|
||||
: so.palette.base().color();
|
||||
|
||||
qreal luma = 0.2126 * backgroundColor.red() +
|
||||
0.7152 * backgroundColor.green() +
|
||||
0.0722 * backgroundColor.blue();
|
||||
qreal luma = 0.2126 * backgroundColor.red() + 0.7152 * backgroundColor.green()
|
||||
+ 0.0722 * backgroundColor.blue();
|
||||
|
||||
if (luma<128)
|
||||
so.palette.setColor(QPalette::Text,Qt::white);
|
||||
else
|
||||
so.palette.setColor(QPalette::Text,Qt::black);
|
||||
if (luma < 128)
|
||||
so.palette.setColor(QPalette::Text, Qt::white);
|
||||
else
|
||||
so.palette.setColor(QPalette::Text, Qt::black);
|
||||
|
||||
opt.text = "";
|
||||
opt.rect.setHeight(opt.rect.height()-1);
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
|
||||
opt.text = "";
|
||||
opt.rect.setHeight(opt.rect.height() - 1);
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
|
||||
|
||||
if (!node->paint(painter,so,index)){
|
||||
so.state &= ~QStyle::State_HasFocus;
|
||||
so.rect.adjust(0,0,0,-1);
|
||||
QStyledItemDelegate::paint(painter, so, index);
|
||||
}
|
||||
if (!node->paint(painter, so, index)) {
|
||||
so.state &= ~QStyle::State_HasFocus;
|
||||
so.rect.adjust(0, 0, 0, -1);
|
||||
QStyledItemDelegate::paint(painter, so, index);
|
||||
}
|
||||
|
||||
if (index.column()==0){
|
||||
QPointF start(
|
||||
option.rect.x()+option.rect.width()-1,
|
||||
option.rect.y()
|
||||
);
|
||||
QPointF end(
|
||||
option.rect.x()+option.rect.width()-1,
|
||||
option.rect.y()+option.rect.height()
|
||||
);
|
||||
painter->save();
|
||||
QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
||||
painter->setPen(color);
|
||||
painter->drawLine(start,end);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (index.column() == 0) {
|
||||
QPointF start(option.rect.x() + option.rect.width() - 1, option.rect.y());
|
||||
QPointF end(option.rect.x() + option.rect.width() - 1,
|
||||
option.rect.y() + option.rect.height());
|
||||
painter->save();
|
||||
QColor color = static_cast<QRgb>(
|
||||
QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &option));
|
||||
painter->setPen(color);
|
||||
painter->drawLine(start, end);
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QSize LimeReport::PropertyDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
QSize LimeReport::PropertyDelegate::sizeHint(const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
QSize size=option.rect.size();
|
||||
size.setHeight(option.fontMetrics.height()+
|
||||
QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin)
|
||||
QSize size = option.rect.size();
|
||||
size.setHeight(option.fontMetrics.height()
|
||||
+ QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin)
|
||||
#ifdef Q_OS_MAC
|
||||
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
+ QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
#endif
|
||||
+4);
|
||||
//return size;
|
||||
+ 4);
|
||||
// return size;
|
||||
QSize defaultSize = QStyledItemDelegate::sizeHint(option, index);
|
||||
return size.height() > defaultSize.height() ? size : defaultSize;
|
||||
}
|
||||
|
||||
QWidget * LimeReport::PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
QWidget* LimeReport::PropertyDelegate::createEditor(QWidget* parent,
|
||||
const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
m_editingItem = qvariant_cast<LimeReport::ObjectPropItem*>(index.data(Qt::UserRole));
|
||||
connect(m_editingItem,SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDeleted(QObject*)));
|
||||
QWidget *editor=m_editingItem->createProperyEditor(parent);
|
||||
if (editor){
|
||||
connect(m_editingItem, SIGNAL(destroyed(QObject*)), this, SLOT(slotItemDeleted(QObject*)));
|
||||
QWidget* editor = m_editingItem->createProperyEditor(parent);
|
||||
if (editor) {
|
||||
m_isEditing = true;
|
||||
editor->setMaximumHeight(option.rect.height()-1);
|
||||
editor->setMaximumHeight(option.rect.height() - 1);
|
||||
editor->setGeometry(option.rect);
|
||||
if (editor->metaObject()->indexOfSignal("editingFinished()")!=-1)
|
||||
connect(editor,SIGNAL(editingFinished()),this,SLOT(commitAndCloseEditor()));
|
||||
connect(editor,SIGNAL(destroyed()),this,SLOT(slotEditorDeleted()));
|
||||
if (editor->metaObject()->indexOfSignal("editingFinished()") != -1)
|
||||
connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
|
||||
connect(editor, SIGNAL(destroyed()), this, SLOT(slotEditorDeleted()));
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
void LimeReport::PropertyDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
if (m_editingItem) m_editingItem->setPropertyEditorData(editor,index);
|
||||
if (m_editingItem)
|
||||
m_editingItem->setPropertyEditorData(editor, index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::commitAndCloseEditor()
|
||||
{
|
||||
QWidget *editor = qobject_cast<QWidget*>(sender());
|
||||
QWidget* editor = qobject_cast<QWidget*>(sender());
|
||||
emit commitData(editor);
|
||||
emit closeEditor(editor);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
void LimeReport::PropertyDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
if (m_editingItem) m_editingItem->setModelData(editor,model,index);
|
||||
if (m_editingItem)
|
||||
m_editingItem->setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
void LimeReport::PropertyDelegate::updateEditorGeometry(QWidget* editor,
|
||||
const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
if (m_editingItem) m_editingItem->updateEditorGeometry(editor,option,index);
|
||||
if (m_editingItem)
|
||||
m_editingItem->updateEditorGeometry(editor, option, index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::setObjectInspector(ObjectInspectorTreeView* objectInspector)
|
||||
{
|
||||
m_objectInspector=objectInspector;
|
||||
m_objectInspector = objectInspector;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::slotEditorDeleted()
|
||||
void LimeReport::PropertyDelegate::slotEditorDeleted() { m_isEditing = false; }
|
||||
|
||||
void LimeReport::PropertyDelegate::slotItemDeleted(QObject* item)
|
||||
{
|
||||
m_isEditing=false;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::slotItemDeleted(QObject *item)
|
||||
{
|
||||
if (item == m_editingItem) m_editingItem = 0;
|
||||
}
|
||||
|
||||
LimeReport::ObjectPropItem* LimeReport::PropertyDelegate::editingItem()
|
||||
{
|
||||
return m_editingItem;
|
||||
if (item == m_editingItem)
|
||||
m_editingItem = 0;
|
||||
}
|
||||
|
||||
LimeReport::ObjectPropItem* LimeReport::PropertyDelegate::editingItem() { return m_editingItem; }
|
||||
|
||||
@@ -30,39 +30,42 @@
|
||||
#ifndef LRPROPERTYDELEGATE_H
|
||||
#define LRPROPERTYDELEGATE_H
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
#include <QObject>
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QItemDelegate>
|
||||
#include <QObject>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ObjectInspectorTreeView;
|
||||
//class PropertyDelegate : public QItemDelegate
|
||||
class PropertyDelegate : public QStyledItemDelegate
|
||||
{
|
||||
// class PropertyDelegate : public QItemDelegate
|
||||
class PropertyDelegate: public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PropertyDelegate(QObject *parent=0);
|
||||
PropertyDelegate(QObject* parent = 0);
|
||||
void setObjectInspector(ObjectInspectorTreeView* objectInspector);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const;
|
||||
void setEditorData(QWidget* editor, const QModelIndex& index) const;
|
||||
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
|
||||
void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const;
|
||||
LimeReport::ObjectPropItem* editingItem();
|
||||
bool isEditing(){return m_isEditing;}
|
||||
bool isEditing() { return m_isEditing; }
|
||||
private slots:
|
||||
void commitAndCloseEditor();
|
||||
void slotEditorDeleted();
|
||||
void slotItemDeleted(QObject* item);
|
||||
|
||||
private:
|
||||
LimeReport::ObjectInspectorTreeView* m_objectInspector;
|
||||
mutable LimeReport::ObjectPropItem* m_editingItem;
|
||||
mutable bool m_isEditing;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRPROPERTYDELEGATE_H
|
||||
|
||||
@@ -7,45 +7,59 @@
|
||||
#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)
|
||||
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);
|
||||
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)
|
||||
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);
|
||||
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
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *AxisPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* AxisPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new AxisPropEditor(qobject_cast<ChartItem*>(object()), m_isXAxis, parent);
|
||||
}
|
||||
|
||||
QString AxisPropItem::displayValue() const
|
||||
{
|
||||
return QObject::tr("Axis");
|
||||
}
|
||||
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)
|
||||
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);
|
||||
layout->setContentsMargins(1, 0, 1, 1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
}
|
||||
|
||||
void AxisPropEditor::slotButtonClicked()
|
||||
@@ -54,4 +68,4 @@ void AxisPropEditor::slotButtonClicked()
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,37 +1,41 @@
|
||||
#ifndef AXISPROPITEM_H
|
||||
#define AXISPROPITEM_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <lrobjectpropitem.h>
|
||||
#include <lrchartitem.h>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <lrchartitem.h>
|
||||
#include <lrobjectpropitem.h>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class AxisPropEditor : public QWidget
|
||||
{
|
||||
class AxisPropEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AxisPropEditor(ChartItem* chart, bool isXAxis, QWidget *parent = 0);
|
||||
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
|
||||
{
|
||||
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;
|
||||
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:
|
||||
|
||||
@@ -28,46 +28,53 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrboolpropitem.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
|
||||
#include "../editors/lrcheckboxeditor.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createBoolPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::BoolPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("bool",""),QObject::tr("bool"),createBoolPropItem);
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QPainter>
|
||||
#include <QStylePainter>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createBoolPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::BoolPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("bool", ""), QObject::tr("bool"), createBoolPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *BoolPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* BoolPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
CheckBoxEditor *editor= new CheckBoxEditor(parent);
|
||||
CheckBoxEditor* editor = new CheckBoxEditor(parent);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void BoolPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void BoolPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
CheckBoxEditor *editor =qobject_cast<CheckBoxEditor *>(propertyEditor);
|
||||
CheckBoxEditor* editor = qobject_cast<CheckBoxEditor*>(propertyEditor);
|
||||
editor->setEditing(true);
|
||||
editor->setChecked(propertyValue().toBool());
|
||||
editor->setEditing(false);
|
||||
}
|
||||
|
||||
void BoolPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void BoolPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
model->setData(index, qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
QPixmap BoolPropItem::getIndicatorImage(const StyleOptionViewItem &option){
|
||||
QPixmap BoolPropItem::getIndicatorImage(const StyleOptionViewItem& option)
|
||||
{
|
||||
QStyleOptionButton so;
|
||||
so.state = option.state;
|
||||
if (!isValueReadonly())
|
||||
@@ -75,34 +82,35 @@ QPixmap BoolPropItem::getIndicatorImage(const StyleOptionViewItem &option){
|
||||
else
|
||||
so.state &= ~QStyle::State_Enabled;
|
||||
so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off;
|
||||
so.rect = QRect(0,0,
|
||||
QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
so.rect = QRect(0, 0, QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
QApplication::style()->pixelMetric(QStyle::PM_IndicatorHeight));
|
||||
|
||||
QPixmap pixmap(so.rect.width(),so.rect.height());
|
||||
QPixmap pixmap(so.rect.width(), so.rect.height());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter p(&pixmap);
|
||||
option.widget->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so, &p);
|
||||
option.widget->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck, &so, &p);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
bool BoolPropItem::paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index)
|
||||
bool BoolPropItem::paint(QPainter* painter, const StyleOptionViewItem& option,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
|
||||
if (index.column()==1){
|
||||
int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
// QStyleOptionButton so;
|
||||
// so.rect = option.rect.adjusted(border,border,0,-border);
|
||||
// so.rect.setWidth(style->pixelMetric(QStyle::PM_IndicatorWidth));
|
||||
// so.rect.setHeight(style->pixelMetric(QStyle::PM_IndicatorHeight));
|
||||
// so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off;
|
||||
// style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so,painter);
|
||||
painter->drawPixmap(option.rect.x()+border,option.rect.y()+border, getIndicatorImage(option));
|
||||
if (index.column() == 1) {
|
||||
int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth)) / 2;
|
||||
// QStyleOptionButton so;
|
||||
// so.rect = option.rect.adjusted(border,border,0,-border);
|
||||
// so.rect.setWidth(style->pixelMetric(QStyle::PM_IndicatorWidth));
|
||||
// so.rect.setHeight(style->pixelMetric(QStyle::PM_IndicatorHeight));
|
||||
// so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off;
|
||||
// style->drawPrimitive(QStyle::PE_IndicatorItemViewItemCheck,&so,painter);
|
||||
painter->drawPixmap(option.rect.x() + border, option.rect.y() + border,
|
||||
getIndicatorImage(option));
|
||||
return true;
|
||||
} else return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
@@ -33,20 +33,25 @@
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class BoolPropItem : public ObjectPropItem
|
||||
{
|
||||
class BoolPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BoolPropItem():ObjectPropItem(){}
|
||||
BoolPropItem(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){}
|
||||
virtual QString displayValue() const {return "";}
|
||||
virtual QWidget* createProperyEditor(QWidget *parent) const;
|
||||
virtual void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
virtual void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
bool paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index);
|
||||
BoolPropItem(): ObjectPropItem() { }
|
||||
BoolPropItem(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)
|
||||
{
|
||||
}
|
||||
virtual QString displayValue() const { return ""; }
|
||||
virtual QWidget* createProperyEditor(QWidget* parent) const;
|
||||
virtual void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
virtual void setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index);
|
||||
bool paint(QPainter* painter, const StyleOptionViewItem& option, const QModelIndex& index);
|
||||
|
||||
protected:
|
||||
QPixmap getIndicatorImage(const StyleOptionViewItem &option);
|
||||
QPixmap getIndicatorImage(const StyleOptionViewItem& option);
|
||||
};
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
@@ -28,60 +28,72 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcolorpropitem.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include "editors/lrcoloreditor.h"
|
||||
#include <QPainter>
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createColorPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ColorPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredColorProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QColor",""),QObject::tr("QColor"),createColorPropItem);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
void ColorPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createColorPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
ColorEditor *editor =qobject_cast<ColorEditor*>(propertyEditor);
|
||||
return new LimeReport::ColorPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredColorProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QColor", ""), QObject::tr("QColor"), createColorPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
void ColorPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
ColorEditor* editor = qobject_cast<ColorEditor*>(propertyEditor);
|
||||
editor->setColor(propertyValue().value<QColor>());
|
||||
}
|
||||
|
||||
void ColorPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void ColorPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ColorEditor*>(propertyEditor)->color());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
model->setData(index, qobject_cast<ColorEditor*>(propertyEditor)->color());
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
bool ColorPropItem::paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index)
|
||||
bool ColorPropItem::paint(QPainter* painter, const StyleOptionViewItem& option,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
if (index.column()==1){
|
||||
if (index.column() == 1) {
|
||||
painter->save();
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
QPen pen;
|
||||
QColor penColor = isColorDark(propertyValue().value<QColor>()) ? Qt::transparent : Qt::darkGray;
|
||||
QColor penColor
|
||||
= isColorDark(propertyValue().value<QColor>()) ? Qt::transparent : Qt::darkGray;
|
||||
pen.setColor(penColor);
|
||||
painter->setPen(pen);
|
||||
painter->setBrush(propertyValue().value<QColor>());
|
||||
int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
int border = (option.rect.height() - style->pixelMetric(QStyle::PM_IndicatorWidth)) / 2;
|
||||
|
||||
QRect rect(option.rect.x()+border,option.rect.y()+border,
|
||||
QRect rect(option.rect.x() + border, option.rect.y() + border,
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth),
|
||||
style->pixelMetric(QStyle::PM_IndicatorWidth));
|
||||
painter->drawRect(rect);
|
||||
|
||||
painter->restore();
|
||||
return true;
|
||||
} else return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *ColorPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* ColorPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new ColorEditor(parent);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -32,20 +32,23 @@
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ColorPropItem : public ObjectPropItem
|
||||
{
|
||||
class ColorPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorPropItem():ObjectPropItem(){}
|
||||
ColorPropItem(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;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
bool paint(QPainter *painter, const StyleOptionViewItem &option, const QModelIndex &index);
|
||||
ColorPropItem(): ObjectPropItem() { }
|
||||
ColorPropItem(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;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
bool paint(QPainter* painter, const StyleOptionViewItem& option, const QModelIndex& index);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRCOLORPROPITEM_H
|
||||
|
||||
@@ -1,38 +1,47 @@
|
||||
#include "lrcontentpropitem.h"
|
||||
#include "lrtextitem.h"
|
||||
|
||||
#include "editors/lrbuttonlineeditor.h"
|
||||
#include "items/lrtextitemeditor.h"
|
||||
#include "lrtextitem.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createContentPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ContentPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredContentProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createContentPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ContentPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredContentProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("content", "LimeReport::TextItem"), QObject::tr("content"),
|
||||
createContentPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *ContentPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* ContentPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new ContentEditor(object(), object()->objectName()+"."+displayName(), parent);
|
||||
return new ContentEditor(object(), object()->objectName() + "." + displayName(), parent);
|
||||
}
|
||||
|
||||
void ContentEditor::editButtonClicked()
|
||||
{
|
||||
QDialog* dialog = new QDialog(QApplication::activeWindow());
|
||||
dialog->setLayout(new QVBoxLayout());
|
||||
dialog->layout()->setContentsMargins(1,1,1,1);
|
||||
dialog->layout()->setContentsMargins(1, 1, 1, 1);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setWindowTitle(propertyName());
|
||||
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
|
||||
dialog->layout()->addWidget(editor);
|
||||
dialog->resize(editor->size());
|
||||
connect(editor,SIGNAL(destroyed()),dialog,SLOT(close()));
|
||||
connect(editor,SIGNAL(destroyed()),this,SIGNAL(editingFinished()));
|
||||
connect(editor, SIGNAL(destroyed()), dialog, SLOT(close()));
|
||||
connect(editor, SIGNAL(destroyed()), this, SIGNAL(editingFinished()));
|
||||
dialog->exec();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -6,24 +6,32 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ContentEditor : public ButtonLineEditor{
|
||||
class ContentEditor: public ButtonLineEditor {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ContentEditor(QObject* object, const QString& propertyName,QWidget *parent = 0)
|
||||
:ButtonLineEditor(propertyName,parent), m_object(object){}
|
||||
explicit ContentEditor(QObject* object, const QString& propertyName, QWidget* parent = 0):
|
||||
ButtonLineEditor(propertyName, parent),
|
||||
m_object(object)
|
||||
{
|
||||
}
|
||||
public slots:
|
||||
void editButtonClicked();
|
||||
|
||||
private:
|
||||
QObject* m_object;
|
||||
};
|
||||
|
||||
class ContentPropItem : public StringPropItem{
|
||||
class ContentPropItem: public StringPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ContentPropItem():StringPropItem(){}
|
||||
ContentPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly)
|
||||
:StringPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
ContentPropItem(): StringPropItem() { }
|
||||
ContentPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly):
|
||||
StringPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
}
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -28,98 +28,125 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdatasourcepropitem.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include "../editors/lrcomboboxeditor.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createDatasourcePropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::DatasourcePropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
|
||||
LimeReport::ObjectPropItem* createFieldPropItem(QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly){
|
||||
return new LimeReport::FieldPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::DataBandDesignIntf"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredImageDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::ImageItem"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredImageFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredChartDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::ChartItem"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredBarcodeDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::BarcodeItem"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field","LimeReport::BarcodeItem"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredSVGItemDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::SVGItem"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredSVGFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field","LimeReport::SVGItem"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem*
|
||||
createDatasourcePropItem(QObject* object, LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName, const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::DatasourcePropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
|
||||
QWidget* LimeReport::DatasourcePropItem::createProperyEditor(QWidget *parent) const{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent,true);
|
||||
LimeReport::ObjectPropItem* createFieldPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::FieldPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredDatasouceProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource", "LimeReport::DataBandDesignIntf"),
|
||||
QObject::tr("datasource"), createDatasourcePropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredImageDatasouceProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource", "LimeReport::ImageItem"), QObject::tr("datasource"),
|
||||
createDatasourcePropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredImageFieldProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field", "LimeReport::ImageItem"), QObject::tr("field"),
|
||||
createFieldPropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredChartDatasouceProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource", "LimeReport::ChartItem"), QObject::tr("datasource"),
|
||||
createDatasourcePropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredBarcodeDatasouceProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource", "LimeReport::BarcodeItem"), QObject::tr("datasource"),
|
||||
createDatasourcePropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field", "LimeReport::BarcodeItem"), QObject::tr("field"),
|
||||
createFieldPropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredSVGItemDatasouceProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource", "LimeReport::SVGItem"), QObject::tr("datasource"),
|
||||
createDatasourcePropItem);
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredSVGFieldProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field", "LimeReport::SVGItem"), QObject::tr("field"),
|
||||
createFieldPropItem);
|
||||
} // namespace
|
||||
|
||||
QWidget* LimeReport::DatasourcePropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent, true);
|
||||
editor->setEditable(true);
|
||||
LimeReport::BaseDesignIntf *item=dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
if (item){
|
||||
editor->addItems(item->reportEditor()->dataManager()->dataSourceNames());
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
if (item) {
|
||||
editor->addItems(item->reportEditor()->dataManager()->dataSourceNames());
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::DatasourcePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
void LimeReport::DatasourcePropItem::setPropertyEditorData(QWidget* propertyEditor,
|
||||
const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(propertyValue().toString());
|
||||
}
|
||||
|
||||
void LimeReport::DatasourcePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index){
|
||||
model->setData(index,qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
void LimeReport::DatasourcePropItem::setModelData(QWidget* propertyEditor,
|
||||
QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index, qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
|
||||
QWidget *LimeReport::FieldPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* LimeReport::FieldPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent);
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent);
|
||||
editor->setEditable(true);
|
||||
LimeReport::BaseDesignIntf *item=dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
int propertyIndex = object()->metaObject()->indexOfProperty("datasource");
|
||||
|
||||
if (item && propertyIndex>0){
|
||||
editor->addItems(item->reportEditor()->dataManager()->fieldNames(object()->property("datasource").toString()));
|
||||
if (item && propertyIndex > 0) {
|
||||
editor->addItems(item->reportEditor()->dataManager()->fieldNames(
|
||||
object()->property("datasource").toString()));
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::FieldPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void LimeReport::FieldPropItem::setPropertyEditorData(QWidget* propertyEditor,
|
||||
const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(propertyValue().toString());
|
||||
}
|
||||
|
||||
void LimeReport::FieldPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void LimeReport::FieldPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
model->setData(index, qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
@@ -31,31 +31,37 @@
|
||||
#define LRDATASOURCEPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class DatasourcePropItem : public LimeReport::ObjectPropItem
|
||||
{
|
||||
class DatasourcePropItem: public LimeReport::ObjectPropItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DatasourcePropItem(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;
|
||||
void setPropertyEditorData(QWidget *, const QModelIndex &) const;
|
||||
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
DatasourcePropItem(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;
|
||||
void setPropertyEditorData(QWidget*, const QModelIndex&) const;
|
||||
void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&);
|
||||
};
|
||||
|
||||
class FieldPropItem : public LimeReport::ObjectPropItem
|
||||
{
|
||||
class FieldPropItem: public LimeReport::ObjectPropItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FieldPropItem(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;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *, const QModelIndex &index);
|
||||
FieldPropItem(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;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel*, const QModelIndex& index);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRDATASOURCEPROPITEM_H
|
||||
|
||||
@@ -28,35 +28,43 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrenumpropitem.h"
|
||||
|
||||
#include "../editors/lrcomboboxeditor.h"
|
||||
#include "lrbanddesignintf.h"
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::ObjectPropItem * createEnumPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
LimeReport::ObjectPropItem* createEnumPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::EnumPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
|
||||
);
|
||||
LimeReport::APropIdent("enum", ""), QObject::tr("enum"), createEnumPropItem);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* EnumPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent,false);
|
||||
connect(editor,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotEnumChanged(QString)));
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent, false);
|
||||
connect(editor, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotEnumChanged(QString)));
|
||||
|
||||
QStringList enumValues;
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++){
|
||||
if (m_acceptableValues.isEmpty()) enumValues.append(tr(propEnum.key(i)));
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
for (int i = 0; i < propEnum.keyCount(); i++) {
|
||||
if (m_acceptableValues.isEmpty())
|
||||
enumValues.append(tr(propEnum.key(i)));
|
||||
else {
|
||||
if (m_acceptableValues.contains(propEnum.value(i))){
|
||||
if (m_acceptableValues.contains(propEnum.value(i))) {
|
||||
enumValues.append(tr(propEnum.key(i)));
|
||||
}
|
||||
}
|
||||
@@ -65,20 +73,24 @@ QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
|
||||
return editor;
|
||||
}
|
||||
|
||||
void EnumPropItem::slotEnumChanged(const QString &text)
|
||||
void EnumPropItem::slotEnumChanged(const QString& text)
|
||||
{
|
||||
if ( nameByType(object()->property(propertyName().toLatin1()).toInt())!=text){
|
||||
if (nameByType(object()->property(propertyName().toLatin1()).toInt()) != text) {
|
||||
beginChangeValue();
|
||||
setPropertyValue(typeByName(text));
|
||||
setValueToObject(propertyName(),typeByName(text));
|
||||
setValueToObject(propertyName(), typeByName(text));
|
||||
endChangeValue();
|
||||
}
|
||||
}
|
||||
|
||||
void EnumPropItem::initTranslation()
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++){
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
for (int i = 0; i < propEnum.keyCount(); i++) {
|
||||
m_translation.insert(QString(tr(propEnum.key(i))), QString(propEnum.key(i)));
|
||||
}
|
||||
}
|
||||
@@ -168,36 +180,42 @@ void EnumPropItem::translateEnumItemName()
|
||||
tr("DashDotLine");
|
||||
tr("DashDotDotLine");
|
||||
tr("CustomDashLine");
|
||||
|
||||
}
|
||||
|
||||
void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void EnumPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(nameByType(propertyValue().toInt()));
|
||||
}
|
||||
|
||||
void EnumPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void EnumPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
setValueToObject(propertyName(),typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
|
||||
model->setData(index,object()->property(propertyName().toLatin1()));
|
||||
setValueToObject(propertyName(),
|
||||
typeByName(qobject_cast<ComboBoxEditor*>(propertyEditor)->text()));
|
||||
model->setData(index, object()->property(propertyName().toLatin1()));
|
||||
}
|
||||
|
||||
QString EnumPropItem::nameByType(int value) const
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
return isTranslateProperty() ? tr(propEnum.valueToKey(value)) : propEnum.valueToKey(value);
|
||||
}
|
||||
|
||||
int EnumPropItem::typeByName(const QString &value) const
|
||||
int EnumPropItem::typeByName(const QString& value) const
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
return propEnum.keyToValue(m_translation.value(value).toLatin1());
|
||||
}
|
||||
|
||||
QString EnumPropItem::displayValue() const
|
||||
{
|
||||
return nameByType((propertyValue().toInt()));
|
||||
}
|
||||
QString EnumPropItem::displayValue() const { return nameByType((propertyValue().toInt())); }
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,35 +31,51 @@
|
||||
#define LRENUMPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
namespace LimeReport{
|
||||
class EnumPropItem : public ObjectPropItem
|
||||
{
|
||||
namespace LimeReport {
|
||||
class EnumPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EnumPropItem():ObjectPropItem(), m_settingValue(false){initTranslation();}
|
||||
EnumPropItem(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),m_settingValue(false){initTranslation();}
|
||||
EnumPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly, QVector<int> acceptableValues)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_acceptableValues(acceptableValues),m_settingValue(false){initTranslation();}
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
QVector<int> acceptableValues() const {return m_acceptableValues;}
|
||||
EnumPropItem(): ObjectPropItem(), m_settingValue(false) { initTranslation(); }
|
||||
EnumPropItem(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),
|
||||
m_settingValue(false)
|
||||
{
|
||||
initTranslation();
|
||||
}
|
||||
EnumPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly, QVector<int> acceptableValues):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly),
|
||||
m_acceptableValues(acceptableValues),
|
||||
m_settingValue(false)
|
||||
{
|
||||
initTranslation();
|
||||
}
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
QVector<int> acceptableValues() const { return m_acceptableValues; }
|
||||
|
||||
protected:
|
||||
QString nameByType(int propertyValue) const;
|
||||
int typeByName(const QString& propertyValue) const;
|
||||
int typeByName(const QString& propertyValue) const;
|
||||
private slots:
|
||||
void slotEnumChanged(const QString& text);
|
||||
|
||||
private:
|
||||
void initTranslation();
|
||||
void translateEnumItemName();
|
||||
|
||||
private:
|
||||
QVector<int> m_acceptableValues;
|
||||
bool m_settingValue;
|
||||
QMap<QString, QString> m_translation;
|
||||
};
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRENUMPROPITEM_H
|
||||
|
||||
@@ -28,10 +28,12 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrflagspropitem.h"
|
||||
#include "lrenumpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
|
||||
#include "../editors/lrcheckboxeditor.h"
|
||||
#include "lrboolpropitem.h"
|
||||
#include "lrenumpropitem.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
@@ -40,14 +42,17 @@
|
||||
|
||||
namespace {
|
||||
|
||||
LimeReport::ObjectPropItem * createFlagsPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
LimeReport::ObjectPropItem* createFlagsPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::FlagsPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
return new LimeReport::FlagsPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("flags",""),QObject::tr("flags"),createFlagsPropItem
|
||||
);
|
||||
LimeReport::APropIdent("flags", ""), QObject::tr("flags"), createFlagsPropItem);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -55,52 +60,73 @@ namespace LimeReport {
|
||||
|
||||
void FlagsPropItem::createChildren()
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++)
|
||||
{
|
||||
if ( propEnum.keyToValue(propEnum.key(i)) !=0 ) {
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
for (int i = 0; i < propEnum.keyCount(); i++) {
|
||||
if (propEnum.keyToValue(propEnum.key(i)) != 0) {
|
||||
this->appendItem(new LimeReport::FlagPropItem(
|
||||
object(), objects(), QString(propEnum.key(i)), tr(propEnum.key(i)),
|
||||
bool((propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))==propEnum.keyToValue(propEnum.key(i))),
|
||||
this, false
|
||||
)
|
||||
);
|
||||
object(), objects(), QString(propEnum.key(i)), tr(propEnum.key(i)),
|
||||
bool((propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))
|
||||
== propEnum.keyToValue(propEnum.key(i))),
|
||||
this, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FlagsPropItem::updateChildren()
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++)
|
||||
{
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
for (int i = 0; i < propEnum.keyCount(); i++) {
|
||||
ObjectPropItem* property = findChild(QString(propEnum.key(i)));
|
||||
if (property)
|
||||
property->setPropertyValue(bool((propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))==propEnum.keyToValue(propEnum.key(i))));
|
||||
property->setPropertyValue(
|
||||
bool((propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))
|
||||
== propEnum.keyToValue(propEnum.key(i))));
|
||||
}
|
||||
}
|
||||
|
||||
FlagsPropItem::FlagsPropItem(QObject *object, ObjectPropItem::ObjectsList *objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
FlagsPropItem::FlagsPropItem(QObject* object, ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
createChildren();
|
||||
}
|
||||
|
||||
FlagsPropItem::FlagsPropItem(QObject *object, ObjectPropItem::ObjectsList *objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly, QSet<int> acceptableValues)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_acceptableValues(acceptableValues){}
|
||||
FlagsPropItem::FlagsPropItem(QObject* object, ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly, QSet<int> acceptableValues):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly),
|
||||
m_acceptableValues(acceptableValues)
|
||||
{
|
||||
}
|
||||
|
||||
QString FlagsPropItem::displayValue() const
|
||||
{
|
||||
QString result;
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++)
|
||||
{
|
||||
if ((propEnum.keyToValue(propEnum.key(i)) == 0) ? propertyValue().toInt() == 0 : (propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i))) == propEnum.keyToValue(propEnum.key(i)))
|
||||
{
|
||||
if (result.isEmpty()) result+= isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i);
|
||||
else result=result+" | "+ (isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i));
|
||||
QMetaEnum propEnum
|
||||
= object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
for (int i = 0; i < propEnum.keyCount(); i++) {
|
||||
if ((propEnum.keyToValue(propEnum.key(i)) == 0)
|
||||
? propertyValue().toInt() == 0
|
||||
: (propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))
|
||||
== propEnum.keyToValue(propEnum.key(i))) {
|
||||
if (result.isEmpty())
|
||||
result += isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i);
|
||||
else
|
||||
result = result + " | "
|
||||
+ (isTranslateProperty() ? tr(propEnum.key(i)) : propEnum.key(i));
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -111,9 +137,7 @@ void FlagsPropItem::setPropertyValue(QVariant value)
|
||||
updateChildren();
|
||||
}
|
||||
|
||||
void FlagsPropItem::slotEnumChanged(QString /*text*/)
|
||||
{
|
||||
}
|
||||
void FlagsPropItem::slotEnumChanged(QString /*text*/) { }
|
||||
|
||||
void FlagsPropItem::translateFlagsItem()
|
||||
{
|
||||
@@ -125,34 +149,42 @@ void FlagsPropItem::translateFlagsItem()
|
||||
tr("AllLines");
|
||||
}
|
||||
|
||||
FlagPropItem::FlagPropItem(QObject* object, ObjectsList* objects, const QString &propName, const QString &displayName, const QVariant &value, ObjectPropItem* parent, bool readonly)
|
||||
:BoolPropItem(object, objects, propName,displayName,value,parent,readonly)
|
||||
FlagPropItem::FlagPropItem(QObject* object, ObjectsList* objects, const QString& propName,
|
||||
const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
BoolPropItem(object, objects, propName, displayName, value, parent, readonly)
|
||||
{
|
||||
}
|
||||
|
||||
void FlagPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &/*index*/) const
|
||||
void FlagPropItem::setPropertyEditorData(QWidget* propertyEditor,
|
||||
const QModelIndex& /*index*/) const
|
||||
{
|
||||
CheckBoxEditor *editor = qobject_cast<CheckBoxEditor*>(propertyEditor);
|
||||
CheckBoxEditor* editor = qobject_cast<CheckBoxEditor*>(propertyEditor);
|
||||
editor->setChecked(propertyValue().toBool());
|
||||
}
|
||||
|
||||
void FlagPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void FlagPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
bool value = qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked();
|
||||
model->setData(index,value);
|
||||
model->setData(index, value);
|
||||
int flags = object()->property(parent()->propertyName().toLatin1()).toInt();
|
||||
if (value) flags = flags | valueByName(propertyName());
|
||||
else if (flags & valueByName(propertyName())) flags = flags ^ valueByName(propertyName());
|
||||
setValueToObject(parent()->propertyName(),flags);
|
||||
if (value)
|
||||
flags = flags | valueByName(propertyName());
|
||||
else if (flags & valueByName(propertyName()))
|
||||
flags = flags ^ valueByName(propertyName());
|
||||
setValueToObject(parent()->propertyName(), flags);
|
||||
parent()->setPropertyValue(flags);
|
||||
}
|
||||
|
||||
int FlagPropItem::valueByName(const QString& typeName)
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(parent()->propertyName().toLatin1())).enumerator();
|
||||
QMetaEnum propEnum = object()
|
||||
->metaObject()
|
||||
->property(object()->metaObject()->indexOfProperty(
|
||||
parent()->propertyName().toLatin1()))
|
||||
.enumerator();
|
||||
return propEnum.keyToValue(typeName.toLatin1());
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
@@ -30,43 +30,50 @@
|
||||
#ifndef LRFLAGSPROPEDITOR_H
|
||||
#define LRFLAGSPROPEDITOR_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class FlagsPropItem : public ObjectPropItem
|
||||
{
|
||||
class FlagsPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FlagsPropItem():ObjectPropItem(){}
|
||||
FlagsPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly);
|
||||
FlagsPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly, QSet<int> acceptableValues);
|
||||
FlagsPropItem(): ObjectPropItem() { }
|
||||
FlagsPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
FlagsPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly, QSet<int> acceptableValues);
|
||||
virtual QString displayValue() const;
|
||||
virtual void setPropertyValue(QVariant propertyValue);
|
||||
virtual void setPropertyValue(QVariant propertyValue);
|
||||
private slots:
|
||||
void slotEnumChanged(QString);
|
||||
|
||||
private:
|
||||
void translateFlagsItem();
|
||||
|
||||
private:
|
||||
QSet<int> m_acceptableValues;
|
||||
QString nameByType(int propertyValue) const;
|
||||
int typeByName(QString propertyValue) const;
|
||||
int typeByName(QString propertyValue) const;
|
||||
void createChildren();
|
||||
void updateChildren();
|
||||
};
|
||||
|
||||
class FlagPropItem : public BoolPropItem{
|
||||
class FlagPropItem: public BoolPropItem {
|
||||
public:
|
||||
FlagPropItem():BoolPropItem(){}
|
||||
FlagPropItem(QObject* object, ObjectsList* objects, const QString& propName, const QString& displayName, const QVariant& propertyValue, ObjectPropItem* parent, bool readonly);
|
||||
virtual void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex & ) const;
|
||||
virtual void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
virtual QString displayValue() const{return "";}
|
||||
private:
|
||||
int valueByName(const QString &typeName);
|
||||
};
|
||||
FlagPropItem(): BoolPropItem() { }
|
||||
FlagPropItem(QObject* object, ObjectsList* objects, const QString& propName,
|
||||
const QString& displayName, const QVariant& propertyValue, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
virtual void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
virtual void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&);
|
||||
virtual QString displayValue() const { return ""; }
|
||||
|
||||
private:
|
||||
int valueByName(const QString& typeName);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
@@ -27,35 +27,48 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QFontDialog>
|
||||
|
||||
#include "lrfontpropitem.h"
|
||||
|
||||
#include "editors/lrbuttonlineeditor.h"
|
||||
#include "editors/lrfonteditor.h"
|
||||
#include "editors/lrcheckboxeditor.h"
|
||||
#include "editors/lrfonteditor.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createFontPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::FontPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredFontProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QFont",""),QObject::tr("QFont"),createFontPropItem);
|
||||
#include <QFontDialog>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createFontPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::FontPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredFontProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QFont", ""), QObject::tr("QFont"), createFontPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
FontPropItem::FontPropItem(QObject *object, ObjectPropItem::ObjectsList *objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool readonly)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
FontPropItem::FontPropItem(QObject* object, ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName, const QVariant& value,
|
||||
ObjectPropItem* parent, bool readonly):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
|
||||
m_bold = new FontAttribPropItem(object,objects,"bold",tr("bold"),propertyValue().value<QFont>().bold(),this,false);
|
||||
m_italic = new FontAttribPropItem(object,objects,"italic",tr("italic"),propertyValue().value<QFont>().italic(),this,false);
|
||||
m_underline = new FontAttribPropItem(object,objects,"underline",tr("underline"),propertyValue().value<QFont>().underline(),this,false);
|
||||
m_pointSize = new FontPointSizePropItem(object,0,"pointSize",tr("size"),propertyValue().value<QFont>().pointSize(),this,false);
|
||||
m_family = new FontFamilyPropItem(object,0,"family",tr("family"),propertyValue().value<QFont>(),this,false);
|
||||
m_bold = new FontAttribPropItem(object, objects, "bold", tr("bold"),
|
||||
propertyValue().value<QFont>().bold(), this, false);
|
||||
m_italic = new FontAttribPropItem(object, objects, "italic", tr("italic"),
|
||||
propertyValue().value<QFont>().italic(), this, false);
|
||||
m_underline = new FontAttribPropItem(object, objects, "underline", tr("underline"),
|
||||
propertyValue().value<QFont>().underline(), this, false);
|
||||
m_pointSize
|
||||
= new FontPointSizePropItem(object, 0, "pointSize", tr("size"),
|
||||
propertyValue().value<QFont>().pointSize(), this, false);
|
||||
m_family = new FontFamilyPropItem(object, 0, "family", tr("family"),
|
||||
propertyValue().value<QFont>(), this, false);
|
||||
|
||||
this->appendItem(m_family);
|
||||
this->appendItem(m_pointSize);
|
||||
@@ -64,23 +77,24 @@ FontPropItem::FontPropItem(QObject *object, ObjectPropItem::ObjectsList *objects
|
||||
this->appendItem(m_underline);
|
||||
}
|
||||
|
||||
QWidget *FontPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new FontEditor(parent);
|
||||
}
|
||||
QWidget* FontPropItem::createProperyEditor(QWidget* parent) const { return new FontEditor(parent); }
|
||||
|
||||
QString FontPropItem::displayValue() const
|
||||
{
|
||||
return toString(propertyValue().value<QFont>());//propertyValue().toString();//toString(propertyValue().value<QFont>());
|
||||
return toString(
|
||||
propertyValue()
|
||||
.value<
|
||||
QFont>()); // propertyValue().toString();//toString(propertyValue().value<QFont>());
|
||||
}
|
||||
|
||||
void FontPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex &) const
|
||||
void FontPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
FontEditor *editor =qobject_cast<FontEditor*>(propertyEditor);
|
||||
FontEditor* editor = qobject_cast<FontEditor*>(propertyEditor);
|
||||
editor->setFontValue(propertyValue().value<QFont>());
|
||||
}
|
||||
|
||||
void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex &index)
|
||||
void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
|
||||
QFont tmpFont = qobject_cast<FontEditor*>(propertyEditor)->fontValue();
|
||||
@@ -89,8 +103,8 @@ void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* mod
|
||||
font.setPointSize(tmpFont.pointSize());
|
||||
font.setItalic(tmpFont.italic());
|
||||
font.setUnderline(tmpFont.underline());
|
||||
model->setData(index,font);
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
model->setData(index, font);
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
void FontPropItem::setPropertyValue(QVariant value)
|
||||
@@ -105,11 +119,14 @@ void FontPropItem::setPropertyValue(QVariant value)
|
||||
|
||||
QString FontPropItem::toString(QFont value) const
|
||||
{
|
||||
QString attribs="";
|
||||
if (value.bold()) (attribs=="") ? attribs+="b":attribs+=",b";
|
||||
if (value.italic()) (attribs=="") ? attribs+="i":attribs+=",i";
|
||||
if (attribs!="") attribs="["+attribs+"]";
|
||||
return "\""+ value.family()+"\" "+QString::number(value.pointSize())+" "+attribs;
|
||||
QString attribs = "";
|
||||
if (value.bold())
|
||||
(attribs == "") ? attribs += "b" : attribs += ",b";
|
||||
if (value.italic())
|
||||
(attribs == "") ? attribs += "i" : attribs += ",i";
|
||||
if (attribs != "")
|
||||
attribs = "[" + attribs + "]";
|
||||
return "\"" + value.family() + "\" " + QString::number(value.pointSize()) + " " + attribs;
|
||||
}
|
||||
|
||||
QString FontFamilyPropItem::displayValue() const
|
||||
@@ -118,71 +135,70 @@ QString FontFamilyPropItem::displayValue() const
|
||||
return font.family();
|
||||
}
|
||||
|
||||
QWidget *FontFamilyPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* FontFamilyPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
FontFamilyEditor* editor = new FontFamilyEditor(parent);
|
||||
// QFontComboBox* editor = new QFontComboBox(parent);
|
||||
// QFontComboBox* editor = new QFontComboBox(parent);
|
||||
editor->setAutoFillBackground(true);
|
||||
editor->setFont(propertyValue().value<QFont>());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void FontFamilyPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void FontFamilyPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
FontFamilyEditor* editor = qobject_cast<FontFamilyEditor*>(propertyEditor);
|
||||
// QFontComboBox* editor = qobject_cast<QFontComboBox*>(propertyEditor);
|
||||
// QFontComboBox* editor = qobject_cast<QFontComboBox*>(propertyEditor);
|
||||
editor->setFont(propertyValue().value<QFont>());
|
||||
}
|
||||
|
||||
void FontFamilyPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void FontFamilyPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
// font.setFamily(qobject_cast<QFontComboBox*>(propertyEditor)->currentFont().family());
|
||||
// font.setFamily(qobject_cast<QFontComboBox*>(propertyEditor)->currentFont().family());
|
||||
font.setFamily(qobject_cast<FontFamilyEditor*>(propertyEditor)->currentFont().family());
|
||||
model->setData(index,font);
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
model->setData(index, font);
|
||||
setValueToObject(parent()->propertyName(), font);
|
||||
}
|
||||
|
||||
void FontAttribPropItem::setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index)
|
||||
void FontAttribPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
model->setData(index, qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
if (propertyName()=="bold"){
|
||||
if (propertyName() == "bold") {
|
||||
font.setBold(propertyValue().toBool());
|
||||
}
|
||||
if (propertyName()=="italic"){
|
||||
if (propertyName() == "italic") {
|
||||
font.setItalic(propertyValue().toBool());
|
||||
}
|
||||
if (propertyName()=="underline"){
|
||||
if (propertyName() == "underline") {
|
||||
font.setUnderline(propertyValue().toBool());
|
||||
}
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
setValueToObject(parent()->propertyName(), font);
|
||||
}
|
||||
|
||||
void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void FontPointSizePropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
|
||||
model->setData(index, qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
font.setPointSize(propertyValue().toInt());
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
setValueToObject(parent()->propertyName(), font);
|
||||
}
|
||||
|
||||
FontFamilyEditor::FontFamilyEditor(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
FontFamilyEditor::FontFamilyEditor(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
m_valueEditor = new QFontComboBox(this);
|
||||
setFocusProxy(m_valueEditor);
|
||||
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
||||
hLayout->addWidget(m_valueEditor);
|
||||
hLayout->setContentsMargins(1,1,1,1);
|
||||
hLayout->setContentsMargins(1, 1, 1, 1);
|
||||
hLayout->setSpacing(0);
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
QFont FontFamilyEditor::currentFont()
|
||||
{
|
||||
return m_valueEditor->currentFont();
|
||||
}
|
||||
QFont FontFamilyEditor::currentFont() { return m_valueEditor->currentFont(); }
|
||||
|
||||
void FontFamilyEditor::setFont(QFont font)
|
||||
{
|
||||
@@ -190,4 +206,4 @@ void FontFamilyEditor::setFont(QFont font)
|
||||
m_valueEditor->setFont(font);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -30,15 +30,15 @@
|
||||
#ifndef LRFONTPROPITEM_H
|
||||
#define LRFONTPROPITEM_H
|
||||
|
||||
#include <QFontComboBox>
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
#include "lrintpropitem.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
#include <QFontComboBox>
|
||||
|
||||
class FontFamilyEditor : public QWidget{
|
||||
namespace LimeReport {
|
||||
|
||||
class FontFamilyEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontFamilyEditor(QWidget* parent);
|
||||
@@ -46,62 +46,82 @@ public:
|
||||
void setFont(QFont font);
|
||||
signals:
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
QFontComboBox* m_valueEditor;
|
||||
};
|
||||
|
||||
class FontFamilyPropItem : public ObjectPropItem
|
||||
{
|
||||
class FontFamilyPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontFamilyPropItem():ObjectPropItem(){}
|
||||
FontFamilyPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly=true)
|
||||
:ObjectPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
FontFamilyPropItem(): ObjectPropItem() { }
|
||||
FontFamilyPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
}
|
||||
QString displayValue() const;
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index);
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
class FontPointSizePropItem : public IntPropItem
|
||||
{
|
||||
class FontPointSizePropItem: public IntPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontPointSizePropItem():IntPropItem(){}
|
||||
FontPointSizePropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly=true)
|
||||
:IntPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
void setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index);
|
||||
FontPointSizePropItem(): IntPropItem() { }
|
||||
FontPointSizePropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true):
|
||||
IntPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
}
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
class FontAttribPropItem : public BoolPropItem
|
||||
{
|
||||
class FontAttribPropItem: public BoolPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontAttribPropItem():BoolPropItem(){}
|
||||
FontAttribPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly=true)
|
||||
:BoolPropItem(object, objects, name, displayName, value, parent, readonly){}
|
||||
void setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index);
|
||||
FontAttribPropItem(): BoolPropItem() { }
|
||||
FontAttribPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true):
|
||||
BoolPropItem(object, objects, name, displayName, value, parent, readonly)
|
||||
{
|
||||
}
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
class FontPropItem : public ObjectPropItem
|
||||
{
|
||||
class FontPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontPropItem():ObjectPropItem(), m_pointSize(NULL), m_bold(NULL), m_italic(NULL), m_underline(NULL), m_family(NULL) {}
|
||||
FontPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly);
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
FontPropItem():
|
||||
ObjectPropItem(),
|
||||
m_pointSize(NULL),
|
||||
m_bold(NULL),
|
||||
m_italic(NULL),
|
||||
m_underline(NULL),
|
||||
m_family(NULL)
|
||||
{
|
||||
}
|
||||
FontPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
void setPropertyValue(QVariant value);
|
||||
|
||||
protected:
|
||||
QString toString(QFont value) const;
|
||||
FontPointSizePropItem* m_pointSize;
|
||||
FontAttribPropItem *m_bold;
|
||||
FontAttribPropItem *m_italic;
|
||||
FontAttribPropItem *m_underline;
|
||||
FontFamilyPropItem *m_family;
|
||||
FontAttribPropItem* m_bold;
|
||||
FontAttribPropItem* m_italic;
|
||||
FontAttribPropItem* m_underline;
|
||||
FontFamilyPropItem* m_family;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRFONTPROPITEM_H
|
||||
|
||||
@@ -28,55 +28,66 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrgroupfieldpropitem.h"
|
||||
|
||||
#include "../editors/lrcomboboxeditor.h"
|
||||
#include "lrgroupbands.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createFieldPropItem(QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly){
|
||||
return new LimeReport::GroupFieldPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredGroupFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("groupFieldName","LimeReport::GroupBandHeader"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createFieldPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::GroupFieldPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredGroupFieldProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("groupFieldName", "LimeReport::GroupBandHeader"),
|
||||
QObject::tr("field"), createFieldPropItem);
|
||||
} // namespace
|
||||
namespace LimeReport {
|
||||
|
||||
|
||||
QString findDatasourceName(BandDesignIntf* band){
|
||||
if (!band) return "";
|
||||
if (!band->datasourceName().isEmpty()) return band->datasourceName();
|
||||
else return findDatasourceName(band->parentBand());
|
||||
QString findDatasourceName(BandDesignIntf* band)
|
||||
{
|
||||
if (!band)
|
||||
return "";
|
||||
if (!band->datasourceName().isEmpty())
|
||||
return band->datasourceName();
|
||||
else
|
||||
return findDatasourceName(band->parentBand());
|
||||
}
|
||||
|
||||
QWidget *GroupFieldPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* GroupFieldPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent,true);
|
||||
ComboBoxEditor* editor = new ComboBoxEditor(parent, true);
|
||||
editor->setEditable(true);
|
||||
GroupBandHeader *item=dynamic_cast<GroupBandHeader*>(object());
|
||||
if (item){
|
||||
GroupBandHeader* item = dynamic_cast<GroupBandHeader*>(object());
|
||||
if (item) {
|
||||
BandDesignIntf* dataBand = dynamic_cast<BandDesignIntf*>(item->parentBand());
|
||||
if (dataBand){
|
||||
if (dataBand) {
|
||||
QString datasourceName = findDatasourceName(dataBand);
|
||||
if (!datasourceName.isEmpty()){
|
||||
editor->addItems(item->reportEditor()->dataManager()->fieldNames(datasourceName));
|
||||
if (!datasourceName.isEmpty()) {
|
||||
editor->addItems(item->reportEditor()->dataManager()->fieldNames(datasourceName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void GroupFieldPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void GroupFieldPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
ComboBoxEditor* editor = qobject_cast<ComboBoxEditor*>(propertyEditor);
|
||||
editor->setTextValue(propertyValue().toString());
|
||||
}
|
||||
|
||||
void GroupFieldPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void GroupFieldPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
|
||||
model->setData(index, qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,19 +31,21 @@
|
||||
#define LRGROUPFIELDPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class GroupFieldPropItem : public ObjectPropItem
|
||||
{
|
||||
class GroupFieldPropItem: public ObjectPropItem {
|
||||
public:
|
||||
GroupFieldPropItem(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;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
GroupFieldPropItem(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;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRGROUPFIELDPROPITEM_H
|
||||
|
||||
@@ -28,20 +28,27 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrimagepropitem.h"
|
||||
|
||||
#include "editors/lrimageeditor.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createImagePropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ImagePropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredImageProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QImage",""),QObject::tr("QImage"),createImagePropItem);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createImagePropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::ImagePropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredImageProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QImage", ""), QObject::tr("QImage"), createImagePropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget* ImagePropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* ImagePropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new ImageEditor(parent);
|
||||
}
|
||||
@@ -51,16 +58,17 @@ QString ImagePropItem::displayValue() const
|
||||
return (propertyValue().isNull()) ? "" : QObject::tr("image");
|
||||
}
|
||||
|
||||
void ImagePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
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>());
|
||||
}
|
||||
|
||||
void ImagePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void ImagePropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ImageEditor*>(propertyEditor)->image());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
model->setData(index, qobject_cast<ImageEditor*>(propertyEditor)->image());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
QIcon ImagePropItem::iconValue() const
|
||||
@@ -68,4 +76,4 @@ QIcon ImagePropItem::iconValue() const
|
||||
return QIcon(QPixmap::fromImage(propertyValue().value<QImage>()));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,21 +31,24 @@
|
||||
#define LRIMAGEPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class ImagePropItem : public ObjectPropItem
|
||||
{
|
||||
class ImagePropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ImagePropItem():ObjectPropItem(){}
|
||||
ImagePropItem(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;
|
||||
ImagePropItem(): ObjectPropItem() { }
|
||||
ImagePropItem(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;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
virtual QIcon iconValue() const;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRIMAGEPROPITEM_H
|
||||
|
||||
@@ -28,56 +28,62 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrintpropitem.h"
|
||||
#include <limits>
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createIntPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::IntPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem);
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createIntPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::IntPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("int", ""), QObject::tr("int"), createIntPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *IntPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* IntPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
// QWidget* base = new QWidget(parent);
|
||||
// QHBoxLayout* layout = new QHBoxLayout();
|
||||
// base->setLayout(layout);
|
||||
// QWidget* base = new QWidget(parent);
|
||||
// QHBoxLayout* layout = new QHBoxLayout();
|
||||
// base->setLayout(layout);
|
||||
|
||||
// QSpinBox *editor = new QSpinBox(parent);
|
||||
// editor->setMaximum(std::numeric_limits<int>::max());
|
||||
// editor->setMinimum(std::numeric_limits<int>::min());
|
||||
// QSpinBox *editor = new QSpinBox(parent);
|
||||
// editor->setMaximum(std::numeric_limits<int>::max());
|
||||
// editor->setMinimum(std::numeric_limits<int>::min());
|
||||
|
||||
// layout->addWidget(editor);
|
||||
// layout->addWidget(editor);
|
||||
return new SpinBoxEditor(parent);
|
||||
}
|
||||
|
||||
void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void IntPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
SpinBoxEditor *editor =qobject_cast<SpinBoxEditor *>(propertyEditor);
|
||||
SpinBoxEditor* editor = qobject_cast<SpinBoxEditor*>(propertyEditor);
|
||||
editor->setValue(propertyValue().toInt());
|
||||
}
|
||||
|
||||
void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void IntPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
if (objects()){
|
||||
foreach(QObject* item, *objects()){
|
||||
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){
|
||||
item->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
model->setData(index, qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
if (objects()) {
|
||||
foreach (QObject* item, *objects()) {
|
||||
if (item->metaObject()->indexOfProperty(propertyName().toLatin1()) != -1) {
|
||||
item->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpinBoxEditor::SpinBoxEditor(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
SpinBoxEditor::SpinBoxEditor(QWidget* parent): QWidget(parent)
|
||||
{
|
||||
m_valueEditor = new QSpinBox(this);
|
||||
m_valueEditor->setMinimum(std::numeric_limits<int>::min());
|
||||
@@ -85,20 +91,14 @@ SpinBoxEditor::SpinBoxEditor(QWidget *parent)
|
||||
setFocusProxy(m_valueEditor);
|
||||
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
||||
hLayout->addWidget(m_valueEditor);
|
||||
hLayout->setContentsMargins(1,1,1,1);
|
||||
hLayout->setContentsMargins(1, 1, 1, 1);
|
||||
hLayout->setSpacing(0);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_valueEditor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||
}
|
||||
|
||||
int SpinBoxEditor::value()
|
||||
{
|
||||
return m_valueEditor->value();
|
||||
}
|
||||
int SpinBoxEditor::value() { return m_valueEditor->value(); }
|
||||
|
||||
void SpinBoxEditor::setValue(int value)
|
||||
{
|
||||
m_valueEditor->setValue(value);
|
||||
}
|
||||
void SpinBoxEditor::setValue(int value) { m_valueEditor->setValue(value); }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
#define LRINTPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class SpinBoxEditor : public QWidget{
|
||||
class SpinBoxEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SpinBoxEditor(QWidget* parent);
|
||||
@@ -43,20 +44,24 @@ public:
|
||||
void setValue(int value);
|
||||
signals:
|
||||
void editingFinished();
|
||||
|
||||
private:
|
||||
QSpinBox* m_valueEditor;
|
||||
};
|
||||
|
||||
class IntPropItem : public ObjectPropItem
|
||||
{
|
||||
class IntPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntPropItem():ObjectPropItem(){}
|
||||
IntPropItem(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;
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
IntPropItem(): ObjectPropItem() { }
|
||||
IntPropItem(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;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,68 +1,77 @@
|
||||
#include "lrmarginpropitem.h"
|
||||
#include <QDoubleSpinBox>
|
||||
#include <limits>
|
||||
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem * createMarginPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::MarginPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredTopMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("topMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredRightMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("rightMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredBottomMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("bottomMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredLeftMargin = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("leftMargin","LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"),createMarginPropItem
|
||||
);
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createMarginPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::MarginPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredTopMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("topMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRightMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("rightMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredBottomMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("bottomMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredLeftMargin
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("leftMargin", "LimeReport::PageItemDesignIntf"),
|
||||
QObject::tr("margin"), createMarginPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QString MarginPropItem::displayValue() const
|
||||
{
|
||||
LimeReport::BaseDesignIntf * item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<LimeReport::BaseDesignIntf*>(object());
|
||||
switch (item->unitType()) {
|
||||
case LimeReport::BaseDesignIntf::Millimeters:
|
||||
|
||||
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2)
|
||||
.arg(QObject::tr("mm"));
|
||||
return QString("%1 %2").arg(propertyValue().toDouble(), 0, 'f', 2).arg(QObject::tr("mm"));
|
||||
case LimeReport::BaseDesignIntf::Inches:
|
||||
return QString("%1 %2").arg((propertyValue().toDouble() * Const::mmFACTOR) / (item->unitFactor() * 10), 0, 'f', 2)
|
||||
.arg(QObject::tr("''"));
|
||||
return QString("%1 %2")
|
||||
.arg((propertyValue().toDouble() * Const::mmFACTOR) / (item->unitFactor() * 10), 0, 'f',
|
||||
2)
|
||||
.arg(QObject::tr("''"));
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QWidget *MarginPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* MarginPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
QDoubleSpinBox* editor = new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(std::numeric_limits<qreal>::max());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max()*-1);
|
||||
editor->setSuffix(" "+unitShortName());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max() * -1);
|
||||
editor->setSuffix(" " + unitShortName());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void MarginPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void MarginPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
QDoubleSpinBox *editor =qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
QDoubleSpinBox* editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(valueInUnits(propertyValue().toReal()));
|
||||
}
|
||||
|
||||
void MarginPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void MarginPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index, valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
model->setData(index,
|
||||
valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,17 +5,21 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class MarginPropItem : public ObjectPropItem
|
||||
{
|
||||
class MarginPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MarginPropItem():ObjectPropItem(){}
|
||||
MarginPropItem(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){}
|
||||
MarginPropItem(): ObjectPropItem() { }
|
||||
MarginPropItem(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)
|
||||
{
|
||||
}
|
||||
QString displayValue() const;
|
||||
QWidget* createProperyEditor(QWidget *parent) const;
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
QWidget* createProperyEditor(QWidget* parent) const;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
|
||||
private:
|
||||
qreal valueInUnits(qreal value) const;
|
||||
qreal valueInReportUnits(qreal value) const;
|
||||
@@ -24,5 +28,4 @@ private:
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
#endif // LRMARGINPROPITEM_H
|
||||
|
||||
@@ -30,39 +30,48 @@
|
||||
#include "lrqrealpropitem.h"
|
||||
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createQRealPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::QRealPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("qreal",""),QObject::tr("qreal"),createQRealPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredDouble = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("double",""),QObject::tr("qreal"),createQRealPropItem);
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createQRealPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::QRealPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
bool VARIABLE_IS_NOT_USED registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("qreal", ""), QObject::tr("qreal"), createQRealPropItem);
|
||||
bool VARIABLE_IS_NOT_USED registredDouble
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("double", ""), QObject::tr("qreal"), createQRealPropItem);
|
||||
} // namespace
|
||||
|
||||
QWidget *QRealPropItem::createProperyEditor(QWidget *parent) const
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget* QRealPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
QDoubleSpinBox* editor = new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(std::numeric_limits<qreal>::max());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max()*-1);
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max() * -1);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void QRealPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void QRealPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
QDoubleSpinBox *editor =qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
QDoubleSpinBox* editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(propertyValue().toDouble());
|
||||
}
|
||||
|
||||
void QRealPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void QRealPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QDoubleSpinBox*>(propertyEditor)->value());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
model->setData(index, qobject_cast<QDoubleSpinBox*>(propertyEditor)->value());
|
||||
setValueToObject(propertyName(), propertyValue());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -34,17 +34,20 @@
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class QRealPropItem : public ObjectPropItem
|
||||
{
|
||||
class QRealPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QRealPropItem():ObjectPropItem(){}
|
||||
QRealPropItem(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;
|
||||
void setPropertyEditorData(QWidget * propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget * propertyEditor, QAbstractItemModel * model, const QModelIndex & index);
|
||||
QRealPropItem(): ObjectPropItem() { }
|
||||
QRealPropItem(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;
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRQREALPROPITEM_H
|
||||
|
||||
@@ -28,150 +28,213 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrrectproptem.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QRect>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QDebug>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QRect>
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createReqtItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
|
||||
){
|
||||
return new LimeReport::RectPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
LimeReport::ObjectPropItem * createReqtUnitItem(
|
||||
QObject*object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
|
||||
){
|
||||
return new LimeReport::RectUnitPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredRectProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QRect",""),QObject::tr("QRect"),createReqtItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRectFProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QRectF",""),QObject::tr("QRectF"),createReqtItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRectMMProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("geometry","LimeReport::BaseDesignIntf"),QObject::tr("geometry"),createReqtUnitItem);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
template<class T> QString rectToString(T rect)
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createReqtItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data, LimeReport::ObjectPropItem* parent,
|
||||
bool readonly)
|
||||
{
|
||||
return QString("[%1,%2] %3x%4").arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
|
||||
return new LimeReport::RectPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
LimeReport::ObjectPropItem* createReqtUnitItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::RectUnitPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredRectProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QRect", ""), QObject::tr("QRect"), createReqtItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRectFProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QRectF", ""), QObject::tr("QRectF"), createReqtItem);
|
||||
bool VARIABLE_IS_NOT_USED registredRectMMProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("geometry", "LimeReport::BaseDesignIntf"), QObject::tr("geometry"),
|
||||
createReqtUnitItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
template <class T> QString rectToString(T rect)
|
||||
{
|
||||
return QString("[%1,%2] %3x%4")
|
||||
.arg(rect.x())
|
||||
.arg(rect.y())
|
||||
.arg(rect.width())
|
||||
.arg(rect.height());
|
||||
}
|
||||
|
||||
QRectF modifyRect(QRectF rect, const QString& name, qreal itemValue){
|
||||
if (name=="x"){qreal width=rect.width(); rect.setX(itemValue); rect.setWidth(width);}
|
||||
if (name=="y"){qreal heigh=rect.height(); rect.setY(itemValue); rect.setHeight(heigh);}
|
||||
if (name=="height"){rect.setHeight(itemValue);}
|
||||
if (name=="width"){rect.setWidth(itemValue);}
|
||||
QRectF modifyRect(QRectF rect, const QString& name, qreal itemValue)
|
||||
{
|
||||
if (name == "x") {
|
||||
qreal width = rect.width();
|
||||
rect.setX(itemValue);
|
||||
rect.setWidth(width);
|
||||
}
|
||||
if (name == "y") {
|
||||
qreal heigh = rect.height();
|
||||
rect.setY(itemValue);
|
||||
rect.setHeight(heigh);
|
||||
}
|
||||
if (name == "height") {
|
||||
rect.setHeight(itemValue);
|
||||
}
|
||||
if (name == "width") {
|
||||
rect.setWidth(itemValue);
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
LimeReport::RectPropItem::RectPropItem(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)
|
||||
LimeReport::RectPropItem::RectPropItem(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)
|
||||
{
|
||||
QRect rect=value.toRect();
|
||||
this->appendItem(new ObjectPropItem(object, objects, "x","x", rect.x(),this));
|
||||
this->appendItem(new ObjectPropItem(object, objects, "y","x", rect.y(),this));
|
||||
this->appendItem(new ObjectPropItem(object, objects, "width",tr("width"), rect.width(),this));
|
||||
this->appendItem(new ObjectPropItem(object, objects, "heigh",tr("height"),rect.height(),this));
|
||||
QRect rect = value.toRect();
|
||||
this->appendItem(new ObjectPropItem(object, objects, "x", "x", rect.x(), this));
|
||||
this->appendItem(new ObjectPropItem(object, objects, "y", "x", rect.y(), this));
|
||||
this->appendItem(new ObjectPropItem(object, objects, "width", tr("width"), rect.width(), this));
|
||||
this->appendItem(
|
||||
new ObjectPropItem(object, objects, "heigh", tr("height"), rect.height(), this));
|
||||
}
|
||||
|
||||
QString LimeReport::RectPropItem::displayValue() const
|
||||
{
|
||||
//TODO: Migrate to QMetaType
|
||||
// TODO: Migrate to QMetaType
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
switch(propertyValue().typeId()){
|
||||
case QMetaType::QRect:
|
||||
return rectToString(propertyValue().toRect());
|
||||
case QMetaType::QRectF:
|
||||
return rectToString(propertyValue().toRect());
|
||||
default :
|
||||
return ObjectPropItem::displayValue();
|
||||
switch (propertyValue().typeId()) {
|
||||
case QMetaType::QRect:
|
||||
return rectToString(propertyValue().toRect());
|
||||
case QMetaType::QRectF:
|
||||
return rectToString(propertyValue().toRect());
|
||||
default:
|
||||
return ObjectPropItem::displayValue();
|
||||
}
|
||||
#else
|
||||
switch(propertyValue().type()){
|
||||
case QVariant::Rect:
|
||||
return rectToString(propertyValue().toRect());
|
||||
case QVariant::RectF:
|
||||
return rectToString(propertyValue().toRect());
|
||||
default :
|
||||
return ObjectPropItem::displayValue();
|
||||
switch (propertyValue().type()) {
|
||||
case QVariant::Rect:
|
||||
return rectToString(propertyValue().toRect());
|
||||
case QVariant::RectF:
|
||||
return rectToString(propertyValue().toRect());
|
||||
default:
|
||||
return ObjectPropItem::displayValue();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
LimeReport::RectUnitPropItem::RectUnitPropItem(QObject *object, ObjectsList* objects, const QString &name, const QString &displayName, const QVariant &value, ObjectPropItem *parent, bool /*readonly*/):
|
||||
ObjectPropItem(object, objects, name, displayName, value,parent)
|
||||
LimeReport::RectUnitPropItem::RectUnitPropItem(QObject* object, ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& value, ObjectPropItem* parent,
|
||||
bool /*readonly*/):
|
||||
ObjectPropItem(object, objects, name, displayName, value, parent)
|
||||
{
|
||||
QRectF rect= value.toRect();
|
||||
QRectF rect = value.toRect();
|
||||
LimeReport::BandDesignIntf* band = dynamic_cast<LimeReport::BandDesignIntf*>(object);
|
||||
LimeReport::PageItemDesignIntf* page = dynamic_cast<LimeReport::PageItemDesignIntf*>(object);
|
||||
LimeReport::BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(object);
|
||||
|
||||
if (band){
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "x", "x", rect.x(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "y", "y", rect.y(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "width", tr("width"), rect.width(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "height", tr("height"), rect.height(), this, false));
|
||||
} else if (page){
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0, "x", "x", rect.x(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0, "y", "y",rect.y(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0,"width", tr("width"), rect.width(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0, "height", tr("height"), rect.height(), this, false));
|
||||
if (band) {
|
||||
this->appendItem(
|
||||
new LimeReport::RectUnitValuePropItem(object, objects, "x", "x", rect.x(), this, true));
|
||||
this->appendItem(
|
||||
new LimeReport::RectUnitValuePropItem(object, objects, "y", "y", rect.y(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(
|
||||
object, objects, "width", tr("width"), rect.width(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(
|
||||
object, objects, "height", tr("height"), rect.height(), this, false));
|
||||
} else if (page) {
|
||||
this->appendItem(
|
||||
new LimeReport::RectUnitValuePropItem(object, 0, "x", "x", rect.x(), this, true));
|
||||
this->appendItem(
|
||||
new LimeReport::RectUnitValuePropItem(object, 0, "y", "y", rect.y(), this, true));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0, "width", tr("width"),
|
||||
rect.width(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, 0, "height", tr("height"),
|
||||
rect.height(), this, false));
|
||||
} else {
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "x", "x", rect.x(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "y", "y", rect.y(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "width", tr("width"), rect.width(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "height", tr("height"), rect.height(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "x", "x", rect.x(),
|
||||
this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(object, objects, "y", "y", rect.y(),
|
||||
this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(
|
||||
object, objects, "width", tr("width"), rect.width(), this, false));
|
||||
this->appendItem(new LimeReport::RectUnitValuePropItem(
|
||||
object, objects, "height", tr("height"), rect.height(), this, false));
|
||||
}
|
||||
|
||||
if (item){
|
||||
connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(itemGeometryChanged(QObject*,QRectF,QRectF)));
|
||||
connect(item,SIGNAL(posChanged(QObject*,QPointF,QPointF)),this,SLOT(itemPosChanged(QObject*,QPointF,QPointF)));
|
||||
connect(item,SIGNAL(posChanging(QObject*,QPointF,QPointF)),this,SLOT(itemPosChanged(QObject*,QPointF,QPointF)));
|
||||
if (item) {
|
||||
connect(item, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), this,
|
||||
SLOT(itemGeometryChanged(QObject*, QRectF, QRectF)));
|
||||
connect(item, SIGNAL(posChanged(QObject*, QPointF, QPointF)), this,
|
||||
SLOT(itemPosChanged(QObject*, QPointF, QPointF)));
|
||||
connect(item, SIGNAL(posChanging(QObject*, QPointF, QPointF)), this,
|
||||
SLOT(itemPosChanged(QObject*, QPointF, QPointF)));
|
||||
}
|
||||
|
||||
}
|
||||
QString LimeReport::RectUnitPropItem::displayValue() const
|
||||
{
|
||||
QRectF rect = rectInUnits(propertyValue().toRectF());
|
||||
return QString("[%1,%2] %3x%4 %5")
|
||||
.arg(rect.x(), 0, 'f', 2)
|
||||
.arg(rect.y(), 0,'f', 2)
|
||||
.arg(rect.width(), 0, 'f', 2)
|
||||
.arg(rect.height(), 0, 'f', 2)
|
||||
.arg(unitShortName());
|
||||
.arg(rect.x(), 0, 'f', 2)
|
||||
.arg(rect.y(), 0, 'f', 2)
|
||||
.arg(rect.width(), 0, 'f', 2)
|
||||
.arg(rect.height(), 0, 'f', 2)
|
||||
.arg(unitShortName());
|
||||
}
|
||||
|
||||
LimeReport::RectUnitValuePropItem::RectUnitValuePropItem(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 * LimeReport::RectUnitValuePropItem::createProperyEditor(QWidget *parent) const
|
||||
LimeReport::RectUnitValuePropItem::RectUnitValuePropItem(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)
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
}
|
||||
|
||||
QWidget* LimeReport::RectUnitValuePropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
QDoubleSpinBox* editor = new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(100000);
|
||||
editor->setSuffix(" "+unitShortName());
|
||||
editor->setSuffix(" " + unitShortName());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::RectUnitValuePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void LimeReport::RectUnitValuePropItem::setPropertyEditorData(QWidget* propertyEditor,
|
||||
const QModelIndex&) const
|
||||
{
|
||||
QDoubleSpinBox *editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
QDoubleSpinBox* editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(valueInUnits(propertyValue().toReal()));
|
||||
}
|
||||
|
||||
void LimeReport::RectUnitValuePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void LimeReport::RectUnitValuePropItem::setModelData(QWidget* propertyEditor,
|
||||
QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
QRectF rect=object()->property(parent()->propertyName().toLatin1()).toRectF();
|
||||
object()->setProperty(parent()->propertyName().toLatin1(), modifyRect(rect, propertyName(), propertyValue().toReal()));
|
||||
model->setData(index,
|
||||
valueInReportUnits(qobject_cast<QDoubleSpinBox*>(propertyEditor)->value()));
|
||||
QRectF rect = object()->property(parent()->propertyName().toLatin1()).toRectF();
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),
|
||||
modifyRect(rect, propertyName(), propertyValue().toReal()));
|
||||
}
|
||||
|
||||
qreal LimeReport::RectUnitValuePropItem::valueInUnits(qreal value) const
|
||||
@@ -212,43 +275,48 @@ QString LimeReport::RectUnitValuePropItem::unitShortName() const
|
||||
|
||||
QString LimeReport::RectUnitValuePropItem::displayValue() const
|
||||
{
|
||||
return QString("%1 %2").arg(valueInUnits(propertyValue().toReal()), 0, 'f', 2).arg(unitShortName());
|
||||
return QString("%1 %2")
|
||||
.arg(valueInUnits(propertyValue().toReal()), 0, 'f', 2)
|
||||
.arg(unitShortName());
|
||||
}
|
||||
|
||||
void LimeReport::RectUnitPropItem::itemPosChanged(QObject* /*object*/, QPointF newPos, QPointF oldPos)
|
||||
void LimeReport::RectUnitPropItem::itemPosChanged(QObject* /*object*/, QPointF newPos,
|
||||
QPointF oldPos)
|
||||
{
|
||||
if (newPos.x() != oldPos.x()){
|
||||
if (newPos.x() != oldPos.x()) {
|
||||
setValue("x", newPos.x());
|
||||
}
|
||||
if (newPos.y() != oldPos.y()){
|
||||
if (newPos.y() != oldPos.y()) {
|
||||
setValue("y", newPos.y());
|
||||
}
|
||||
}
|
||||
|
||||
void LimeReport::RectUnitPropItem::itemGeometryChanged(QObject * /*object*/, QRectF newGeometry, QRectF oldGeometry)
|
||||
void LimeReport::RectUnitPropItem::itemGeometryChanged(QObject* /*object*/, QRectF newGeometry,
|
||||
QRectF oldGeometry)
|
||||
{
|
||||
if (newGeometry.x() != oldGeometry.x()){
|
||||
if (newGeometry.x() != oldGeometry.x()) {
|
||||
setValue("x", newGeometry.x());
|
||||
}
|
||||
if (newGeometry.y() != oldGeometry.y()){
|
||||
if (newGeometry.y() != oldGeometry.y()) {
|
||||
setValue("y", newGeometry.y());
|
||||
}
|
||||
if (newGeometry.width() != oldGeometry.width()){
|
||||
if (newGeometry.width() != oldGeometry.width()) {
|
||||
setValue("width", newGeometry.width());
|
||||
}
|
||||
if (newGeometry.height() != oldGeometry.height()){
|
||||
if (newGeometry.height() != oldGeometry.height()) {
|
||||
setValue("height", newGeometry.height());
|
||||
}
|
||||
}
|
||||
|
||||
void LimeReport::RectUnitPropItem::setValue(const QString &name, qreal value)
|
||||
void LimeReport::RectUnitPropItem::setValue(const QString& name, qreal value)
|
||||
{
|
||||
if (name != ""){
|
||||
if (name != "") {
|
||||
LimeReport::ObjectPropItem* propItem = findChild(name);
|
||||
if (propItem) {
|
||||
propItem->setPropertyValue(value);
|
||||
setPropertyValue(LimeReport::modifyRect(propertyValue().toRectF(), name, value));
|
||||
LimeReport::QObjectPropertyModel *itemModel = dynamic_cast<LimeReport::QObjectPropertyModel *>(model());
|
||||
LimeReport::QObjectPropertyModel* itemModel
|
||||
= dynamic_cast<LimeReport::QObjectPropertyModel*>(model());
|
||||
if (itemModel) {
|
||||
itemModel->itemDataChanged(modelIndex());
|
||||
if (propItem->modelIndex().isValid())
|
||||
@@ -263,13 +331,10 @@ QRectF LimeReport::RectUnitPropItem::rectInUnits(QRectF rect) const
|
||||
BaseDesignIntf* item = dynamic_cast<BaseDesignIntf*>(object());
|
||||
switch (item->unitType()) {
|
||||
case LimeReport::BaseDesignIntf::Millimeters:
|
||||
return QRectF(rect.x() / item->unitFactor(),
|
||||
rect.y() / item->unitFactor(),
|
||||
rect.width() / item->unitFactor(),
|
||||
rect.height() / item->unitFactor());
|
||||
return QRectF(rect.x() / item->unitFactor(), rect.y() / item->unitFactor(),
|
||||
rect.width() / item->unitFactor(), rect.height() / item->unitFactor());
|
||||
case LimeReport::BaseDesignIntf::Inches:
|
||||
return QRectF(rect.x() / (item->unitFactor() * 10),
|
||||
rect.y() / (item->unitFactor() * 10),
|
||||
return QRectF(rect.x() / (item->unitFactor() * 10), rect.y() / (item->unitFactor() * 10),
|
||||
rect.width() / (item->unitFactor() * 10),
|
||||
rect.height() / (item->unitFactor() * 10));
|
||||
}
|
||||
|
||||
@@ -30,49 +30,57 @@
|
||||
#ifndef LRRECTPROPTEM_H
|
||||
#define LRRECTPROPTEM_H
|
||||
#include "lrobjectpropitem.h"
|
||||
#include <QRectF>
|
||||
|
||||
#include <QMetaProperty>
|
||||
#include <QRectF>
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class RectPropItem : public ObjectPropItem{
|
||||
class RectPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RectPropItem():ObjectPropItem(){}
|
||||
RectPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true);
|
||||
RectPropItem(): ObjectPropItem() { }
|
||||
RectPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true);
|
||||
QString displayValue() const;
|
||||
};
|
||||
|
||||
class RectUnitPropItem : public ObjectPropItem{
|
||||
class RectUnitPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RectUnitPropItem():ObjectPropItem(){}
|
||||
RectUnitPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true);
|
||||
RectUnitPropItem(): ObjectPropItem() { }
|
||||
RectUnitPropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly = true);
|
||||
QString displayValue() const;
|
||||
public slots:
|
||||
void itemPosChanged(QObject* /*object*/, QPointF newPos, QPointF oldPos);
|
||||
void itemGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
|
||||
|
||||
private:
|
||||
void setValue(const QString& propertyName, qreal propertyValue);
|
||||
QRectF rectInUnits(QRectF rect) const;
|
||||
void setValue(const QString& propertyName, qreal propertyValue);
|
||||
QRectF rectInUnits(QRectF rect) const;
|
||||
QString unitShortName() const;
|
||||
};
|
||||
|
||||
class RectUnitValuePropItem : public ObjectPropItem{
|
||||
class RectUnitValuePropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RectUnitValuePropItem():ObjectPropItem(){}
|
||||
RectUnitValuePropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly );
|
||||
RectUnitValuePropItem(): ObjectPropItem() { }
|
||||
RectUnitValuePropItem(QObject* object, ObjectsList* objects, const QString& name,
|
||||
const QString& displayName, const QVariant& value, ObjectPropItem* parent,
|
||||
bool readonly);
|
||||
QString displayValue() const;
|
||||
QWidget* createProperyEditor(QWidget *) const;
|
||||
void setPropertyEditorData(QWidget *, const QModelIndex &) const;
|
||||
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
QWidget* createProperyEditor(QWidget*) const;
|
||||
void setPropertyEditorData(QWidget*, const QModelIndex&) const;
|
||||
void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&);
|
||||
|
||||
private:
|
||||
qreal valueInUnits(qreal value) const;
|
||||
qreal valueInReportUnits(qreal value) const;
|
||||
QString unitShortName() const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
#endif // LRRECTPROPTEM_H
|
||||
|
||||
@@ -6,39 +6,45 @@
|
||||
#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)
|
||||
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);
|
||||
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
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *SeriesPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* SeriesPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new SeriesPropEditor(qobject_cast<ChartItem*>(object()), parent);
|
||||
}
|
||||
|
||||
QString SeriesPropItem::displayValue() const
|
||||
{
|
||||
return QObject::tr("Series");
|
||||
}
|
||||
QString SeriesPropItem::displayValue() const { return QObject::tr("Series"); }
|
||||
|
||||
SeriesPropEditor::SeriesPropEditor(ChartItem *chart, QWidget *parent)
|
||||
: QWidget(parent), m_button(new QPushButton(this)), m_chart(chart)
|
||||
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);
|
||||
layout->setContentsMargins(1, 0, 1, 1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(m_button);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
connect(m_button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
}
|
||||
|
||||
void SeriesPropEditor::slotButtonClicked()
|
||||
@@ -47,5 +53,4 @@ void SeriesPropEditor::slotButtonClicked()
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -1,41 +1,42 @@
|
||||
#ifndef SERIESPROPITEM_H
|
||||
#define SERIESPROPITEM_H
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <lrobjectpropitem.h>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <lrchartitem.h>
|
||||
#include <lrobjectpropitem.h>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class SeriesPropEditor : public QWidget
|
||||
{
|
||||
class SeriesPropEditor: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SeriesPropEditor(ChartItem* chart, QWidget *parent = 0);
|
||||
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{
|
||||
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;
|
||||
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
|
||||
|
||||
@@ -27,46 +27,50 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
#include "lrstringpropitem.h"
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "objectinspector/editors/lrbuttonlineeditor.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createStringPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::StringPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredStringProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QString",""),QObject::tr("QString"),createStringPropItem);
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createStringPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::StringPropItem(object, objects, name, displayName, data, parent,
|
||||
readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredStringProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("QString", ""), QObject::tr("QString"), createStringPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
|
||||
QWidget * StringPropItem::createProperyEditor(QWidget *parent) const
|
||||
QWidget* StringPropItem::createProperyEditor(QWidget* parent) const
|
||||
{
|
||||
return new ButtonLineEditor(object()->objectName()+"."+displayName(),parent);
|
||||
return new ButtonLineEditor(object()->objectName() + "." + displayName(), parent);
|
||||
}
|
||||
|
||||
void StringPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) 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());
|
||||
}
|
||||
|
||||
void StringPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void StringPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ButtonLineEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
model->setData(index, qobject_cast<ButtonLineEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
QString StringPropItem::displayValue() const
|
||||
{
|
||||
return propertyValue().toString().simplified();
|
||||
}
|
||||
QString StringPropItem::displayValue() const { return propertyValue().toString().simplified(); }
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -31,17 +31,21 @@
|
||||
#define LRSTRINGPROPITEM_H
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class StringPropItem : public LimeReport::ObjectPropItem{
|
||||
namespace LimeReport {
|
||||
class StringPropItem: public LimeReport::ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
StringPropItem():ObjectPropItem(){}
|
||||
StringPropItem(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;
|
||||
StringPropItem(): ObjectPropItem() { }
|
||||
StringPropItem(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;
|
||||
void setPropertyEditorData(QWidget *, const QModelIndex &) const;
|
||||
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
void setPropertyEditorData(QWidget*, const QModelIndex&) const;
|
||||
void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&);
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // LRSTRINGPROPITEM_H
|
||||
|
||||
@@ -1,37 +1,42 @@
|
||||
#include "lrsvgpropitem.h"
|
||||
|
||||
#include "editors/lrsvgeditor.h"
|
||||
|
||||
namespace{
|
||||
LimeReport::ObjectPropItem * createSvgPropItem(
|
||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
namespace {
|
||||
LimeReport::ObjectPropItem* createSvgPropItem(QObject* object,
|
||||
LimeReport::ObjectPropItem::ObjectsList* objects,
|
||||
const QString& name, const QString& displayName,
|
||||
const QVariant& data,
|
||||
LimeReport::ObjectPropItem* parent, bool readonly)
|
||||
{
|
||||
return new LimeReport::SvgPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredImageProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("image","LimeReport::SVGItem"),QObject::tr("image"),createSvgPropItem);
|
||||
}
|
||||
bool VARIABLE_IS_NOT_USED registredImageProp
|
||||
= LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("image", "LimeReport::SVGItem"), QObject::tr("image"),
|
||||
createSvgPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget* SvgPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new SvgEditor(parent);
|
||||
}
|
||||
QWidget* SvgPropItem::createProperyEditor(QWidget* parent) const { return new SvgEditor(parent); }
|
||||
|
||||
QString SvgPropItem::displayValue() const
|
||||
{
|
||||
return (propertyValue().isNull()) ? "" : QObject::tr("image");
|
||||
}
|
||||
|
||||
void SvgPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
void SvgPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const
|
||||
{
|
||||
SvgEditor *editor = qobject_cast<SvgEditor*>(propertyEditor);
|
||||
SvgEditor* editor = qobject_cast<SvgEditor*>(propertyEditor);
|
||||
editor->setImage(propertyValue().value<QByteArray>());
|
||||
}
|
||||
|
||||
void SvgPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
void SvgPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model,
|
||||
const QModelIndex& index)
|
||||
{
|
||||
model->setData(index,qobject_cast<SvgEditor*>(propertyEditor)->image());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
model->setData(index, qobject_cast<SvgEditor*>(propertyEditor)->image());
|
||||
object()->setProperty(propertyName().toLatin1(), propertyValue());
|
||||
}
|
||||
|
||||
QIcon SvgPropItem::iconValue() const
|
||||
@@ -39,4 +44,4 @@ QIcon SvgPropItem::iconValue() const
|
||||
return QIcon(QPixmap::fromImage(propertyValue().value<QImage>()));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace LimeReport
|
||||
|
||||
@@ -2,19 +2,22 @@
|
||||
#define SVGPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
class SvgPropItem : public ObjectPropItem
|
||||
{
|
||||
class SvgPropItem: public ObjectPropItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SvgPropItem():ObjectPropItem(){}
|
||||
SvgPropItem(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;
|
||||
SvgPropItem(): ObjectPropItem() { }
|
||||
SvgPropItem(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;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
void setPropertyEditorData(QWidget* propertyEditor, const QModelIndex&) const;
|
||||
void setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex& index);
|
||||
virtual QIcon iconValue() const;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user