mirror of
https://github.com/fralx/LimeReport.git
synced 2025-09-23 08:29:07 +03:00
Change to subforder project model.
This commit is contained in:
136
limereport/objectinspector/editors/lrbuttonlineeditor.cpp
Normal file
136
limereport/objectinspector/editors/lrbuttonlineeditor.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbuttonlineeditor.h"
|
||||
#include <QMessageBox>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
#include <QDesktopWidget>
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ButtonLineEditor::ButtonLineEditor(const QString &propertyName, QWidget *parent) :
|
||||
QWidget(parent), m_overButton(false), m_propertyName(propertyName)
|
||||
{
|
||||
m_lineEdit = new QLineEdit(this);
|
||||
m_lineEdit->installEventFilter(this);
|
||||
setFocusProxy(m_lineEdit);
|
||||
m_buttonEdit = new QToolButton(this);
|
||||
m_buttonEdit->setText("...");
|
||||
m_buttonEdit->installEventFilter(this);
|
||||
m_buttonEdit->setAttribute(Qt::WA_Hover);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_lineEdit);
|
||||
layout->addWidget(m_buttonEdit);
|
||||
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()));
|
||||
}
|
||||
|
||||
ButtonLineEditor::~ButtonLineEditor(){}
|
||||
|
||||
void ButtonLineEditor::editButtonClicked()
|
||||
{
|
||||
TextItemPropertyEditor* editor = new TextItemPropertyEditor(QApplication::activeWindow());
|
||||
editor->setAttribute(Qt::WA_DeleteOnClose);
|
||||
editor->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, editor->size(), QApplication::desktop()->availableGeometry()));
|
||||
editor->setWindowTitle(m_propertyName);
|
||||
editor->setText(m_lineEdit->text());
|
||||
connect(editor,SIGNAL(accepted()),this,SLOT(editingByEditorFinished()));
|
||||
editor->exec();
|
||||
}
|
||||
|
||||
void ButtonLineEditor::setText(const QString &value){
|
||||
m_lineEdit->setText(value);
|
||||
}
|
||||
|
||||
QString ButtonLineEditor::text()
|
||||
{
|
||||
return m_lineEdit->text();
|
||||
}
|
||||
|
||||
bool ButtonLineEditor::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
|
||||
if (target==m_buttonEdit) {
|
||||
|
||||
if (event->type()==QEvent::HoverEnter){
|
||||
m_overButton=true;
|
||||
}
|
||||
if (event->type()==QEvent::HoverLeave){
|
||||
m_overButton=false;
|
||||
}
|
||||
if (event->type()==QEvent::FocusOut){
|
||||
if (static_cast<QFocusEvent*>(event)->reason()!=Qt::MouseFocusReason){
|
||||
m_lineEdit->setFocus();
|
||||
}
|
||||
}
|
||||
QSet<int> enterKeys;
|
||||
enterKeys.insert(Qt::Key_Enter);
|
||||
enterKeys.insert(Qt::Key_Return);
|
||||
|
||||
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()){
|
||||
case Qt::TabFocusReason:
|
||||
m_overButton=true;
|
||||
break;
|
||||
case Qt::MouseFocusReason:
|
||||
break;
|
||||
default:
|
||||
m_overButton=false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
|
||||
}
|
||||
|
||||
void ButtonLineEditor::editingByEditorFinished()
|
||||
{
|
||||
setText(qobject_cast<TextItemPropertyEditor*>(sender())->text());
|
||||
m_lineEdit->setFocus();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
70
limereport/objectinspector/editors/lrbuttonlineeditor.h
Normal file
70
limereport/objectinspector/editors/lrbuttonlineeditor.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRBUTTONLINEEDIT_H
|
||||
#define LRBUTTONLINEEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class ButtonLineEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ButtonLineEditor(const QString& propertyName,QWidget *parent = 0);
|
||||
~ButtonLineEditor();
|
||||
void setText(const QString &value);
|
||||
QString text();
|
||||
signals:
|
||||
void editingFinished();
|
||||
public slots:
|
||||
virtual void editButtonClicked();
|
||||
void editingByEditorFinished();
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
#endif // LRBUTTONLINEEDIT_H
|
115
limereport/objectinspector/editors/lrcheckboxeditor.cpp
Normal file
115
limereport/objectinspector/editors/lrcheckboxeditor.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcheckboxeditor.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QVBoxLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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)
|
||||
{
|
||||
m_checkBox = new QCheckBox(text,this);
|
||||
init();
|
||||
}
|
||||
|
||||
CheckBoxEditor::~CheckBoxEditor(){}
|
||||
|
||||
void CheckBoxEditor::init()
|
||||
{
|
||||
QVBoxLayout *layout=new QVBoxLayout(this);
|
||||
layout->addStretch();
|
||||
layout->addWidget(m_checkBox);
|
||||
m_checkBox->setFocusPolicy(Qt::NoFocus);
|
||||
connect(m_checkBox, SIGNAL(stateChanged(int)), this, SLOT(slotStateChanged(int)));
|
||||
layout->addStretch();
|
||||
layout->setContentsMargins(2,1,1,1);
|
||||
layout->setSpacing(0);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::setEditing(bool value)
|
||||
{
|
||||
m_editing=value;
|
||||
}
|
||||
|
||||
void CheckBoxEditor::setChecked(bool value)
|
||||
{
|
||||
m_checkBox->setChecked(value);
|
||||
}
|
||||
|
||||
bool CheckBoxEditor::isChecked()
|
||||
{
|
||||
return m_checkBox->isChecked();
|
||||
}
|
||||
|
||||
void CheckBoxEditor::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
m_checkBox->setChecked(!m_checkBox->isChecked());
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
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)){
|
||||
emit editingFinished();
|
||||
}
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::showEvent(QShowEvent *)
|
||||
{
|
||||
int border = (height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth))/2
|
||||
#ifdef Q_OS_MAC
|
||||
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
#endif
|
||||
;
|
||||
layout()->setContentsMargins(border,0,0,0);
|
||||
}
|
||||
|
||||
void CheckBoxEditor::slotStateChanged(int)
|
||||
{
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
}
|
64
limereport/objectinspector/editors/lrcheckboxeditor.h
Normal file
64
limereport/objectinspector/editors/lrcheckboxeditor.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRCHECKBOXEDITOR_H
|
||||
#define LRCHECKBOXEDITOR_H
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class CheckBoxEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
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 *);
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotStateChanged(int);
|
||||
private:
|
||||
QCheckBox* m_checkBox;
|
||||
bool m_editing;
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRCHECKBOXEDITOR_H
|
132
limereport/objectinspector/editors/lrcoloreditor.cpp
Normal file
132
limereport/objectinspector/editors/lrcoloreditor.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcoloreditor.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QColorDialog>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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->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);
|
||||
setFocusProxy(m_button);
|
||||
setAutoFillBackground(true);
|
||||
setLayout(layout);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotClicked()));
|
||||
}
|
||||
|
||||
void ColorEditor::setColor(const QColor &value)
|
||||
{
|
||||
m_color=value;
|
||||
m_colorIndicator->setColor(m_color);
|
||||
}
|
||||
|
||||
bool ColorEditor::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == m_button){
|
||||
if (event->type() == QEvent::FocusOut && !m_buttonPressed){
|
||||
QFocusEvent* focusEvent = dynamic_cast<QFocusEvent*>(event);
|
||||
if (focusEvent && focusEvent->reason()!=Qt::MouseFocusReason){
|
||||
setFocusToParent();
|
||||
emit(editingFinished());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ColorEditor::setFocusToParent(){
|
||||
if (parentWidget())
|
||||
parentWidget()->setFocus();
|
||||
}
|
||||
|
||||
void ColorEditor::slotClicked()
|
||||
{
|
||||
m_buttonPressed = true;
|
||||
QColorDialog* dialog = new QColorDialog(this);
|
||||
dialog->setCurrentColor(m_color);
|
||||
if (dialog->exec()) m_color=dialog->currentColor();
|
||||
delete dialog;
|
||||
setFocusToParent();
|
||||
emit(editingFinished());
|
||||
}
|
||||
|
||||
|
||||
void ColorIndicator::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.save();
|
||||
painter.setBrush(m_color);
|
||||
painter.setPen(Qt::gray);
|
||||
QRect rect = event->rect().adjusted(3,3,-4,-4);
|
||||
rect.setWidth(rect.height());
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.drawEllipse(rect);
|
||||
painter.restore();
|
||||
}
|
||||
|
||||
ColorIndicator::ColorIndicator(QWidget *parent)
|
||||
:QWidget(parent), m_color(Qt::white){
|
||||
setAttribute(Qt::WA_StaticContents);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
QColor ColorIndicator::color() const
|
||||
{
|
||||
return m_color;
|
||||
}
|
||||
|
||||
void ColorIndicator::setColor(const QColor &color)
|
||||
{
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
QSize ColorIndicator::sizeHint() const
|
||||
{
|
||||
return QSize(20,20);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
76
limereport/objectinspector/editors/lrcoloreditor.h
Normal file
76
limereport/objectinspector/editors/lrcoloreditor.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRCOLOREDITOR_H
|
||||
#define LRCOLOREDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class ColorIndicator : public QWidget{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorIndicator(QWidget* parent = 0);
|
||||
QColor color() const;
|
||||
void setColor(const QColor &color);
|
||||
QSize sizeHint() const;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
class ColorEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ColorEditor(QWidget *parent = 0);
|
||||
QColor color(){return m_color;}
|
||||
void setColor(const QColor& value);
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
private:
|
||||
void setFocusToParent();
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotClicked();
|
||||
private:
|
||||
QColor m_color;
|
||||
QToolButton* m_button;
|
||||
ColorIndicator* m_colorIndicator;
|
||||
bool m_buttonPressed;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRCOLOREDITOR_H
|
144
limereport/objectinspector/editors/lrcomboboxeditor.cpp
Normal file
144
limereport/objectinspector/editors/lrcomboboxeditor.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QHBoxLayout>
|
||||
#include <QToolButton>
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QKeyEvent>
|
||||
#include "lrcomboboxeditor.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ComboBoxEditor::ComboBoxEditor(QWidget *parent, bool clearable) :
|
||||
QWidget(parent),
|
||||
m_comboBox(new InternalComboBox(this)),
|
||||
m_buttonClear(0),
|
||||
m_settingValues(false)
|
||||
{
|
||||
setFocusProxy(m_comboBox);
|
||||
|
||||
if (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->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
connect(m_buttonClear,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked()));
|
||||
}
|
||||
|
||||
connect(m_comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotCurrentIndexChanged(QString)));
|
||||
m_comboBox->installEventFilter(this);
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(m_comboBox);
|
||||
if (clearable)
|
||||
layout->addWidget(m_buttonClear);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setSpacing(2);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
void ComboBoxEditor::addItems(const QStringList &values){
|
||||
m_settingValues = true;
|
||||
m_comboBox->addItems(values);
|
||||
m_settingValues = false;
|
||||
}
|
||||
|
||||
void ComboBoxEditor::setTextValue(const QString &value){
|
||||
m_settingValues = true;
|
||||
if (m_comboBox->findText(value)>0){
|
||||
m_comboBox->setCurrentIndex(m_comboBox->findText(value));
|
||||
} else {
|
||||
m_comboBox->setEditText(value);
|
||||
}
|
||||
m_settingValues = false;
|
||||
}
|
||||
|
||||
void ComboBoxEditor::slotClearButtonClicked(){
|
||||
m_comboBox->setCurrentIndex(-1);
|
||||
}
|
||||
|
||||
void ComboBoxEditor::slotCurrentIndexChanged(const QString& value)
|
||||
{
|
||||
if (!m_settingValues){
|
||||
emit currentIndexChanged(value);
|
||||
}
|
||||
}
|
||||
|
||||
QString ComboBoxEditor::text(){
|
||||
return m_comboBox->currentText();
|
||||
}
|
||||
|
||||
void ComboBoxEditor::setEditable(bool value)
|
||||
{
|
||||
if (m_comboBox) {
|
||||
m_comboBox->setEditable(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){
|
||||
m_comboBox->setFocus();
|
||||
}
|
||||
}
|
||||
QSet<int> enterKeys;
|
||||
enterKeys.insert(Qt::Key_Enter);
|
||||
enterKeys.insert(Qt::Key_Return);
|
||||
|
||||
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 (!m_comboBox->isPopup() || (m_buttonClear && m_buttonClear->hasFocus()))
|
||||
emit editingFinished();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
}
|
||||
|
||||
|
||||
void ComboBoxEditor::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
if (m_buttonClear)
|
||||
m_buttonClear->setMinimumHeight(e->size().height()-4);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
80
limereport/objectinspector/editors/lrcomboboxeditor.h
Normal file
80
limereport/objectinspector/editors/lrcomboboxeditor.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRCOMBOBOXEDITOR_H
|
||||
#define LRCOMBOBOXEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
//#include <QPushButton>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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;}
|
||||
private:
|
||||
bool m_popup;
|
||||
|
||||
};
|
||||
|
||||
class ComboBoxEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
//explicit ComboBoxEditor(QWidget *parent = 0);
|
||||
ComboBoxEditor(QWidget *parent=0, bool clearable=false);
|
||||
void addItems(const QStringList& values);
|
||||
void setTextValue(const QString& value);
|
||||
QString text();
|
||||
void setEditable(bool value);
|
||||
signals:
|
||||
void editingFinished();
|
||||
void currentIndexChanged(const QString&);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
private slots:
|
||||
void slotClearButtonClicked();
|
||||
void slotCurrentIndexChanged(const QString& value);
|
||||
private:
|
||||
bool eventFilter(QObject *target, QEvent *event);
|
||||
InternalComboBox* m_comboBox;
|
||||
QToolButton* m_buttonClear;
|
||||
bool m_settingValues;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRCOMBOBOXEDITOR_H
|
85
limereport/objectinspector/editors/lrfonteditor.cpp
Normal file
85
limereport/objectinspector/editors/lrfonteditor.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrfonteditor.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QFontDialog>
|
||||
#include <QDebug>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
FontEditor::FontEditor(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
//m_button = new QPushButton(this);
|
||||
m_button = new QToolButton(this);
|
||||
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);
|
||||
setFocusProxy(m_button);
|
||||
setLayout(layout);
|
||||
setAutoFillBackground(true);
|
||||
connect(m_button,SIGNAL(clicked()),this,SLOT(slotButtonCliked()));
|
||||
}
|
||||
|
||||
FontEditor::~FontEditor()
|
||||
{}
|
||||
|
||||
void FontEditor::setFontValue(const QFont &font)
|
||||
{
|
||||
m_font=font;
|
||||
m_button->setText(toString(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();
|
||||
delete dialog;
|
||||
emit(editingFinished());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
61
limereport/objectinspector/editors/lrfonteditor.h
Normal file
61
limereport/objectinspector/editors/lrfonteditor.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRFONTEDITOR_H
|
||||
#define LRFONTEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class FontEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FontEditor(QWidget *parent = 0);
|
||||
~FontEditor();
|
||||
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;
|
||||
QToolButton* m_button;
|
||||
QFont m_font;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRFONTEDITOR_H
|
60
limereport/objectinspector/editors/lrimageeditor.cpp
Normal file
60
limereport/objectinspector/editors/lrimageeditor.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* 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{
|
||||
|
||||
ImageEditor::ImageEditor(QWidget* parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
m_button.setIcon(QIcon(":items/ImageItem"));
|
||||
QHBoxLayout* layout = new QHBoxLayout(this);
|
||||
layout->addWidget(&m_button);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(1,0,1,1);
|
||||
setLayout(layout);
|
||||
setFocusProxy(&m_button);
|
||||
connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked()));
|
||||
}
|
||||
|
||||
QImage ImageEditor::image()
|
||||
{
|
||||
return m_image;
|
||||
}
|
||||
|
||||
void ImageEditor::slotButtonClicked()
|
||||
{
|
||||
m_image.load(QFileDialog::getOpenFileName(this));
|
||||
emit editingFinished();
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
55
limereport/objectinspector/editors/lrimageeditor.h
Normal file
55
limereport/objectinspector/editors/lrimageeditor.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRIMAGEEDITOR_H
|
||||
#define LRIMAGEEDITOR_H
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class ImageEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImageEditor(QWidget *parent=0);
|
||||
QImage image();
|
||||
void setImage(const QImage& image){m_image=image;}
|
||||
signals:
|
||||
void editingFinished();
|
||||
private slots:
|
||||
void slotButtonClicked();
|
||||
private:
|
||||
QPushButton m_button;
|
||||
QImage m_image;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
#endif // LRIMAGEEDITOR_H
|
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrtextitempropertyeditor.h"
|
||||
#include "ui_ltextitempropertyeditor.h"
|
||||
#include <QCompleter>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
TextItemPropertyEditor::TextItemPropertyEditor(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::TextItemPropertyEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->textEdit->setAcceptRichText(false);
|
||||
}
|
||||
|
||||
TextItemPropertyEditor::~TextItemPropertyEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TextItemPropertyEditor::setText(const QString &value)
|
||||
{
|
||||
ui->textEdit->setPlainText(value);
|
||||
}
|
||||
|
||||
QString TextItemPropertyEditor::text()
|
||||
{
|
||||
return ui->textEdit->toPlainText();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef ATEXTITEMPROPERTYEDITOR_H
|
||||
#define ATEXTITEMPROPERTYEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui {
|
||||
class TextItemPropertyEditor;
|
||||
}
|
||||
|
||||
class TextItemPropertyEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextItemPropertyEditor(QWidget *parent = 0);
|
||||
~TextItemPropertyEditor();
|
||||
void setText(const QString &value);
|
||||
QString text();
|
||||
public slots:
|
||||
void pbSaveCliked(){ emit editingFinished();}
|
||||
signals:
|
||||
void editingFinished();
|
||||
private:
|
||||
Ui::TextItemPropertyEditor *ui;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
#endif // ATEXTITEMPROPERTYEDITOR_H
|
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LimeReport::TextItemPropertyEditor</class>
|
||||
<widget class="QDialog" name="LimeReport::TextItemPropertyEditor">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../items/items.qrc">
|
||||
<normaloff>:/items/images/insert-text_3.png</normaloff>:/items/images/insert-text_3.png</iconset>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../items/items.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LimeReport::TextItemPropertyEditor</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>54</x>
|
||||
<y>277</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>5</x>
|
||||
<y>258</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LimeReport::TextItemPropertyEditor</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>161</x>
|
||||
<y>266</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>397</x>
|
||||
<y>225</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>pbSaveCliked()</slot>
|
||||
<slot>pbCancelCliked()</slot>
|
||||
</slots>
|
||||
</ui>
|
BIN
limereport/objectinspector/images/check.png
Normal file
BIN
limereport/objectinspector/images/check.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 447 B |
BIN
limereport/objectinspector/images/check_w.png
Normal file
BIN
limereport/objectinspector/images/check_w.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 576 B |
BIN
limereport/objectinspector/images/clear.png
Normal file
BIN
limereport/objectinspector/images/clear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 723 B |
BIN
limereport/objectinspector/images/edit_16.ico
Normal file
BIN
limereport/objectinspector/images/edit_16.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
limereport/objectinspector/images/uncheck.png
Normal file
BIN
limereport/objectinspector/images/uncheck.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 237 B |
BIN
limereport/objectinspector/images/uncheck_w.png
Normal file
BIN
limereport/objectinspector/images/uncheck_w.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 226 B |
10
limereport/objectinspector/lobjectinspector.qrc
Normal file
10
limereport/objectinspector/lobjectinspector.qrc
Normal file
@@ -0,0 +1,10 @@
|
||||
<RCC>
|
||||
<qresource prefix="/items">
|
||||
<file alias="clear.png">images/clear.png</file>
|
||||
<file alias="edit.ico">images/edit_16.ico</file>
|
||||
<file>images/check.png</file>
|
||||
<file>images/uncheck.png</file>
|
||||
<file alias="checked.png">images/check_w.png</file>
|
||||
<file alias="unchecked.png">images/uncheck_w.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
51
limereport/objectinspector/lrbasedesignobjectmodel.cpp
Normal file
51
limereport/objectinspector/lrbasedesignobjectmodel.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrbasedesignobjectmodel.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
BaseDesignPropertyModel::BaseDesignPropertyModel(QObject *parent)
|
||||
: QObjectPropertyModel(parent)
|
||||
{}
|
||||
|
||||
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)));
|
||||
|
||||
}
|
||||
QObjectPropertyModel::setObject(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
43
limereport/objectinspector/lrbasedesignobjectmodel.h
Normal file
43
limereport/objectinspector/lrbasedesignobjectmodel.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRBASEDESIGNOBJECTSMODEL_H
|
||||
#define LRBASEDESIGNOBJECTSMODEL_H
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include <QObject>
|
||||
namespace LimeReport{
|
||||
class BaseDesignPropertyModel : public QObjectPropertyModel
|
||||
{
|
||||
public:
|
||||
explicit BaseDesignPropertyModel(QObject* parent=0);
|
||||
virtual void setObject(QObject *object);
|
||||
};
|
||||
}
|
||||
#endif // LRBASEDESIGNOBJECTSMODEL_H
|
158
limereport/objectinspector/lrobjectinspectorwidget.cpp
Normal file
158
limereport/objectinspector/lrobjectinspectorwidget.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
|
||||
#include "lrglobal.h"
|
||||
#include "lrobjectinspectorwidget.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ObjectInspectorWidget::ObjectInspectorWidget(QWidget *parent)
|
||||
:QTreeView(parent), m_propertyDelegate(0)
|
||||
{
|
||||
setRootIsDecorated(false);
|
||||
initColorMap();
|
||||
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));
|
||||
setPalette(p);
|
||||
}
|
||||
|
||||
ObjectInspectorWidget::~ObjectInspectorWidget(){}
|
||||
|
||||
void ObjectInspectorWidget::drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const
|
||||
{
|
||||
ObjectPropItem *node = nodeFromIndex(index);
|
||||
QStyleOptionViewItemV4 so = options;
|
||||
bool alternate = so.features & QStyleOptionViewItemV4::Alternate;
|
||||
if (node){
|
||||
if ((!node->isHaveValue())){
|
||||
const QColor c = options.palette.color(QPalette::Dark);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QTreeView::drawRow(painter,so,index);
|
||||
painter->save();
|
||||
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->restore();
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
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));
|
||||
} else {
|
||||
if ((index.column()==1)&&(!nodeFromIndex(index)->isHaveChildren())) {
|
||||
setCurrentIndex(index);
|
||||
edit(index);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTreeView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::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));
|
||||
}
|
||||
|
||||
QColor ObjectInspectorWidget::getColor(const int index) const
|
||||
{
|
||||
return m_colors[index];
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObjectPropItem * ObjectInspectorWidget::nodeFromIndex(QModelIndex index) const
|
||||
{
|
||||
return static_cast<LimeReport::ObjectPropItem*>(index.internalPointer());
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void ObjectInspectorWidget::commitActiveEditorData(){
|
||||
if (state()==QAbstractItemView::EditingState){
|
||||
commitData(indexWidget(currentIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
64
limereport/objectinspector/lrobjectinspectorwidget.h
Normal file
64
limereport/objectinspector/lrobjectinspectorwidget.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LROBJECTINSPECTORWIDGET_H
|
||||
#define LROBJECTINSPECTORWIDGET_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QMap>
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include "lrpropertydelegate.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class ObjectInspectorWidget : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObjectInspectorWidget(QWidget * parent=0);
|
||||
~ObjectInspectorWidget();
|
||||
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);
|
||||
private:
|
||||
void initColorMap();
|
||||
LimeReport::ObjectPropItem* nodeFromIndex(QModelIndex index) const;
|
||||
|
||||
private:
|
||||
QVector<QColor> m_colors;
|
||||
PropertyDelegate *m_propertyDelegate;
|
||||
};
|
||||
|
||||
} //namespace LimeReport
|
||||
|
||||
#endif // LROBJECTINSPECTORWIDGET_H
|
407
limereport/objectinspector/lrobjectitemmodel.cpp
Normal file
407
limereport/objectinspector/lrobjectitemmodel.cpp
Normal file
@@ -0,0 +1,407 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include <QMetaProperty>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
void QObjectPropertyModel::translatePropertyName()
|
||||
{
|
||||
tr("leftMargin");
|
||||
tr("rightMargin");
|
||||
tr("topMargin");
|
||||
tr("bottomMargin");
|
||||
tr("objectName");
|
||||
tr("borders");
|
||||
tr("geometry");
|
||||
tr("itemAlign");
|
||||
tr("pageOrientation");
|
||||
tr("pageSize");
|
||||
tr("TopLine");
|
||||
tr("BottomLine");
|
||||
tr("LeftLine");
|
||||
tr("RightLine");
|
||||
tr("reprintOnEachPage");
|
||||
tr("borderLineSize");
|
||||
tr("autoHeight");
|
||||
tr("backgroundColor");
|
||||
tr("columnCount");
|
||||
tr("columnsFillDirection");
|
||||
tr("datasource");
|
||||
tr("keepBottomSpace");
|
||||
tr("keepFooterTogether");
|
||||
tr("keepSubdetailTogether");
|
||||
tr("printIfEmpty");
|
||||
tr("sliceLastRow");
|
||||
tr("splittable");
|
||||
tr("alignment");
|
||||
tr("angle");
|
||||
tr("autoWidth");
|
||||
tr("backgroundMode");
|
||||
tr("backgroundOpacity");
|
||||
tr("content");
|
||||
tr("font");
|
||||
tr("fontColor");
|
||||
tr("foregroundOpacity");
|
||||
tr("itemLocation");
|
||||
tr("margin");
|
||||
tr("stretchToMaxHeight");
|
||||
tr("trimValue");
|
||||
tr("lineWidth");
|
||||
tr("opacity");
|
||||
tr("penStyle");
|
||||
tr("shape");
|
||||
tr("shapeBrush");
|
||||
tr("shapeBrushColor");
|
||||
}
|
||||
|
||||
QObjectPropertyModel::QObjectPropertyModel(QObject *parent/*=0*/)
|
||||
:QAbstractItemModel(parent),m_rootNode(0),m_object(0),m_dataChanging(false), m_subclassesAsLevel(true), m_validator(0)
|
||||
{}
|
||||
|
||||
QObjectPropertyModel::~QObjectPropertyModel()
|
||||
{
|
||||
delete m_rootNode;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::initModel()
|
||||
{
|
||||
beginResetModel();
|
||||
delete m_rootNode;
|
||||
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);
|
||||
m_rootNode->setModel(this);
|
||||
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)
|
||||
{
|
||||
m_objects.clear();
|
||||
if (m_object!=object){
|
||||
submit();
|
||||
m_object=object;
|
||||
initModel();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setMultiObjects(QList<QObject *>* list)
|
||||
{
|
||||
m_objects.clear();
|
||||
submit();
|
||||
|
||||
if (!list->contains(m_object)){
|
||||
m_object=list->at(0);
|
||||
list->removeAt(0);
|
||||
} else {
|
||||
list->removeOne(m_object);
|
||||
}
|
||||
|
||||
foreach(QObject* item, *list)
|
||||
m_objects.append(item);
|
||||
//initModel();
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotObjectDestroyed(QObject *obj)
|
||||
{
|
||||
m_objects.removeOne(obj);
|
||||
if (m_object == obj){
|
||||
m_object=0;
|
||||
if (!m_objects.isEmpty()) m_object=m_objects.at(0);
|
||||
initModel();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotPropertyChanged(const QString &propertyName, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue);
|
||||
Q_UNUSED(newValue);
|
||||
if (m_object)
|
||||
updateProperty(propertyName);
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::slotPropertyObjectNameChanged(const QString &oldName, const QString &newName)
|
||||
{
|
||||
Q_UNUSED(oldName)
|
||||
Q_UNUSED(newName)
|
||||
if (m_object)
|
||||
updateProperty("objectName");
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
ObjectPropItem * QObjectPropertyModel::nodeFromIndex(const QModelIndex &index) const
|
||||
{
|
||||
if(index.isValid()){
|
||||
return static_cast<ObjectPropItem*>(index.internalPointer());
|
||||
} else return m_rootNode;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::updateProperty(const QString &propertyName)
|
||||
{
|
||||
if (!m_dataChanging&&m_rootNode){
|
||||
ObjectPropItem* propItem = m_rootNode->findPropertyItem(propertyName);
|
||||
if (propItem)
|
||||
propItem->updatePropertyValue();
|
||||
}
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setSubclassesAsLevel(bool value)
|
||||
{
|
||||
m_subclassesAsLevel = value;
|
||||
}
|
||||
|
||||
int QObjectPropertyModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!m_rootNode) return 0;
|
||||
ObjectPropItem *parentNode;
|
||||
if (parent.isValid())
|
||||
parentNode = nodeFromIndex(parent);
|
||||
else
|
||||
parentNode = m_rootNode;
|
||||
return parentNode->childCount();
|
||||
}
|
||||
|
||||
QVariant QObjectPropertyModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
ObjectPropItem *node = nodeFromIndex(index);
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
if (!node) return QVariant();
|
||||
if (index.column()==0){
|
||||
return node->displayName();
|
||||
} else return node->displayValue();
|
||||
break;
|
||||
case Qt::DecorationRole :
|
||||
if (!node) return QIcon();
|
||||
if (index.column()==1){
|
||||
return node->iconValue();
|
||||
}else return QIcon();
|
||||
break;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex QObjectPropertyModel::index(int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
if(!m_rootNode)
|
||||
return QModelIndex();
|
||||
|
||||
if (!hasIndex(row, column, parent))
|
||||
return QModelIndex();
|
||||
|
||||
ObjectPropItem *parentNode;
|
||||
if (parent.isValid())
|
||||
parentNode = nodeFromIndex(parent);
|
||||
else
|
||||
parentNode = m_rootNode;
|
||||
|
||||
ObjectPropItem *childItem=parentNode->child(row);
|
||||
|
||||
if (childItem){
|
||||
QModelIndex modelIndex=createIndex(row,column,childItem);
|
||||
if (column==1){
|
||||
if (childItem->modelIndex()!=modelIndex){
|
||||
childItem->setModelIndex(modelIndex);
|
||||
}
|
||||
}
|
||||
return modelIndex;
|
||||
}
|
||||
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
|
||||
{
|
||||
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){
|
||||
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* 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())
|
||||
);
|
||||
} else {
|
||||
propertyItem=new ObjectPropItem(
|
||||
0,
|
||||
0,
|
||||
QString(prop.name()),
|
||||
QString(prop.name()),
|
||||
object->property(prop.name()),
|
||||
parent
|
||||
);
|
||||
}
|
||||
return propertyItem;
|
||||
}
|
||||
ValidatorIntf *QObjectPropertyModel::validator() const
|
||||
{
|
||||
return m_validator;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::setValidator(ValidatorIntf *validator)
|
||||
{
|
||||
m_validator = validator;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::addObjectProperties(const QMetaObject *metaObject, QObject *object, ObjectPropItem::ObjectsList *objects, int level)
|
||||
{
|
||||
if (metaObject->propertyCount()>metaObject->propertyOffset()){
|
||||
ObjectPropItem* objectNode;
|
||||
if (m_subclassesAsLevel){
|
||||
objectNode=new ObjectPropItem(0,0,metaObject->className(),metaObject->className(),m_rootNode,true);
|
||||
m_rootNode->appendItem(objectNode);
|
||||
} else {
|
||||
objectNode = m_rootNode;
|
||||
}
|
||||
|
||||
//m_rootNode->appendItem(objectNode);
|
||||
|
||||
for (int i=metaObject->propertyOffset();i<metaObject->propertyCount();i++){
|
||||
if (metaObject->property(i).isDesignable()){
|
||||
ObjectPropItem* prop=createPropertyItem(metaObject->property(i),object,objects,objectNode);
|
||||
//ObjectPropItem* prop=createPropertyItem(metaObject->property(i),object,objects,m_rootNode);
|
||||
//m_rootNode->appendItem(prop);
|
||||
objectNode->appendItem(prop);
|
||||
}
|
||||
}
|
||||
if (m_subclassesAsLevel){
|
||||
objectNode->setColorIndex(level);
|
||||
objectNode->sortItem();
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
||||
if (metaObject->superClass()) addObjectProperties(metaObject->superClass(),object,objects,level);
|
||||
m_rootNode->sortItem();
|
||||
}
|
||||
|
||||
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){
|
||||
QString msg;
|
||||
if (validator() && !validator()->validate(propItem->propertyName(),value.toString(),m_object,msg)){
|
||||
QMessageBox::information(0,tr("Warning"),msg);
|
||||
return true;
|
||||
}
|
||||
QVariant oldValue=propItem->propertyValue();
|
||||
propItem->setPropertyValue(value);
|
||||
emit dataChanged(index,index);
|
||||
emit objectPropetyChanged(propItem->propertyName(),oldValue,propItem->propertyValue());
|
||||
}
|
||||
m_dataChanging=false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::itemDataChanged(const QModelIndex &index)
|
||||
{
|
||||
emit dataChanged(index,index);
|
||||
}
|
||||
|
||||
}
|
||||
|
94
limereport/objectinspector/lrobjectitemmodel.h
Normal file
94
limereport/objectinspector/lrobjectitemmodel.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LROBJECTITEMMODEL_H
|
||||
#define LROBJECTITEMMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QVariant>
|
||||
#include <QObject>
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
|
||||
class ValidatorIntf {
|
||||
public:
|
||||
virtual bool validate(const QString& propName, const QVariant& propValue, QObject* object, QString& msg) = 0;
|
||||
virtual ~ValidatorIntf(){}
|
||||
};
|
||||
|
||||
class QObjectPropertyModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
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();
|
||||
signals:
|
||||
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 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);
|
||||
private:
|
||||
LimeReport::ObjectPropItem* m_rootNode;
|
||||
QObject* m_object;
|
||||
QList<QObject*> m_objects;
|
||||
bool m_dataChanging;
|
||||
bool m_subclassesAsLevel;
|
||||
ValidatorIntf* m_validator;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LROBJECTITEMMODEL_H
|
190
limereport/objectinspector/lrobjectpropitem.cpp
Normal file
190
limereport/objectinspector/lrobjectpropitem.cpp
Normal file
@@ -0,0 +1,190 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
#include "lrbasedesignintf.h"
|
||||
#endif
|
||||
#include <QDebug>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
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)
|
||||
{
|
||||
if (parent) setModel(parent->model());
|
||||
m_index=QModelIndex();
|
||||
if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
#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)));
|
||||
}
|
||||
#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)
|
||||
{
|
||||
if (parent) setModel(parent->model());
|
||||
m_index=QModelIndex();
|
||||
if (objects) foreach(QObject* item, *objects) m_objects.append(item);
|
||||
#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)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ObjectPropItem::~ObjectPropItem(){
|
||||
qDeleteAll(m_childItems);
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
qSort(m_childItems.begin(), m_childItems.end(), lesThen);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
void ObjectPropItem::setColorIndex(int value)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (name.compare(propertyName(),Qt::CaseInsensitive)==0 && !isValueChanging()){
|
||||
setPropertyValue(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectPropItem::slotPropertyObjectName(const QString &oldValue, const QString &newValue)
|
||||
{
|
||||
Q_UNUSED(oldValue)
|
||||
if (propertyName().compare("objectName",Qt::CaseInsensitive)==0 && !isValueChanging()){
|
||||
setPropertyValue(newValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ObjectPropItem::setValueToObject(const QString &propertyName, QVariant propertyValue)
|
||||
{
|
||||
object()->setProperty(propertyName.toLatin1(),propertyValue);
|
||||
foreach (QObject* item, *objects()) {
|
||||
if (item->metaObject()->indexOfProperty(propertyName.toLatin1())!=-1)
|
||||
item->setProperty(propertyName.toLatin1(), propertyValue);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectPropItem * ObjectPropItem::findChild(const QString &name)
|
||||
{
|
||||
foreach(ObjectPropItem* item,m_childItems){
|
||||
if (item->propertyName()==name) return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ObjectPropItem *ObjectPropItem::findPropertyItem(const QString &propertyName)
|
||||
{
|
||||
foreach(ObjectPropItem* item,m_globalPropList){
|
||||
if (item->propertyName()==propertyName) return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
bool ObjectPropItem::paint(QPainter *, const QStyleOptionViewItemV4 &, const QModelIndex &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString ObjectPropItem::displayValue() const
|
||||
{
|
||||
return m_value.toString();
|
||||
}
|
||||
|
||||
}
|
141
limereport/objectinspector/lrobjectpropitem.h
Normal file
141
limereport/objectinspector/lrobjectpropitem.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LROBJECTPROPITEM_H
|
||||
#define LROBJECTPROPITEM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QModelIndex>
|
||||
#include <QMetaProperty>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDebug>
|
||||
#include <QStyleOptionViewItemV4>
|
||||
|
||||
#include "lrattribsabstractfactory.h"
|
||||
#include "lrsingleton.h"
|
||||
|
||||
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 {return m_displayName;}
|
||||
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 QStyleOptionViewItemV4 &, 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(QModelIndex index){m_index=index;}
|
||||
QModelIndex modelIndex(){return m_index;}
|
||||
bool isClass(){return m_isClass;}
|
||||
#ifdef INSPECT_BASEDESIGN
|
||||
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_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;
|
||||
};
|
||||
|
||||
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;}
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LROBJECTPROPITEM_H
|
165
limereport/objectinspector/lrpropertydelegate.cpp
Normal file
165
limereport/objectinspector/lrpropertydelegate.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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"
|
||||
|
||||
LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent)
|
||||
:QItemDelegate(parent), m_editingItem(0), m_isEditing(false)
|
||||
//:QStyledItemDelegate(parent), m_editingItem(0)
|
||||
{
|
||||
//setClipping(false);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) return;
|
||||
|
||||
LimeReport::ObjectPropItem *node = static_cast<LimeReport::ObjectPropItem*>(index.internalPointer());
|
||||
if (node){
|
||||
if (!node->isHaveValue()){
|
||||
if (index.column()==0) {
|
||||
QStyleOptionViewItemV4 cellOpt = option;
|
||||
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)));
|
||||
drawBackground(painter,option,index);
|
||||
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));
|
||||
drawDisplay(painter,cellOpt,cellOpt.rect,LimeReport::extractClassName(node->propertyName()));
|
||||
painter->restore();
|
||||
}
|
||||
} else
|
||||
{
|
||||
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();
|
||||
painter->setPen(option.palette.color(QPalette::Dark));
|
||||
painter->drawLine(start,end);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QStyleOptionViewItemV4 so = option;
|
||||
if ((node->isValueReadonly())&&(!node->isHaveChildren())) {
|
||||
so.palette.setColor(QPalette::Text,so.palette.color(QPalette::Dark));
|
||||
}
|
||||
drawBackground(painter,option,index);
|
||||
if (!node->paint(painter,so,index))
|
||||
QItemDelegate::paint(painter, so, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
#ifdef Q_OS_MAC
|
||||
+QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin)
|
||||
#endif
|
||||
+2);
|
||||
return size;
|
||||
}
|
||||
|
||||
QWidget * LimeReport::PropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
m_editingItem=static_cast<LimeReport::ObjectPropItem*>(index.internalPointer());
|
||||
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->setGeometry(option.rect);
|
||||
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
|
||||
{
|
||||
if (m_editingItem) m_editingItem->setPropertyEditorData(editor,index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::commitAndCloseEditor()
|
||||
{
|
||||
QWidget *editor = qobject_cast<QWidget*>(sender());
|
||||
emit commitData(editor);
|
||||
emit closeEditor(editor);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
if (m_editingItem) m_editingItem->setModelData(editor,model,index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if (m_editingItem) m_editingItem->updateEditorGeometry(editor,option,index);
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::setObjectInspector(ObjectInspectorWidget* objectInspector)
|
||||
{
|
||||
m_objectInspector=objectInspector;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::slotEditorDeleted()
|
||||
{
|
||||
m_isEditing=false;
|
||||
}
|
||||
|
||||
void LimeReport::PropertyDelegate::slotItemDeleted(QObject *item)
|
||||
{
|
||||
if (item == m_editingItem) m_editingItem = 0;
|
||||
}
|
||||
|
||||
LimeReport::ObjectPropItem* LimeReport::PropertyDelegate::editingItem()
|
||||
{
|
||||
return m_editingItem;
|
||||
}
|
||||
|
68
limereport/objectinspector/lrpropertydelegate.h
Normal file
68
limereport/objectinspector/lrpropertydelegate.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRPROPERTYDELEGATE_H
|
||||
#define LRPROPERTYDELEGATE_H
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
#include <QObject>
|
||||
|
||||
#include "lrobjectitemmodel.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class ObjectInspectorWidget;
|
||||
class PropertyDelegate : public QItemDelegate
|
||||
//class PropertyDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PropertyDelegate(QObject *parent=0);
|
||||
void setObjectInspector(ObjectInspectorWidget* 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;
|
||||
LimeReport::ObjectPropItem* editingItem();
|
||||
bool isEditing(){return m_isEditing;}
|
||||
private slots:
|
||||
void commitAndCloseEditor();
|
||||
void slotEditorDeleted();
|
||||
void slotItemDeleted(QObject* item);
|
||||
private:
|
||||
LimeReport::ObjectInspectorWidget* m_objectInspector;
|
||||
mutable LimeReport::ObjectPropItem* m_editingItem;
|
||||
mutable bool m_isEditing;
|
||||
};
|
||||
}
|
||||
#endif // LRPROPERTYDELEGATE_H
|
92
limereport/objectinspector/propertyItems/lrboolpropitem.cpp
Normal file
92
limereport/objectinspector/propertyItems/lrboolpropitem.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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"
|
||||
|
||||
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 registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("bool",""),QObject::tr("bool"),createBoolPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *BoolPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
CheckBoxEditor *editor= new CheckBoxEditor(parent);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void BoolPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
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)
|
||||
{
|
||||
model->setData(index,qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
bool BoolPropItem::paint(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
|
||||
{
|
||||
if (index.column()==1){
|
||||
QStyleOptionButton so;
|
||||
int border = (option.rect.height() - QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth))/2;
|
||||
so.rect = option.rect.adjusted(border,border,0,-border);
|
||||
so.rect.setWidth(QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth));
|
||||
|
||||
if (!isValueReadonly())
|
||||
so.state = QStyle::State_Enabled;
|
||||
else
|
||||
so.state &= ~QStyle::State_Enabled;
|
||||
|
||||
so.state |= propertyValue().toBool() ? QStyle::State_On : QStyle::State_Off;
|
||||
|
||||
option.widget->style()->drawPrimitive(QStyle::PE_IndicatorCheckBox,&so,painter);
|
||||
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
51
limereport/objectinspector/propertyItems/lrboolpropitem.h
Normal file
51
limereport/objectinspector/propertyItems/lrboolpropitem.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRBOOLPROPITEM_H
|
||||
#define LRBOOLPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
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 QStyleOptionViewItemV4 &option, const QModelIndex &index);
|
||||
};
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRBOOLPROPITEM_H
|
87
limereport/objectinspector/propertyItems/lrcolorpropitem.cpp
Normal file
87
limereport/objectinspector/propertyItems/lrcolorpropitem.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrcolorpropitem.h"
|
||||
#include "editors/lrcoloreditor.h"
|
||||
#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 registredColorProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QColor",""),QObject::tr("QColor"),createColorPropItem);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
model->setData(index,qobject_cast<ColorEditor*>(propertyEditor)->color());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
bool ColorPropItem::paint(QPainter *painter, const QStyleOptionViewItemV4 &option, const QModelIndex &index)
|
||||
{
|
||||
if (index.column()==1){
|
||||
painter->save();
|
||||
QPen pen;
|
||||
|
||||
if (option.state & QStyle::State_Selected){
|
||||
pen.setWidth(2);
|
||||
pen.setColor(option.palette.brightText().color());
|
||||
}else {
|
||||
pen.setColor(Qt::gray);
|
||||
}
|
||||
|
||||
painter->setPen(pen);
|
||||
|
||||
painter->setBrush(propertyValue().value<QColor>());
|
||||
QRect rect = option.rect.adjusted(4,4,-4,-6);
|
||||
rect.setWidth(rect.height());
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->drawEllipse(rect);
|
||||
painter->restore();
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
QWidget *ColorPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new ColorEditor(parent);
|
||||
}
|
||||
|
||||
}
|
51
limereport/objectinspector/propertyItems/lrcolorpropitem.h
Normal file
51
limereport/objectinspector/propertyItems/lrcolorpropitem.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRCOLORPROPITEM_H
|
||||
#define LRCOLORPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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 QStyleOptionViewItemV4 &option, const QModelIndex &index);
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRCOLORPROPITEM_H
|
@@ -0,0 +1,38 @@
|
||||
#include "lrcontentpropitem.h"
|
||||
#include "lrtextitem.h"
|
||||
#include "editors/lrbuttonlineeditor.h"
|
||||
#include "items/lrtextitemeditor.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 registredContentProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *ContentPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
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->setAttribute(Qt::WA_DeleteOnClose);
|
||||
//dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), QApplication::desktop()->availableGeometry()));
|
||||
dialog->setWindowTitle(propertyName());
|
||||
QWidget* editor = dynamic_cast<BaseDesignIntf*>(m_object)->defaultEditor();
|
||||
dialog->layout()->addWidget(editor);
|
||||
connect(editor,SIGNAL(destroyed()),dialog,SLOT(close()));
|
||||
connect(editor,SIGNAL(destroyed()),this,SIGNAL(editingFinished()));
|
||||
dialog->exec();
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
31
limereport/objectinspector/propertyItems/lrcontentpropitem.h
Normal file
31
limereport/objectinspector/propertyItems/lrcontentpropitem.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef CONTENTPROPITEM_H
|
||||
#define CONTENTPROPITEM_H
|
||||
|
||||
#include "lrstringpropitem.h"
|
||||
#include "objectinspector/editors/lrbuttonlineeditor.h"
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
class ContentEditor : public ButtonLineEditor{
|
||||
Q_OBJECT
|
||||
public:
|
||||
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{
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // CONTENTPROPITEM_H
|
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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 <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 registredDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::DataBandDesignIntf"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
bool registredImageDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("datasource","LimeReport::ImageItem"),QObject::tr("datasource"),createDatasourcePropItem
|
||||
);
|
||||
bool registredImageFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
QWidget *LimeReport::FieldPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent);
|
||||
editor->setEditable(true);
|
||||
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()));
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::FieldPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
editor->setTextValue(propertyValue().toString());
|
||||
}
|
||||
|
||||
void LimeReport::FieldPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRDATASOURCEPROPITEM_H
|
||||
#define LRDATASOURCEPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
|
||||
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 &);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATASOURCEPROPITEM_H
|
107
limereport/objectinspector/propertyItems/lrenumpropitem.cpp
Normal file
107
limereport/objectinspector/propertyItems/lrenumpropitem.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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)
|
||||
{
|
||||
return new LimeReport::EnumPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *EnumPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
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(propEnum.key(i));
|
||||
else {
|
||||
if (m_acceptableValues.contains(propEnum.value(i))){
|
||||
enumValues.append(propEnum.key(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
editor->addItems(enumValues);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void EnumPropItem::slotEnumChanged(const QString &text)
|
||||
{
|
||||
if ( nameByType(object()->property(propertyName().toLatin1()).toInt())!=text){
|
||||
beginChangeValue();
|
||||
setPropertyValue(typeByName(text));
|
||||
setValueToObject(propertyName(),typeByName(text));
|
||||
endChangeValue();
|
||||
}
|
||||
}
|
||||
|
||||
void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
editor->setTextValue(nameByType(propertyValue().toInt()));
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
QString EnumPropItem::nameByType(int value) const
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
return propEnum.valueToKey(value);
|
||||
}
|
||||
|
||||
int EnumPropItem::typeByName(const QString &value) const
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
return propEnum.keyToValue(value.toLatin1());
|
||||
}
|
||||
|
||||
QString EnumPropItem::displayValue() const
|
||||
{
|
||||
return nameByType((propertyValue().toInt()));
|
||||
}
|
||||
|
||||
}
|
60
limereport/objectinspector/propertyItems/lrenumpropitem.h
Normal file
60
limereport/objectinspector/propertyItems/lrenumpropitem.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRENUMPROPITEM_H
|
||||
#define LRENUMPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class EnumPropItem : public ObjectPropItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EnumPropItem():ObjectPropItem(){}
|
||||
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){}
|
||||
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){}
|
||||
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;
|
||||
private slots:
|
||||
void slotEnumChanged(const QString& text);
|
||||
private:
|
||||
QVector<int> m_acceptableValues;
|
||||
bool m_settingValue;
|
||||
};
|
||||
}
|
||||
#endif // LRENUMPROPITEM_H
|
147
limereport/objectinspector/propertyItems/lrflagspropitem.cpp
Normal file
147
limereport/objectinspector/propertyItems/lrflagspropitem.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrflagspropitem.h"
|
||||
#include "lrenumpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
#include "../editors/lrcheckboxeditor.h"
|
||||
#include "lrobjectitemmodel.h"
|
||||
#include <QIcon>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
#include <QStylePainter>
|
||||
|
||||
namespace {
|
||||
|
||||
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);
|
||||
}
|
||||
bool registred = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("flags",""),QObject::tr("flags"),createFlagsPropItem
|
||||
);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
void FlagsPropItem::createChildren()
|
||||
{
|
||||
QMetaEnum propEnum = object()->metaObject()->property(object()->metaObject()->indexOfProperty(propertyName().toLatin1())).enumerator();
|
||||
for (int i=0;i<propEnum.keyCount();i++)
|
||||
{
|
||||
this->appendItem(new LimeReport::FlagPropItem(
|
||||
object(), objects(), QString(propEnum.key(i)), QString(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++)
|
||||
{
|
||||
ObjectPropItem* property = findChild(QString(propEnum.key(i)));
|
||||
if (property)
|
||||
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)
|
||||
{
|
||||
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){}
|
||||
|
||||
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 ( (propertyValue().toInt() & propEnum.keyToValue(propEnum.key(i)))==propEnum.keyToValue(propEnum.key(i) ))
|
||||
{
|
||||
if (result.isEmpty()) result+=propEnum.key(i);
|
||||
else result=result+" | "+propEnum.key(i);
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void FlagsPropItem::setPropertyValue(QVariant value)
|
||||
{
|
||||
ObjectPropItem::setPropertyValue(value);
|
||||
updateChildren();
|
||||
}
|
||||
|
||||
void FlagsPropItem::slotEnumChanged(QString /*text*/)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
CheckBoxEditor *editor = qobject_cast<CheckBoxEditor*>(propertyEditor);
|
||||
editor->setChecked(propertyValue().toBool());
|
||||
}
|
||||
|
||||
void FlagPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
bool value = qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked();
|
||||
model->setData(index,value);
|
||||
int flags = object()->property(parent()->propertyName().toLatin1()).toInt();
|
||||
if (value) flags=flags | valueByName(displayName());
|
||||
else if (flags&valueByName(displayName())) flags=flags ^ valueByName(displayName());
|
||||
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();
|
||||
return propEnum.keyToValue(typeName.toLatin1());
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
71
limereport/objectinspector/propertyItems/lrflagspropitem.h
Normal file
71
limereport/objectinspector/propertyItems/lrflagspropitem.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRFLAGSPROPEDITOR_H
|
||||
#define LRFLAGSPROPEDITOR_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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);
|
||||
virtual QString displayValue() const;
|
||||
virtual void setPropertyValue(QVariant propertyValue);
|
||||
private slots:
|
||||
void slotEnumChanged(QString);
|
||||
private:
|
||||
QSet<int> m_acceptableValues;
|
||||
QString nameByType(int propertyValue) const;
|
||||
int typeByName(QString propertyValue) const;
|
||||
void createChildren();
|
||||
void updateChildren();
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRFLAGSPROPEDITOR_H
|
160
limereport/objectinspector/propertyItems/lrfontpropitem.cpp
Normal file
160
limereport/objectinspector/propertyItems/lrfontpropitem.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QFontDialog>
|
||||
#include <QSpinBox>
|
||||
#include <QFontComboBox>
|
||||
|
||||
#include "lrfontpropitem.h"
|
||||
#include "editors/lrbuttonlineeditor.h"
|
||||
#include "editors/lrfonteditor.h"
|
||||
#include "editors/lrcheckboxeditor.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 registredFontProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QFont",""),QObject::tr("QFont"),createFontPropItem);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
this->appendItem(m_bold);
|
||||
this->appendItem(m_italic);
|
||||
this->appendItem(m_underline);
|
||||
}
|
||||
|
||||
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>());
|
||||
}
|
||||
|
||||
void FontPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
FontEditor *editor =qobject_cast<FontEditor*>(propertyEditor);
|
||||
editor->setFontValue(propertyValue().value<QFont>());
|
||||
}
|
||||
|
||||
void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<FontEditor*>(propertyEditor)->fontValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
void FontPropItem::setPropertyValue(QVariant value)
|
||||
{
|
||||
ObjectPropItem::setPropertyValue(value);
|
||||
m_bold->setPropertyValue(value.value<QFont>().bold());
|
||||
m_italic->setPropertyValue(value.value<QFont>().italic());
|
||||
m_underline->setPropertyValue(value.value<QFont>().underline());
|
||||
m_pointSize->setPropertyValue(value.value<QFont>().pointSize());
|
||||
m_family->setPropertyValue(value.value<QFont>());
|
||||
}
|
||||
|
||||
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 FontFamilyPropItem::displayValue() const
|
||||
{
|
||||
QFont font = propertyValue().value<QFont>();
|
||||
return font.family();
|
||||
}
|
||||
|
||||
QWidget *FontFamilyPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
QFontComboBox* editor = new QFontComboBox(parent);
|
||||
editor->setFont(propertyValue().value<QFont>());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void FontFamilyPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
QFontComboBox* editor = qobject_cast<QFontComboBox*>(propertyEditor);
|
||||
editor->setCurrentFont(propertyValue().value<QFont>());
|
||||
}
|
||||
|
||||
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());
|
||||
model->setData(index,font);
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
void FontAttribPropItem::setModelData(QWidget *propertyEditor , QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<CheckBoxEditor*>(propertyEditor)->isChecked());
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
if (propertyName()=="bold"){
|
||||
font.setBold(propertyValue().toBool());
|
||||
}
|
||||
if (propertyName()=="italic"){
|
||||
font.setItalic(propertyValue().toBool());
|
||||
}
|
||||
if (propertyName()=="underline"){
|
||||
font.setUnderline(propertyValue().toBool());
|
||||
}
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
void FontPointSizePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value());
|
||||
QFont font = object()->property(parent()->propertyName().toLatin1()).value<QFont>();
|
||||
font.setPointSize(propertyValue().toInt());
|
||||
setValueToObject(parent()->propertyName(),font);
|
||||
}
|
||||
|
||||
}
|
92
limereport/objectinspector/propertyItems/lrfontpropitem.h
Normal file
92
limereport/objectinspector/propertyItems/lrfontpropitem.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRFONTPROPITEM_H
|
||||
#define LRFONTPROPITEM_H
|
||||
#include "lrobjectpropitem.h"
|
||||
#include "lrboolpropitem.h"
|
||||
#include "lrintpropitem.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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){}
|
||||
QString displayValue() const;
|
||||
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
|
||||
{
|
||||
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);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
class FontPropItem : public ObjectPropItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FontPropItem():ObjectPropItem(){}
|
||||
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 setPropertyValue(QVariant value);
|
||||
protected:
|
||||
QString toString(QFont value) const;
|
||||
FontPointSizePropItem* m_pointSize;
|
||||
FontAttribPropItem *m_bold;
|
||||
FontAttribPropItem *m_italic;
|
||||
FontAttribPropItem *m_underline;
|
||||
FontFamilyPropItem *m_family;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRFONTPROPITEM_H
|
@@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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 registredGroupFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||
LimeReport::APropIdent("groupFieldName","LimeReport::GroupBandHeader"),QObject::tr("field"),createFieldPropItem
|
||||
);
|
||||
}
|
||||
namespace LimeReport {
|
||||
|
||||
QWidget *GroupFieldPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
ComboBoxEditor *editor = new ComboBoxEditor(parent,true);
|
||||
editor->setEditable(true);
|
||||
GroupBandHeader *item=dynamic_cast<GroupBandHeader*>(object());
|
||||
if (item){
|
||||
DataBandDesignIntf* dataBand = dynamic_cast<DataBandDesignIntf*>(item->parentBand());
|
||||
if (dataBand){
|
||||
int propertyIndex = dataBand->metaObject()->indexOfProperty("datasource");
|
||||
|
||||
if (item && propertyIndex>0){
|
||||
editor->addItems(item->reportEditor()->dataManager()->fieldNames(dataBand->property("datasource").toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return editor;
|
||||
}
|
||||
|
||||
void GroupFieldPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ComboBoxEditor *editor=qobject_cast<ComboBoxEditor *>(propertyEditor);
|
||||
editor->setTextValue(propertyValue().toString());
|
||||
}
|
||||
|
||||
void GroupFieldPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ComboBoxEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRGROUPFIELDPROPITEM_H
|
||||
#define LRGROUPFIELDPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LRGROUPFIELDPROPITEM_H
|
71
limereport/objectinspector/propertyItems/lrimagepropitem.cpp
Normal file
71
limereport/objectinspector/propertyItems/lrimagepropitem.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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 registredImageProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QImage",""),QObject::tr("QImage"),createImagePropItem);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
QWidget* ImagePropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new ImageEditor(parent);
|
||||
}
|
||||
|
||||
QString ImagePropItem::displayValue() const
|
||||
{
|
||||
return (propertyValue().isNull())?"":"Picture";
|
||||
}
|
||||
|
||||
void ImagePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ImageEditor *editor =qobject_cast<ImageEditor*>(propertyEditor);
|
||||
editor->setImage(propertyValue().value<QImage>());
|
||||
}
|
||||
|
||||
void ImagePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ImageEditor*>(propertyEditor)->image());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
|
||||
QIcon ImagePropItem::iconValue() const
|
||||
{
|
||||
return QIcon(QPixmap::fromImage(propertyValue().value<QImage>()));
|
||||
}
|
||||
|
||||
}
|
51
limereport/objectinspector/propertyItems/lrimagepropitem.h
Normal file
51
limereport/objectinspector/propertyItems/lrimagepropitem.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRIMAGEPROPITEM_H
|
||||
#define LRIMAGEPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
namespace LimeReport{
|
||||
|
||||
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;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const;
|
||||
void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index);
|
||||
virtual QIcon iconValue() const;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRIMAGEPROPITEM_H
|
70
limereport/objectinspector/propertyItems/lrintpropitem.cpp
Normal file
70
limereport/objectinspector/propertyItems/lrintpropitem.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrintpropitem.h"
|
||||
#include <limits>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
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 registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
QWidget *IntPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
QSpinBox *editor= new QSpinBox(parent);
|
||||
editor->setMaximum(std::numeric_limits<int>::max());
|
||||
editor->setMinimum(std::numeric_limits<int>::min());
|
||||
return editor;
|
||||
}
|
||||
|
||||
void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
QSpinBox *editor =qobject_cast<QSpinBox *>(propertyEditor);
|
||||
editor->setValue(propertyValue().toInt());
|
||||
}
|
||||
|
||||
void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
foreach(QObject* item, *objects()){
|
||||
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){
|
||||
item->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
50
limereport/objectinspector/propertyItems/lrintpropitem.h
Normal file
50
limereport/objectinspector/propertyItems/lrintpropitem.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRINTPROPITEM_H
|
||||
#define LRINTPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
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);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRINTPROPITEM_H
|
68
limereport/objectinspector/propertyItems/lrqrealpropitem.cpp
Normal file
68
limereport/objectinspector/propertyItems/lrqrealpropitem.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#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 registred = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("qreal",""),QObject::tr("qreal"),createQRealPropItem);
|
||||
bool registredDouble = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("double",""),QObject::tr("qreal"),createQRealPropItem);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
QWidget *QRealPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(std::numeric_limits<qreal>::max());
|
||||
editor->setMinimum(std::numeric_limits<qreal>::max()*-1);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void QRealPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
QDoubleSpinBox *editor =qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(propertyValue().toDouble());
|
||||
}
|
||||
|
||||
void QRealPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QDoubleSpinBox*>(propertyEditor)->value());
|
||||
//object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
setValueToObject(propertyName(),propertyValue());
|
||||
}
|
||||
|
||||
}
|
52
limereport/objectinspector/propertyItems/lrqrealpropitem.h
Normal file
52
limereport/objectinspector/propertyItems/lrqrealpropitem.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRQREALPROPITEM_H
|
||||
#define LRQREALPROPITEM_H
|
||||
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // LRQREALPROPITEM_H
|
211
limereport/objectinspector/propertyItems/lrrectproptem.cpp
Normal file
211
limereport/objectinspector/propertyItems/lrrectproptem.cpp
Normal file
@@ -0,0 +1,211 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* 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 <QAbstractItemModel>
|
||||
#include <QRect>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QDebug>
|
||||
|
||||
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 * createReqtMMItem(
|
||||
QObject*object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
|
||||
){
|
||||
return new LimeReport::RectMMPropItem(object, objects, name, displayName, data, parent, readonly);
|
||||
}
|
||||
bool registredRectProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QRect",""),QObject::tr("QRect"),createReqtItem);
|
||||
bool registredRectFProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QRectF",""),QObject::tr("QRectF"),createReqtItem);
|
||||
bool registredRectMMProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("geometry","LimeReport::BaseDesignIntf"),QObject::tr("geometry"),createReqtMMItem);
|
||||
}
|
||||
|
||||
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);}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
QString LimeReport::RectPropItem::displayValue() const
|
||||
{
|
||||
switch(propertyValue().type()){
|
||||
case QVariant::Rect:
|
||||
return rectToString(propertyValue().toRect());
|
||||
break;
|
||||
case QVariant::RectF:
|
||||
return rectToString(propertyValue().toRect());
|
||||
break;
|
||||
default :
|
||||
return ObjectPropItem::displayValue();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LimeReport::RectMMPropItem::RectMMPropItem(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();
|
||||
LimeReport::BandDesignIntf* band = dynamic_cast<LimeReport::BandDesignIntf*>(object);
|
||||
LimeReport::PageItemDesignIntf *page = dynamic_cast<LimeReport::PageItemDesignIntf*>(object);
|
||||
if(band){
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "x","x",rect.x()/10,this,true));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "y","y",rect.y()/10,this,true));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "width",tr("width"), rect.width()/10,this,true));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "height",tr("height"), rect.height()/10,this,false));
|
||||
} else if(page){
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, 0, "x","x",rect.x()/10,this,true));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, 0, "y","y",rect.y()/10,this,true));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, 0,"width", tr("width"), rect.width()/10,this,false));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, 0, "height", tr("height"), rect.height()/10,this,false));
|
||||
} else {
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "x","x",rect.x()/10,this,false));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "y","y",rect.y()/10,this,false));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "width", tr("width"), rect.width()/10,this,false));
|
||||
this->appendItem(new LimeReport::RectMMValuePropItem(object, objects, "height", tr("height"), rect.height()/10,this,false));
|
||||
}
|
||||
LimeReport::BaseDesignIntf * item = dynamic_cast<LimeReport::BaseDesignIntf*>(object);
|
||||
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)));
|
||||
}
|
||||
|
||||
}
|
||||
QString LimeReport::RectMMPropItem::displayValue() const
|
||||
{
|
||||
QRectF rect = propertyValue().toRectF();
|
||||
return QString("[%1,%2] %3x%4 mm")
|
||||
.arg(rect.x()/10,0,'f',2)
|
||||
.arg(rect.y()/10,0,'f',2)
|
||||
.arg(rect.width()/10,0,'f',2)
|
||||
.arg(rect.height()/10,0,'f',2);
|
||||
}
|
||||
|
||||
LimeReport::RectMMValuePropItem::RectMMValuePropItem(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::RectMMValuePropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
QDoubleSpinBox *editor= new QDoubleSpinBox(parent);
|
||||
editor->setMaximum(100000);
|
||||
editor->setSuffix(" mm");
|
||||
return editor;
|
||||
}
|
||||
|
||||
void LimeReport::RectMMValuePropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
QDoubleSpinBox *editor = qobject_cast<QDoubleSpinBox*>(propertyEditor);
|
||||
editor->setValue(propertyValue().toDouble());
|
||||
}
|
||||
|
||||
void LimeReport::RectMMValuePropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<QDoubleSpinBox*>(propertyEditor)->value());
|
||||
QRectF rect=object()->property(parent()->propertyName().toLatin1()).toRectF();
|
||||
object()->setProperty(parent()->propertyName().toLatin1(),modifyRect(rect,propertyName(),propertyValue().toReal()*10));
|
||||
}
|
||||
|
||||
QString LimeReport::RectMMValuePropItem::displayValue() const
|
||||
{
|
||||
return QString::number(propertyValue().toReal())+" "+QObject::tr("mm");
|
||||
}
|
||||
|
||||
void LimeReport::RectMMPropItem::itemPosChanged(QObject* /*object*/, QPointF newPos, QPointF oldPos)
|
||||
{
|
||||
if (newPos.x()!=oldPos.x()){
|
||||
setValue("x",newPos.x());
|
||||
}
|
||||
if (newPos.y()!=oldPos.y()){
|
||||
setValue("y",newPos.y());
|
||||
}
|
||||
}
|
||||
|
||||
void LimeReport::RectMMPropItem::itemGeometryChanged(QObject * /*object*/, QRectF newGeometry, QRectF oldGeometry)
|
||||
{
|
||||
if (newGeometry.x()!=oldGeometry.x()){
|
||||
setValue("x",newGeometry.x());
|
||||
}
|
||||
if (newGeometry.y()!=oldGeometry.y()){
|
||||
setValue("y",newGeometry.y());
|
||||
}
|
||||
if (newGeometry.width()!=oldGeometry.width()){
|
||||
setValue("width",newGeometry.width());
|
||||
}
|
||||
if (newGeometry.height()!=oldGeometry.height()){
|
||||
setValue("height",newGeometry.height());
|
||||
}
|
||||
}
|
||||
|
||||
void LimeReport::RectMMPropItem::setValue(const QString &name, qreal value)
|
||||
{
|
||||
if (name!=""){
|
||||
LimeReport::ObjectPropItem* propItem = findChild(name);
|
||||
if (propItem) {
|
||||
propItem->setPropertyValue(value/10);
|
||||
setPropertyValue(LimeReport::modifyRect(propertyValue().toRectF(),name,value));
|
||||
LimeReport::QObjectPropertyModel *itemModel=dynamic_cast<LimeReport::QObjectPropertyModel *>(model());
|
||||
if (itemModel) {
|
||||
itemModel->itemDataChanged(modelIndex());
|
||||
if (propItem->modelIndex().isValid())
|
||||
itemModel->itemDataChanged(propItem->modelIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
71
limereport/objectinspector/propertyItems/lrrectproptem.h
Normal file
71
limereport/objectinspector/propertyItems/lrrectproptem.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRRECTPROPTEM_H
|
||||
#define LRRECTPROPTEM_H
|
||||
#include "lrobjectpropitem.h"
|
||||
#include <QRectF>
|
||||
#include <QMetaProperty>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
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);
|
||||
QString displayValue() const;
|
||||
};
|
||||
|
||||
class RectMMPropItem : public ObjectPropItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RectMMPropItem():ObjectPropItem(){}
|
||||
RectMMPropItem(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);
|
||||
};
|
||||
|
||||
class RectMMValuePropItem : public ObjectPropItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RectMMValuePropItem():ObjectPropItem(){}
|
||||
RectMMValuePropItem(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 &);
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRRECTPROPTEM_H
|
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* 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 registredStringProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("QString",""),QObject::tr("QString"),createStringPropItem);
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
|
||||
QWidget * StringPropItem::createProperyEditor(QWidget *parent) const
|
||||
{
|
||||
return new ButtonLineEditor(object()->objectName()+"."+displayName(),parent);
|
||||
}
|
||||
|
||||
void StringPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
{
|
||||
ButtonLineEditor *editor =qobject_cast<ButtonLineEditor *>(propertyEditor);
|
||||
editor->setText(propertyValue().toString());
|
||||
}
|
||||
|
||||
void StringPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||
{
|
||||
model->setData(index,qobject_cast<ButtonLineEditor*>(propertyEditor)->text());
|
||||
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||
}
|
||||
|
||||
QString StringPropItem::displayValue() const
|
||||
{
|
||||
return propertyValue().toString().simplified();
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
47
limereport/objectinspector/propertyItems/lrstringpropitem.h
Normal file
47
limereport/objectinspector/propertyItems/lrstringpropitem.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRSTRINGPROPITEM_H
|
||||
#define LRSTRINGPROPITEM_H
|
||||
#include "lrobjectpropitem.h"
|
||||
|
||||
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;
|
||||
QString displayValue() const;
|
||||
void setPropertyEditorData(QWidget *, const QModelIndex &) const;
|
||||
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &);
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // LRSTRINGPROPITEM_H
|
Reference in New Issue
Block a user