Change to subforder project model.

This commit is contained in:
newsages
2016-03-21 02:12:30 +01:00
parent 9797b30d0a
commit 598d4f10ed
531 changed files with 167 additions and 2522 deletions

View 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

View 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

View 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);
}
}

View 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

View File

@@ -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

View 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

View File

@@ -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());
}

View 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 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

View 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()));
}
}

View 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

View 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

View 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

View 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);
}
}

View 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

View 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. *
****************************************************************************/
#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());
}
}

View File

@@ -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

View 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>()));
}
}

View 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

View 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

View 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

View 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());
}
}

View 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

View 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());
}
}
}
}

View 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

View File

@@ -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

View 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