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

Merge branch 'develop' into feature/CH_Private_To_Public

# Conflicts:
#	limereport/lrreportdesignwidget.cpp
#	limereport/lrreportdesignwidget.h
#	limereport/lrreportdesignwindow.h
This commit is contained in:
Arin Alexander 2017-04-18 22:21:24 +03:00
commit cb438ceff1
65 changed files with 2598 additions and 238 deletions

View File

@ -1,4 +1,6 @@
LimeReport v1.3.11 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport)
LimeReport v1.4.7 [![Build Status](https://api.travis-ci.org/fralx/LimeReport.svg?branch=master)](https://travis-ci.org/fralx/LimeReport)
-----------
Official LimeReport web site [http://limereport.ru](http://limereport.ru)
-----------
##Features
@ -38,6 +40,17 @@ For more samples see a demo
## Change log
###1.4.7
1. Multipage
2. Dialogs
3. Render events
4. Initscript
5. Memory usage has been reduced
6. Datasource manager has been refactored
7. Report items context menus have been added
8. Editable report
And many others minor fixes and improvements
###1.3.11
1. LimeReport project structure has been changed
2. Preview widget has been added

View File

@ -1,6 +1,8 @@
CONFIG += build_translations
CONFIG += zint
CONFIG += qjsengine
CONFIG += dialogdesigner
greaterThan(QT_MAJOR_VERSION, 4) {
QT += uitools
}
@ -56,7 +58,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 4
LIMEREPORT_VERSION_RELEASE = 4
LIMEREPORT_VERSION_RELEASE = 8
LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"'
DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\"

View File

@ -64,6 +64,7 @@ class SubDetailHeaderBand : public BandDesignIntf
public:
SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent=0);
bool isUnique() const;
bool isHeader() const {return true;}
protected:
QColor bandColor() const;
private:

View File

@ -0,0 +1,109 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include "shared_global_p.h"
#include <QtCore/QMap>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class QDesignerFormEditorInterface;
class QDesignerCustomWidgetInterface;
class QDesignerPluginManagerPrivate;
class QDESIGNER_SHARED_EXPORT QDesignerPluginManager: public QObject
{
Q_OBJECT
public:
explicit QDesignerPluginManager(QDesignerFormEditorInterface *core);
virtual ~QDesignerPluginManager();
QDesignerFormEditorInterface *core() const;
QObject *instance(const QString &plugin) const;
QStringList registeredPlugins() const;
QStringList findPlugins(const QString &path);
QStringList pluginPaths() const;
void setPluginPaths(const QStringList &plugin_paths);
QStringList disabledPlugins() const;
void setDisabledPlugins(const QStringList &disabled_plugins);
QStringList failedPlugins() const;
QString failureReason(const QString &pluginName) const;
QList<QObject*> instances() const;
QList<QDesignerCustomWidgetInterface*> registeredCustomWidgets() const;
bool registerNewPlugins();
public slots:
bool syncSettings();
void ensureInitialized();
private:
void updateRegisteredPlugins();
void registerPath(const QString &path);
void registerPlugin(const QString &plugin);
private:
static QStringList defaultPluginPaths();
QDesignerPluginManagerPrivate *m_d;
};
QT_END_NAMESPACE
#endif // PLUGINMANAGER_H

View File

@ -0,0 +1,126 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef QDESIGNER_INTEGRATION_H
#define QDESIGNER_INTEGRATION_H
#include "shared_global_p.h"
#include <QtDesigner/QDesignerIntegrationInterface>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerResourceBrowserInterface;
class QVariant;
class QWidget;
namespace qdesigner_internal {
struct Selection;
class QDesignerIntegrationPrivate;
class QDESIGNER_SHARED_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface
{
Q_OBJECT
public:
explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0);
virtual ~QDesignerIntegration();
static void requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document);
virtual QWidget *containerWindow(QWidget *widget) const;
// Load plugins into widget database and factory.
static void initializePlugins(QDesignerFormEditorInterface *formEditor);
void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
// Create a resource browser specific to integration. Language integration takes precedence
virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0);
signals:
void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value);
void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName);
void helpRequested(const QString &manual, const QString &document);
public slots:
virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling);
// Additional signals of designer property editor
virtual void updatePropertyComment(const QString &name, const QString &value);
virtual void resetProperty(const QString &name);
virtual void addDynamicProperty(const QString &name, const QVariant &value);
virtual void removeDynamicProperty(const QString &name);
virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow);
virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow);
virtual void updateSelection();
virtual void updateGeometry();
virtual void activateWidget(QWidget *widget);
void updateCustomWidgetPlugins();
private slots:
void updatePropertyPrivate(const QString &name, const QVariant &value);
private:
void initialize();
void getSelection(Selection &s);
QObject *propertyEditorObject();
QDesignerIntegrationPrivate *m_d;
};
} // namespace qdesigner_internal
QT_END_NAMESPACE
#endif // QDESIGNER_INTEGRATION_H

View File

@ -0,0 +1,72 @@
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef SHARED_GLOBAL_H
#define SHARED_GLOBAL_H
#include <QtCore/qglobal.h>
#ifdef QT_DESIGNER_STATIC
#define QDESIGNER_SHARED_EXTERN
#define QDESIGNER_SHARED_IMPORT
#else
#define QDESIGNER_SHARED_EXTERN Q_DECL_EXPORT
#define QDESIGNER_SHARED_IMPORT Q_DECL_IMPORT
#endif
#ifndef QT_NO_SHARED_EXPORT
# ifdef QDESIGNER_SHARED_LIBRARY
# define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_EXTERN
# else
# define QDESIGNER_SHARED_EXPORT QDESIGNER_SHARED_IMPORT
# endif
#else
# define QDESIGNER_SHARED_EXPORT
#endif
#endif // SHARED_GLOBAL_H

View File

@ -0,0 +1,10 @@
This is a new Designer integration, started on 28.02.2008.
The reason for it is the introduction of layout caching
in Qt 4.4, which unearthed a lot of mainwindow-size related
bugs in Designer and all integrations.
The goal of it is to have a closed layout chain from
integration top level to form window.
Friedemann

View File

@ -0,0 +1,11 @@
INCLUDEPATH *= $$PWD $$PWD/..
SOURCES += $$PWD/widgethost.cpp \
$$PWD/sizehandlerect.cpp \
$$PWD/formresizer.cpp
HEADERS += $$PWD/widgethost.h \
$$PWD/sizehandlerect.h \
$$PWD/formresizer.h \
$$PWD/widgethostconstants.h \
$$PWD/../namespace_global.h

View File

@ -0,0 +1,198 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "formresizer.h"
#include "sizehandlerect.h"
#include "widgethostconstants.h"
#include <QDebug>
#include <QDesignerFormWindowInterface>
#include <QResizeEvent>
#include <QPalette>
#include <QLayout>
#include <QFrame>
#include <QResizeEvent>
enum { debugFormResizer = 0 };
using namespace SharedTools::Internal;
FormResizer::FormResizer(QWidget *parent) :
QWidget(parent),
m_frame(new QFrame),
m_formWindow(0)
{
// Make the resize grip of a mainwindow form find us as resizable window.
setWindowFlags(windowFlags() | Qt::SubWindow);
setBackgroundRole(QPalette::Base);
QVBoxLayout *handleLayout = new QVBoxLayout(this);
handleLayout->setMargin(SELECTION_MARGIN);
handleLayout->addWidget(m_frame);
m_frame->setFrameStyle(QFrame::Panel | QFrame::Raised);
QVBoxLayout *layout = new QVBoxLayout(m_frame);
layout->setMargin(0);
// handles
m_handles.reserve(SizeHandleRect::Left);
for (int i = SizeHandleRect::LeftTop; i <= SizeHandleRect::Left; ++i) {
SizeHandleRect *shr = new SizeHandleRect(this, static_cast<SizeHandleRect::Direction>(i), this);
connect(shr, SIGNAL(mouseButtonReleased(QRect,QRect)), this, SIGNAL(formWindowSizeChanged(QRect,QRect)));
m_handles.push_back(shr);
}
setState(SelectionHandleActive);
updateGeometry();
}
void FormResizer::updateGeometry()
{
const QRect &geom = m_frame->geometry();
if (debugFormResizer)
qDebug() << "FormResizer::updateGeometry() " << size() << " frame " << geom;
const int w = SELECTION_HANDLE_SIZE;
const int h = SELECTION_HANDLE_SIZE;
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it) {
SizeHandleRect *hndl = *it;;
switch (hndl->dir()) {
case SizeHandleRect::LeftTop:
hndl->move(geom.x() - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::Top:
hndl->move(geom.x() + geom.width() / 2 - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::RightTop:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() - h / 2);
break;
case SizeHandleRect::Right:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() + geom.height() / 2 - h / 2);
break;
case SizeHandleRect::RightBottom:
hndl->move(geom.x() + geom.width() - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::Bottom:
hndl->move(geom.x() + geom.width() / 2 - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::LeftBottom:
hndl->move(geom.x() - w / 2, geom.y() + geom.height() - h / 2);
break;
case SizeHandleRect::Left:
hndl->move(geom.x() - w / 2, geom.y() + geom.height() / 2 - h / 2);
break;
default:
break;
}
}
}
void FormResizer::update()
{
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it) {
(*it)->update();
}
}
void FormResizer::setState(SelectionHandleState st)
{
if (debugFormResizer)
qDebug() << "FormResizer::setState " << st;
const Handles::iterator hend = m_handles.end();
for (Handles::iterator it = m_handles.begin(); it != hend; ++it)
(*it)->setState(st);
}
void FormResizer::setFormWindow(QDesignerFormWindowInterface *fw)
{
if (debugFormResizer)
qDebug() << "FormResizer::setFormWindow " << fw;
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(m_frame->layout());
Q_ASSERT(layout);
if (layout->count())
delete layout->takeAt(0);
m_formWindow = fw;
if (m_formWindow)
layout->addWidget(m_formWindow);
mainContainerChanged();
connect(fw, SIGNAL(mainContainerChanged(QWidget*)), this, SLOT(mainContainerChanged()));
}
void FormResizer::resizeEvent(QResizeEvent *event)
{
if (debugFormResizer)
qDebug() << ">FormResizer::resizeEvent" << event->size();
updateGeometry();
QWidget::resizeEvent(event);
if (debugFormResizer)
qDebug() << "<FormResizer::resizeEvent";
}
QSize FormResizer::decorationSize() const
{
const int lineWidth = m_frame->lineWidth();
const QMargins frameMargins = m_frame->contentsMargins();
const int margin = 2* SELECTION_MARGIN;
QSize size = QSize( margin, margin );
size += QSize( qMax( frameMargins.left(), lineWidth ), qMax( frameMargins.top(), lineWidth ) );
size += QSize( qMax( frameMargins.right(), lineWidth ), qMax( frameMargins.bottom(), lineWidth ) );
return size;
}
QWidget *FormResizer::mainContainer()
{
if (m_formWindow)
return m_formWindow->mainContainer();
return 0;
}
void FormResizer::mainContainerChanged()
{
const QSize maxWidgetSize = QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
if (const QWidget *mc = mainContainer()) {
// Set Maximum size which is not handled via a hint (as opposed to minimum size)
const QSize maxWidgetSize = QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
const QSize formMaxSize = mc->maximumSize();
QSize newMaxSize = maxWidgetSize;
if (formMaxSize != maxWidgetSize)
newMaxSize = formMaxSize + decorationSize();
if (debugFormResizer)
qDebug() << "FormResizer::mainContainerChanged" << mc << " Size " << mc->size()<< newMaxSize;
setMaximumSize(newMaxSize);
resize(decorationSize() + mc->size());
} else {
setMaximumSize(maxWidgetSize);
}
}

View File

@ -0,0 +1,99 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef FORMRESIZER_H
#define FORMRESIZER_H
#include "namespace_global.h"
#include "widgethostconstants.h"
#include <QWidget>
#include <QVector>
QT_FORWARD_DECLARE_CLASS(QDesignerFormWindowInterface)
QT_FORWARD_DECLARE_CLASS(QFrame)
namespace SharedTools {
namespace Internal {
class SizeHandleRect;
/* A window to embed a form window interface as follows:
*
* Widget
* |
* +---+----+
* | |
* | |
* Handles QVBoxLayout [margin: SELECTION_MARGIN]
* |
* Frame [margin: lineWidth]
* |
* QVBoxLayout
* |
* QDesignerFormWindowInterface
*
* Can be embedded into a QScrollArea. */
class FormResizer : public QWidget
{
Q_OBJECT
public:
FormResizer(QWidget *parent = 0);
void updateGeometry();
void setState(SelectionHandleState st);
void update();
void setFormWindow(QDesignerFormWindowInterface *fw);
signals:
void formWindowSizeChanged(const QRect &oldGeo, const QRect &newGeo);
protected:
virtual void resizeEvent(QResizeEvent *event);
private slots:
void mainContainerChanged();
private:
QSize decorationSize() const;
QWidget *mainContainer();
QFrame *m_frame;
typedef QVector<SizeHandleRect*> Handles;
Handles m_handles;
QDesignerFormWindowInterface * m_formWindow;
};
}
} // namespace SharedTools
#endif // FORMRESIZER_H

View File

@ -0,0 +1,188 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "sizehandlerect.h"
#include "widgethostconstants.h"
#include <QDesignerFormWindowInterface>
#include <QMouseEvent>
#include <QPainter>
#include <QFrame>
#include <QDebug>
enum { debugSizeHandle = 0 };
using namespace SharedTools::Internal;
SizeHandleRect::SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable) :
QWidget(parent),
m_dir(d),
m_resizable(resizable),
m_state(SelectionHandleOff)
{
setBackgroundRole(QPalette::Text);
setAutoFillBackground(true);
setFixedSize(SELECTION_HANDLE_SIZE, SELECTION_HANDLE_SIZE);
setMouseTracking(false);
updateCursor();
}
void SizeHandleRect::updateCursor()
{
switch (m_dir) {
case Right:
case RightTop:
setCursor(Qt::SizeHorCursor);
return;
case RightBottom:
setCursor(Qt::SizeFDiagCursor);
return;
case LeftBottom:
case Bottom:
setCursor(Qt::SizeVerCursor);
return;
default:
break;
}
setCursor(Qt::ArrowCursor);
}
void SizeHandleRect::paintEvent(QPaintEvent *)
{
switch (m_state) {
case SelectionHandleOff:
break;
case SelectionHandleInactive: {
QPainter p(this);
p.setPen(Qt::red);
p.drawRect(0, 0, width() - 1, height() - 1);
}
break;
case SelectionHandleActive: {
QPainter p(this);
p.setPen(Qt::blue);
p.drawRect(0, 0, width() - 1, height() - 1);
}
break;
}
}
void SizeHandleRect::mousePressEvent(QMouseEvent *e)
{
e->accept();
if (e->button() != Qt::LeftButton)
return;
m_startSize = m_curSize = m_resizable->size();
m_startPos = m_curPos = m_resizable->mapFromGlobal(e->globalPos());
if (debugSizeHandle)
qDebug() << "SizeHandleRect::mousePressEvent" << m_startSize << m_startPos << m_curPos;
}
void SizeHandleRect::mouseMoveEvent(QMouseEvent *e)
{
if (!(e->buttons() & Qt::LeftButton))
return;
// Try resize with delta against start position.
// We don't take little deltas in consecutive move events as this
// causes the handle and the mouse cursor to become out of sync
// once a min/maxSize limit is hit. When the cursor reenters the valid
// areas, it will now snap to it.
m_curPos = m_resizable->mapFromGlobal(e->globalPos());
QSize delta = QSize(m_curPos.x() - m_startPos.x(), m_curPos.y() - m_startPos.y());
switch (m_dir) {
case Right:
case RightTop: // Only width
delta.setHeight(0);
break;
case RightBottom: // All dimensions
break;
case LeftBottom:
case Bottom: // Only height
delta.setWidth(0);
break;
default:
delta = QSize(0, 0);
break;
}
if (delta != QSize(0, 0))
tryResize(delta);
}
void SizeHandleRect::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() != Qt::LeftButton)
return;
e->accept();
if (m_startSize != m_curSize) {
const QRect startRect = QRect(0, 0, m_startPos.x(), m_startPos.y());
const QRect newRect = QRect(0, 0, m_curPos.x(), m_curPos.y());
if (debugSizeHandle)
qDebug() << "SizeHandleRect::mouseReleaseEvent" << startRect << newRect;
emit mouseButtonReleased(startRect, newRect);
}
}
void SizeHandleRect::tryResize(const QSize &delta)
{
// Try resize with delta against start position
QSize newSize = m_startSize + delta;
newSize = newSize.expandedTo(m_resizable->minimumSizeHint());
newSize = newSize.expandedTo(m_resizable->minimumSize());
newSize = newSize.boundedTo(m_resizable->maximumSize());
if (newSize == m_resizable->size())
return;
if (debugSizeHandle)
qDebug() << "SizeHandleRect::tryResize by (" << m_startSize << '+' << delta << ')' << newSize;
m_resizable->resize(newSize);
m_curSize = m_resizable->size();
}
void SizeHandleRect::setState(SelectionHandleState st)
{
if (st == m_state)
return;
switch (st) {
case SelectionHandleOff:
hide();
break;
case SelectionHandleInactive:
case SelectionHandleActive:
show();
raise();
break;
}
m_state = st;
}

View File

@ -0,0 +1,82 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef SIZEHANDLERECT_H
#define SIZEHANDLERECT_H
#include "namespace_global.h"
#include "widgethostconstants.h"
#include <QWidget>
#include <QPoint>
namespace SharedTools {
namespace Internal {
class SizeHandleRect : public QWidget
{
Q_OBJECT
public:
enum Direction { LeftTop, Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left };
SizeHandleRect(QWidget *parent, Direction d, QWidget *resizable);
Direction dir() const { return m_dir; }
void updateCursor();
void setState(SelectionHandleState st);
signals:
void mouseButtonReleased(const QRect &, const QRect &);
protected:
void paintEvent(QPaintEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
private:
void tryResize(const QSize &delta);
private:
const Direction m_dir;
QPoint m_startPos;
QPoint m_curPos;
QSize m_startSize;
QSize m_curSize;
QWidget *m_resizable;
SelectionHandleState m_state;
};
}
} // namespace SharedTools
#endif // SIZEHANDLERECT_H

View File

@ -0,0 +1,111 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "widgethost.h"
#include "formresizer.h"
#include "widgethostconstants.h"
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowCursorInterface>
#include <QPalette>
#include <QLayout>
#include <QFrame>
#include <QResizeEvent>
#include <QDebug>
using namespace SharedTools;
// ---------- WidgetHost
WidgetHost::WidgetHost(QWidget *parent, QDesignerFormWindowInterface *formWindow) :
QScrollArea(parent),
m_formWindow(0),
m_formResizer(new Internal::FormResizer)
{
setWidget(m_formResizer);
// Re-set flag (gets cleared by QScrollArea): Make the resize grip of a mainwindow form find the resizer as resizable window.
m_formResizer->setWindowFlags(m_formResizer->windowFlags() | Qt::SubWindow);
setFormWindow(formWindow);
}
WidgetHost::~WidgetHost()
{
if (m_formWindow)
delete m_formWindow;
}
void WidgetHost::setFormWindow(QDesignerFormWindowInterface *fw)
{
m_formWindow = fw;
if (!fw)
return;
m_formResizer->setFormWindow(fw);
setBackgroundRole(QPalette::Base);
m_formWindow->setAutoFillBackground(true);
m_formWindow->setBackgroundRole(QPalette::Background);
connect(m_formResizer, SIGNAL(formWindowSizeChanged(QRect, QRect)),
this, SLOT(fwSizeWasChanged(QRect, QRect)));
connect(m_formWindow, SIGNAL(destroyed(QObject*)), this, SLOT(formWindowDeleted(QObject*)));
}
QSize WidgetHost::formWindowSize() const
{
if (!m_formWindow || !m_formWindow->mainContainer())
return QSize();
return m_formWindow->mainContainer()->size();
}
void WidgetHost::fwSizeWasChanged(const QRect &, const QRect &)
{
// newGeo is the mouse coordinates, thus moving the Right will actually emit wrong height
emit formWindowSizeChanged(formWindowSize().width(), formWindowSize().height());
}
void WidgetHost::formWindowDeleted(QObject *object)
{
if (object == m_formWindow) m_formWindow = 0;
}
void WidgetHost::updateFormWindowSelectionHandles(bool active)
{
Internal::SelectionHandleState state = Internal::SelectionHandleOff;
const QDesignerFormWindowCursorInterface *cursor = m_formWindow->cursor();
if (cursor->isWidgetSelected(m_formWindow->mainContainer()))
state = active ? Internal::SelectionHandleActive : Internal::SelectionHandleInactive;
m_formResizer->setState(state);
}
QWidget *WidgetHost::integrationContainer() const
{
return m_formResizer;
}

View File

@ -0,0 +1,80 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef WIDGETHOST_H
#define WIDGETHOST_H
#include "namespace_global.h"
#include <QScrollArea>
QT_FORWARD_DECLARE_CLASS(QDesignerFormWindowInterface)
namespace SharedTools {
namespace Internal {
class FormResizer;
}
/* A scroll area that embeds a Designer form window */
class WidgetHost : public QScrollArea
{
Q_OBJECT
public:
WidgetHost(QWidget *parent = 0, QDesignerFormWindowInterface *formWindow = 0);
virtual ~WidgetHost();
// Show handles if active and main container is selected.
void updateFormWindowSelectionHandles(bool active);
inline QDesignerFormWindowInterface *formWindow() const { return m_formWindow; }
QWidget *integrationContainer() const;
protected:
void setFormWindow(QDesignerFormWindowInterface *fw);
signals:
void formWindowSizeChanged(int, int);
private slots:
void fwSizeWasChanged(const QRect &, const QRect &);
void formWindowDeleted(QObject* object);
private:
QSize formWindowSize() const;
QDesignerFormWindowInterface *m_formWindow;
Internal::FormResizer *m_formResizer;
QSize m_oldFakeWidgetSize;
};
} // namespace SharedTools
#endif // WIDGETHOST_H

View File

@ -0,0 +1,41 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef WIDGETHOST_CONSTANTS_H
#define WIDGETHOST_CONSTANTS_H
namespace SharedTools {
namespace Internal {
enum { SELECTION_HANDLE_SIZE = 6, SELECTION_MARGIN = 10 };
enum SelectionHandleState { SelectionHandleOff, SelectionHandleInactive, SelectionHandleActive };
}
}
#endif // WIDGETHOST_CONSTANTS_H

View File

@ -0,0 +1,48 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef NAMESPACE_GLOBAL_H
#define NAMESPACE_GLOBAL_H
#include <QtCore/qglobal.h>
#if QT_VERSION < 0x040400
# define QT_ADD_NAMESPACE(name) ::name
# define QT_USE_NAMESPACE
# define QT_BEGIN_NAMESPACE
# define QT_END_NAMESPACE
# define QT_BEGIN_INCLUDE_NAMESPACE
# define QT_END_INCLUDE_NAMESPACE
# define QT_BEGIN_MOC_NAMESPACE
# define QT_END_MOC_NAMESPACE
# define QT_FORWARD_DECLARE_CLASS(name) class name;
# define QT_MANGLE_NAMESPACE(name) name
#endif
#endif // NAMESPACE_GLOBAL_H

View File

@ -0,0 +1,20 @@
include(../../common.pri)
include($$PWD/3rdparty/qtcreator/designerintegrationv2/designerintegration.pri)
INCLUDEPATH *= $$PWD/3rdparty/designer
greaterThan(QT_MAJOR_VERSION, 4) {
contains(QT,uitools){
DEFINES += HAVE_QTDESIGNER_INTEGRATION
}
}
lessThan(QT_MAJOR_VERSION, 5){
contains(CONFIG,uitools){
DEFINES += HAVE_QTDESIGNER_INTEGRATION
}
}
QT += designer designercomponents-private
SOURCES += $$PWD/lrdialogdesigner.cpp
HEADERS += $$PWD/lrdialogdesigner.h
RESOURCES += \
$$PWD/dialogdesigner.qrc

View File

@ -0,0 +1,12 @@
<RCC>
<qresource prefix="/images">
<file>images/buddytool.png</file>
<file>images/editform.png</file>
<file>images/signalslottool.png</file>
<file>images/tabordertool.png</file>
<file>images/widgettool.png</file>
</qresource>
<qresource prefix="/templates">
<file>templates/Dialog.ui</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,345 @@
#include "lrdialogdesigner.h"
#include <QPluginLoader>
#include <QDesignerComponents>
#include <QDesignerIntegration>
#include <abstractobjectinspector.h>
#include <QDesignerFormEditorInterface>
#include <QDesignerFormWindowInterface>
#include <QDesignerFormWindowManagerInterface>
#include <QDesignerFormEditorPluginInterface>
#include <QDesignerWidgetBoxInterface>
#include <QDesignerActionEditorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QDesignerObjectInspectorInterface>
#include <QDesignerFormEditorInterface>
#include <QAction>
#include <QDebug>
#include <QVBoxLayout>
#include "pluginmanager_p.h"
//#include <QExtensionManager>
#include "widgethost.h"
namespace LimeReport{
DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
{
QDesignerComponents::initializeResources();
m_formEditor = QDesignerComponents::createFormEditor(this);
QDesignerComponents::initializePlugins(m_formEditor);
QDesignerComponents::createTaskMenu(m_formEditor, this);
m_editWidgetsAction = new QAction(tr("Edit Widgets"), this);
m_editWidgetsAction->setIcon(QIcon(":/images/images/widgettool.png"));
m_editWidgetsAction->setEnabled(false);
connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets()));
connect(m_formEditor->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
this, SLOT(slotActiveFormWindowChanged(QDesignerFormWindowInterface*)) );
m_modes = new QActionGroup(this);
m_modes->setExclusive(true);
m_modes->addAction(m_editWidgetsAction);
foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() )
{
if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) )
{
if ( !fep->isInitialized() )
fep->initialize( m_formEditor );
fep->action()->setCheckable( true );
fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName())));
m_modes->addAction(fep->action());
}
}
m_widgetBox = QDesignerComponents::createWidgetBox(m_formEditor, 0);
m_widgetBox->setWindowTitle(tr("Widget Box"));
m_widgetBox->setObjectName(QLatin1String("WidgetBox"));
m_formEditor->setWidgetBox(m_widgetBox);
m_formEditor->setTopLevel(m_widgetBox);
m_designerToolWindows.append(m_widgetBox);
connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0);
m_objectInspector->setWindowTitle(tr("Object Inspector"));
m_objectInspector->setObjectName(QLatin1String("ObjectInspector"));
m_formEditor->setObjectInspector(m_objectInspector);
m_designerToolWindows.append(m_objectInspector);
connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0);
m_propertyEditor->setWindowTitle(tr("Property Editor"));
m_propertyEditor->setObjectName(QLatin1String("PropertyEditor"));
m_formEditor->setPropertyEditor(m_propertyEditor);
m_designerToolWindows.append(m_propertyEditor);
connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0);
m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor"));
m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor"));
m_designerToolWindows.append(m_signalSlotEditor);
connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0);
m_resourcesEditor->setWindowTitle(tr("Resource Editor"));
m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor"));
m_designerToolWindows.append(m_resourcesEditor);
connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0);
m_actionEditor->setWindowTitle(tr("Action Editor"));
m_actionEditor->setObjectName("ActionEditor");
m_formEditor->setActionEditor(m_actionEditor);
m_designerToolWindows.append(m_actionEditor);
connect(m_actionEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_designerIntegration = new QDesignerIntegration(m_formEditor,this);
m_formEditor->setIntegration(m_designerIntegration);
}
DialogDesignerManager::~DialogDesignerManager()
{
for (int i = 0; i<m_designerToolWindows.size();++i){
if (m_designerToolWindows[i])
delete m_designerToolWindows[i];
}
delete m_designerIntegration;
delete m_formEditor;
}
void DialogDesignerManager::initToolBar(QToolBar *tb)
{
tb->setIconSize(QSize(16,16));
m_formEditor->formWindowManager()->actionCopy()->setIcon(QIcon(":/report/images/copy"));
tb->addAction(m_formEditor->formWindowManager()->actionCopy());
m_formEditor->formWindowManager()->actionPaste()->setIcon(QIcon(":/report/images/paste"));
tb->addAction(m_formEditor->formWindowManager()->actionPaste());
m_formEditor->formWindowManager()->actionCut()->setIcon(QIcon(":/report/images/cut"));
tb->addAction(m_formEditor->formWindowManager()->actionCut());
m_formEditor->formWindowManager()->actionUndo()->setIcon(QIcon(":/report/images/undo"));
tb->addAction(m_formEditor->formWindowManager()->actionUndo());
m_formEditor->formWindowManager()->actionRedo()->setIcon(QIcon(":/report/images/redo"));
tb->addAction(m_formEditor->formWindowManager()->actionRedo());
tb->addActions(m_modes->actions());
tb->addAction(m_formEditor->formWindowManager()->actionHorizontalLayout());
tb->addAction(m_formEditor->formWindowManager()->actionVerticalLayout());
tb->addAction(m_formEditor->formWindowManager()->actionSplitHorizontal());
tb->addAction(m_formEditor->formWindowManager()->actionSplitVertical());
tb->addAction(m_formEditor->formWindowManager()->actionGridLayout());
m_formEditor->formWindowManager()->actionFormLayout()->setIcon(QIcon(":/images/images/editform.png"));
tb->addAction(m_formEditor->formWindowManager()->actionFormLayout());
tb->addAction(m_formEditor->formWindowManager()->actionBreakLayout());
tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize());
}
QWidget *DialogDesignerManager::createFormEditor(const QString &content)
{
QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
wnd->setContents(content);
m_formEditor->formWindowManager()->setActiveFormWindow(wnd);
m_formEditor->objectInspector()->setFormWindow(wnd);
wnd->editWidgets();
DialogDesigner* dialogDesigner = new DialogDesigner(wnd, m_formEditor);
connect(dialogDesigner, SIGNAL(dialogChanged()), this, SLOT(slotDialogChanged()));
connect(dialogDesigner, SIGNAL(dialogNameChanged(QString,QString)), this, SIGNAL(dialogNameChanged(QString,QString)));
connect(dialogDesigner, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
m_dialogDesigners.append(dialogDesigner);
return dialogDesigner;
}
QByteArray DialogDesignerManager::getDialogDescription(QWidget *form)
{
QByteArray result;
DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(form);
Q_ASSERT(dialogDesigner != NULL);
//SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form);
if (dialogDesigner){
result = dialogDesigner->dialogContent();
//wh->formWindow()->setDirty(false);
}
return result;
}
void DialogDesignerManager::setActiveEditor(QWidget *widget)
{
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget);
if (wh){
m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow());
}
}
void DialogDesignerManager::setDirty(bool value)
{
foreach(DialogDesigner* dialogDesigner, m_dialogDesigners){
dialogDesigner->setChanged(value);
}
}
QWidget* DialogDesignerManager::widgetBox() const
{
return m_widgetBox;
}
QWidget* DialogDesignerManager::actionEditor() const
{
return m_actionEditor;
}
QWidget* DialogDesignerManager::propertyEditor() const
{
return m_propertyEditor;
}
QWidget* DialogDesignerManager::objectInspector() const
{
return m_objectInspector;
}
QWidget *DialogDesignerManager::signalSlotEditor() const
{
return m_signalSlotEditor;
}
QWidget *DialogDesignerManager::resourcesEditor() const
{
return m_resourcesEditor;
}
void DialogDesignerManager::slotObjectDestroyed(QObject* object)
{
QList<DialogDesigner*>::Iterator it = m_dialogDesigners.begin();
while(it!=m_dialogDesigners.end()){
if (*it == object){
it = m_dialogDesigners.erase(it);
return;
} else {
++it;
}
}
for ( int i = 0; i<m_designerToolWindows.size();++i){
m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
}
}
void DialogDesignerManager::slotEditWidgets()
{
for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){
m_formEditor->formWindowManager()->formWindow(i)->editWidgets();
}
}
void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow)
{
if (formWindow){
m_editWidgetsAction->setEnabled(true);
m_activeWindowName = formWindow->objectName();
}
}
void DialogDesignerManager::slotDialogChanged()
{
DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(sender());
if (dialogDesigner){
emit dialogChanged(dialogDesigner->dialogName());
}
}
QString DialogDesignerManager::iconPathByName(const QString &name)
{
if (name.compare("__qt_edit_signals_slots_action") == 0)
return ":/images/images/signalslottool.png";
if (name.compare("__qt_edit_buddies_action") == 0)
return ":/images/images/buddytool.png";
if (name.compare("_qt_edit_tab_order_action") == 0)
return ":/images/images/tabordertool.png";
return "";
}
DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent, Qt::WindowFlags flags)
:QWidget(parent, flags), m_formEditor(formEditor)
{
m_dialogName = wnd->mainContainer()->objectName();
connect(wnd, SIGNAL(changed()), this, SIGNAL(dialogChanged()));
connect(wnd->mainContainer(), SIGNAL(objectNameChanged(QString)), this, SLOT(slotMainContainerNameChanged(QString)));
m_designerHolder = new SharedTools::WidgetHost(this,wnd);
m_designerHolder->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
m_designerHolder->setFocusProxy( wnd );
QVBoxLayout* l = new QVBoxLayout(this);
l->addWidget(m_designerHolder);
setLayout(l);
}
DialogDesigner::~DialogDesigner(){}
QString DialogDesigner::dialogName() const
{
return m_dialogName;
}
void DialogDesigner::setDialogName(const QString &dialogName)
{
m_dialogName = dialogName;
}
bool DialogDesigner::isChanged()
{
return m_designerHolder->formWindow()->isDirty();
}
void DialogDesigner::setChanged(bool value)
{
m_designerHolder->formWindow()->setDirty(false);
}
QByteArray DialogDesigner::dialogContent()
{
if (m_designerHolder && m_designerHolder->formWindow())
return m_designerHolder->formWindow()->contents().toUtf8();
return QByteArray();
}
void DialogDesigner::undo()
{
Q_ASSERT(m_formEditor != NULL);
if (m_formEditor){
m_formEditor->formWindowManager()->actionUndo()->trigger();
}
}
void DialogDesigner::redo()
{
Q_ASSERT(m_formEditor != NULL);
if (m_formEditor){
m_formEditor->formWindowManager()->actionRedo()->trigger();
}
}
void DialogDesigner::slotMainContainerNameChanged(QString newName)
{
if (m_dialogName.compare(newName) != 0){
emit dialogNameChanged(m_dialogName, newName);
m_dialogName = newName;
}
}
}

View File

@ -0,0 +1,93 @@
#ifndef DIALOGDESIGNER_H
#define DIALOGDESIGNER_H
#include <QObject>
#include <QVector>
#include <QToolBar>
class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface;
class QDesignerIntegrationInterface;
class QDesignerWidgetBoxInterface;
class QDesignerActionEditorInterface;
class QDesignerPropertyEditorInterface;
class QDesignerObjectInspectorInterface;
class QDesignerFormWindowManagerInterface;
namespace SharedTools{
class WidgetHost;
}
namespace LimeReport{
class DialogDesigner : public QWidget{
Q_OBJECT
public:
DialogDesigner(QDesignerFormWindowInterface *wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~DialogDesigner();
QString dialogName() const;
void setDialogName(const QString &dialogName);
bool isChanged();
void setChanged(bool value);
QByteArray dialogContent();
public slots:
void undo();
void redo();
signals:
void dialogChanged();
void dialogNameChanged(QString oldName, QString newName);
private slots:
void slotMainContainerNameChanged(QString newName);
private:
QString m_dialogName;
SharedTools::WidgetHost* m_designerHolder;
QDesignerFormEditorInterface* m_formEditor;
};
class DialogDesignerManager : public QObject
{
Q_OBJECT
public:
explicit DialogDesignerManager(QObject *parent = 0);
~DialogDesignerManager();
void initToolBar(QToolBar* tb);
QWidget* createFormEditor(const QString& content);
QByteArray getDialogDescription(QWidget* form);
void setActiveEditor(QWidget* widget);
void setDirty(bool value);
QWidget* widgetBox() const;
QWidget* actionEditor() const;
QWidget* propertyEditor() const;
QWidget* objectInspector() const;
QWidget* signalSlotEditor() const;
QWidget* resourcesEditor() const;
signals:
void dialogChanged(QString dialogName);
void dialogNameChanged(QString oldName, QString newName);
private slots:
void slotObjectDestroyed(QObject* object);
void slotEditWidgets();
void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow);
void slotDialogChanged();
private:
QString iconPathByName(const QString& name);
private:
QDesignerFormEditorInterface* m_formEditor;
QDesignerIntegrationInterface* m_designerIntegration;
QDesignerWidgetBoxInterface* m_widgetBox;
QDesignerActionEditorInterface* m_actionEditor;
QDesignerPropertyEditorInterface* m_propertyEditor;
QDesignerObjectInspectorInterface* m_objectInspector;
QWidget* m_signalSlotEditor;
QWidget* m_resourcesEditor;
QVector<QWidget*> m_designerToolWindows;
QAction* m_editWidgetsAction;
QActionGroup* m_modes;
QString m_activeWindowName;
QList<DialogDesigner*> m_dialogDesigners;
};
} // namespace LimeReport
#endif // DIALOGDESIGNER_H

View File

@ -0,0 +1,18 @@
<ui version="4.0" >
<class>$ClassName$</class>
<widget class="QDialog" name="$ClassName$" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>$ClassName$</string>
</property>
</widget>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
limereport/images/copy3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 518 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 849 B

After

Width:  |  Height:  |  Size: 466 B

View File

@ -702,7 +702,7 @@ bool TextItem::isNeedUpdateSize(RenderPass pass) const
{
Q_UNUSED(pass)
if ((autoHeight() && autoWidth()) || hasFollower()){
if ((autoHeight() || autoWidth()) || hasFollower()){
initTextSizes();
}

View File

@ -1,5 +1,9 @@
include(../common.pri)
contains(CONFIG,dialogdesigner){
include($$REPORT_PATH/dialogdesigner/dialogdesigner.pri)
}
DEFINES += INSPECT_BASEDESIGN
INCLUDEPATH += \
@ -19,6 +23,15 @@ SOURCES += \
$$REPORT_PATH/bands/lrgroupbands.cpp \
$$REPORT_PATH/bands/lrsubdetailband.cpp \
$$REPORT_PATH/bands/lrtearoffband.cpp \
$$REPORT_PATH/databrowser/lrdatabrowser.cpp \
$$REPORT_PATH/databrowser/lrsqleditdialog.cpp \
$$REPORT_PATH/databrowser/lrconnectiondialog.cpp \
$$REPORT_PATH/databrowser/lrvariabledialog.cpp \
$$REPORT_PATH/databrowser/lrdatabrowsertree.cpp \
$$REPORT_PATH/serializators/lrxmlqrectserializator.cpp \
$$REPORT_PATH/serializators/lrxmlbasetypesserializators.cpp \
$$REPORT_PATH/serializators/lrxmlreader.cpp \
$$REPORT_PATH/serializators/lrxmlwriter.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrstringpropitem.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrrectproptem.cpp \
$$REPORT_PATH/objectinspector/propertyItems/lrintpropitem.cpp \
@ -45,15 +58,7 @@ SOURCES += \
$$REPORT_PATH/objectinspector/lrobjectpropitem.cpp \
$$REPORT_PATH/objectinspector/lrpropertydelegate.cpp \
$$REPORT_PATH/objectsbrowser/lrobjectbrowser.cpp \
$$REPORT_PATH/databrowser/lrdatabrowser.cpp \
$$REPORT_PATH/databrowser/lrsqleditdialog.cpp \
$$REPORT_PATH/databrowser/lrconnectiondialog.cpp \
$$REPORT_PATH/databrowser/lrvariabledialog.cpp \
$$REPORT_PATH/databrowser/lrdatabrowsertree.cpp \
$$REPORT_PATH/serializators/lrxmlqrectserializator.cpp \
$$REPORT_PATH/serializators/lrxmlbasetypesserializators.cpp \
$$REPORT_PATH/serializators/lrxmlreader.cpp \
$$REPORT_PATH/serializators/lrxmlwriter.cpp \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \
$$REPORT_PATH/items/lrsubitemparentpropitem.cpp \
$$REPORT_PATH/items/lralignpropitem.cpp \
$$REPORT_PATH/items/lrhorizontallayout.cpp \
@ -89,7 +94,8 @@ SOURCES += \
$$REPORT_PATH/lrsimplecrypt.cpp \
$$REPORT_PATH/lraboutdialog.cpp \
$$REPORT_PATH/lrsettingdialog.cpp \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp
$$REPORT_PATH/lritemscontainerdesignitf.cpp
contains(CONFIG, zint){
SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp
@ -145,6 +151,7 @@ HEADERS += \
$$REPORT_PATH/objectinspector/lrobjectpropitem.h \
$$REPORT_PATH/objectinspector/lrpropertydelegate.h \
$$REPORT_PATH/objectsbrowser/lrobjectbrowser.h \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h \
$$REPORT_PATH/items/editors/lritemeditorwidget.h \
$$REPORT_PATH/items/editors/lrfonteditorwidget.h \
$$REPORT_PATH/items/editors/lrtextalignmenteditorwidget.h \
@ -188,7 +195,7 @@ HEADERS += \
$$REPORT_PATH/lrcallbackdatasourceintf.h \
$$REPORT_PATH/lrsettingdialog.h \
$$REPORT_PATH/lrpreviewreportwidget_p.h \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.h
$$REPORT_PATH/lritemscontainerdesignitf.h
contains(CONFIG,zint){
HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h

View File

@ -99,33 +99,8 @@ void BandMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
}
bool Segment::intersect(Segment value)
{
return ((value.m_end>=m_begin)&&(value.m_end<=m_end)) ||
((value.m_begin>=m_begin)&&(value.m_end>=m_end)) ||
((value.m_begin>=m_begin)&&(value.m_end<=m_end)) ||
((value.m_begin<m_begin)&&(value.m_end>m_end)) ;
}
qreal Segment::intersectValue(Segment value)
{
if ((value.m_end>=m_begin)&&(value.m_end<=m_end)){
return value.m_end-m_begin;
}
if ((value.m_begin>=m_begin)&&(value.m_end>=m_end)){
return m_end-value.m_begin;
}
if ((value.m_begin>=m_begin)&&(value.m_end<=m_end)){
return value.m_end-value.m_begin;
}
if ((value.m_begin<m_begin)&&(value.m_end>m_end)){
return m_end-m_begin;
}
return 0;
}
BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, QObject* owner, QGraphicsItem *parent) :
BaseDesignIntf(xmlTypeName, owner,parent),
ItemsContainerDesignInft(xmlTypeName, owner,parent),
m_bandType(bandType),
m_bandIndex(static_cast<int>(bandType)),
m_dataSourceName(""),
@ -461,6 +436,19 @@ void BandDesignIntf::processPopUpAction(QAction *action)
}
}
void BandDesignIntf::recalcItems(DataSourceManager* dataManager)
{
foreach(BaseDesignIntf* bi, childBaseItems()){
ContentItemDesignIntf* ci = dynamic_cast<ContentItemDesignIntf*>(bi);
if (bi){
ContentItemDesignIntf* pci = dynamic_cast<ContentItemDesignIntf*>(bi->patternItem());
ci->setContent(pci->content());
}
}
updateItemSize(dataManager,FirstPass,height());
}
BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
{
int maxBottom = 0;
@ -582,97 +570,11 @@ void BandDesignIntf::setSplittable(bool value){
}
}
bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2)
{
VSegment vS1(c1->m_rect),vS2(c2->m_rect);
HSegment hS1(c1->m_rect),hS2(c2->m_rect);
if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2))
return c1->m_rect.x()<c2->m_rect.x();
else return c1->m_rect.y()<c2->m_rect.y();
}
bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2)
{
return b1->bandIndex()<b2->bandIndex();
}
void BandDesignIntf::snapshotItemsLayout()
{
m_bandItems.clear();
foreach(BaseDesignIntf *childItem,childBaseItems()){
m_bandItems.append(PItemSortContainer(new ItemSortContainer(childItem)));
}
qSort(m_bandItems.begin(),m_bandItems.end(),itemSortContainerLessThen);
}
void BandDesignIntf::arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type)
{
bool needArrage=(type==Force);
foreach (PItemSortContainer item, m_bandItems) {
if (item->m_item->isNeedUpdateSize(pass)){
item->m_item->updateItemSize(dataManager, pass);
needArrage=true;
}
}
if (needArrage){
//qSort(m_bandItems.begin(),m_bandItems.end(),itemSortContainerLessThen);
for (int i=0;i<m_bandItems.count();i++)
for (int j=i;j<m_bandItems.count();j++){
if ((i!=j) && (m_bandItems[i]->m_item->collidesWithItem(m_bandItems[j]->m_item))){
HSegment hS1(m_bandItems[j]->m_rect),hS2(m_bandItems[i]->m_rect);
VSegment vS1(m_bandItems[j]->m_rect),vS2(m_bandItems[i]->m_rect);
if (m_bandItems[i]->m_rect.bottom()<m_bandItems[i]->m_item->geometry().bottom()){
if (hS1.intersectValue(hS2)>vS1.intersectValue(vS2))
m_bandItems[j]->m_item->setY(m_bandItems[i]->m_item->y()+m_bandItems[i]->m_item->height()
+m_bandItems[j]->m_rect.top()-m_bandItems[i]->m_rect.bottom());
}
if (m_bandItems[i]->m_rect.right()<m_bandItems[i]->m_item->geometry().right()){
if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2))
m_bandItems[j]->m_item->setX(m_bandItems[i]->m_item->geometry().right()+
(m_bandItems[j]->m_rect.x()-m_bandItems[i]->m_rect.right()));
}
}
}
}
if(needArrage||pass==FirstPass){
int maxBottom = findMaxBottom();
foreach(BaseDesignIntf* item,childBaseItems()){
ItemDesignIntf* childItem=dynamic_cast<ItemDesignIntf*>(item);
if (childItem){
if (childItem->stretchToMaxHeight())
childItem->setHeight(maxBottom-childItem->geometry().top());
}
}
}
}
qreal BandDesignIntf::findMaxBottom()
{
qreal maxBottom=0;
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) )
maxBottom=subItem->geometry().bottom();
}
return maxBottom;
}
qreal BandDesignIntf::findMaxHeight(){
qreal maxHeight=0;
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if (subItem->geometry().height()>maxHeight) maxHeight=subItem->geometry().height();
}
return maxHeight;
}
void BandDesignIntf::trimToMaxHeight(int maxHeight)
{
foreach(BaseDesignIntf* item,childBaseItems()){
@ -966,6 +868,17 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
void BandDesignIntf::restoreItems()
{
foreach(BaseDesignIntf* bi, childBaseItems()){
ContentItemDesignIntf* ci = dynamic_cast<ContentItemDesignIntf*>(bi);
if (ci){
ContentItemDesignIntf* pci = dynamic_cast<ContentItemDesignIntf*>(bi->patternItem());
ci->setContent(pci->content());
}
}
}
void BandDesignIntf::updateBandNameLabel()
{
if (m_bandNameLabel) m_bandNameLabel->updateLabel();

View File

@ -31,6 +31,7 @@
#define LRBANDDESIGNINTF_H
#include "lrbasedesignintf.h"
#include "lrdatasourcemanager.h"
#include "lritemscontainerdesignitf.h"
#include <QObject>
namespace LimeReport {
@ -81,10 +82,7 @@ private:
BandDesignIntf* m_band;
};
struct ItemSortContainer;
typedef QSharedPointer< ItemSortContainer > PItemSortContainer;
class BandDesignIntf : public BaseDesignIntf
class BandDesignIntf : public ItemsContainerDesignInft
{
Q_OBJECT
Q_PROPERTY(bool autoHeight READ autoHeight WRITE setAutoHeight )
@ -128,6 +126,8 @@ public:
virtual QIcon bandIcon() const;
virtual bool isUnique() const;
void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
void restoreItems();
void recalcItems(DataSourceManager* dataManager);
void updateBandNameLabel();
virtual QColor selectionColor() const;
@ -221,14 +221,10 @@ public:
void setAlternateBackgroundColor(const QColor &alternateBackgroundColor);
bool useAlternateBackgroundColor() const;
void setUseAlternateBackgroundColor(bool useAlternateBackgroundColor);
void replaceGroupsFunction(BandDesignIntf *band);
signals:
void bandRendered(BandDesignIntf* band);
protected:
void snapshotItemsLayout();
void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded);
qreal findMaxBottom();
qreal findMaxHeight();
void trimToMaxHeight(int maxHeight);
void setBandTypeText(const QString& value);
QString bandTypeText(){return m_bandTypeText;}
@ -248,6 +244,7 @@ protected:
void moveItemsDown(qreal startPos, qreal offset);
void preparePopUpMenu(QMenu &menu);
void processPopUpAction(QAction *action);
private slots:
void childBandDeleted(QObject* band);
private:
@ -289,37 +286,7 @@ public:
DataBandDesignIntf(BandsType bandType, QString xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
};
class Segment{
public:
Segment(qreal segmentStart,qreal segmentEnd):m_begin(segmentStart),m_end(segmentEnd){}
bool intersect(Segment value);
qreal intersectValue(Segment value);
private:
qreal m_begin;
qreal m_end;
};
class VSegment : public Segment{
public:
VSegment(QRectF rect):Segment(rect.top(),rect.bottom()){}
};
struct HSegment :public Segment{
public:
HSegment(QRectF rect):Segment(rect.left(),rect.right()){}
};
struct ItemSortContainer {
QRectF m_rect;
BaseDesignIntf * m_item;
ItemSortContainer(BaseDesignIntf *item){
m_item=item;
m_rect=item->geometry();
}
};
bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2);
bool bandIndexLessThen(const BandDesignIntf* b1, const BandDesignIntf* b2);
}
} // namespace LimeReport
#endif // LRBANDDESIGNINTF_H

View File

@ -39,7 +39,6 @@
#include "serializators/lrxmlreader.h"
#include <memory>
#include <QMetaObject>
#include <QGraphicsSceneMouseEvent>
#include <QApplication>
@ -79,7 +78,8 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_changingItemAlign(false),
m_borderColor(Qt::black),
m_reportSettings(0),
m_patternName("")
m_patternName(""),
m_patternItem(0)
{
setGeometry(QRectF(0, 0, m_width, m_height));
if (BaseDesignIntf *item = dynamic_cast<BaseDesignIntf *>(parent)) {
@ -712,6 +712,16 @@ void BaseDesignIntf::setPatternName(const QString &patternName)
m_patternName = patternName;
}
BaseDesignIntf* BaseDesignIntf::patternItem() const
{
return m_patternItem;
}
void BaseDesignIntf::setPatternItem(BaseDesignIntf *patternItem)
{
m_patternItem = patternItem;
}
ReportSettings *BaseDesignIntf::reportSettings() const
{
return m_reportSettings;
@ -1330,6 +1340,7 @@ BaseDesignIntf *BaseDesignIntf::cloneItem(ItemMode mode, QObject *owner, QGraphi
{
BaseDesignIntf *clone = cloneItemWOChild(mode, owner, parent);
clone->setPatternName(this->objectName());
clone->setPatternItem(this);
#ifdef HAVE_QT5
foreach(QObject * child, children()) {
#else
@ -1525,8 +1536,7 @@ BaseDesignIntf *Marker::object() const
return m_object;
}
}
} //namespace LimeReport

View File

@ -272,6 +272,8 @@ public:
void setZValueProperty(qreal value);
QString patternName() const;
void setPatternName(const QString &patternName);
BaseDesignIntf* patternItem() const;
void setPatternItem(BaseDesignIntf* patternItem);
Q_INVOKABLE QString setItemWidth(qreal width);
Q_INVOKABLE QString setItemHeight(qreal height);
@ -397,6 +399,7 @@ private:
QColor m_borderColor;
ReportSettings* m_reportSettings;
QString m_patternName;
BaseDesignIntf* m_patternItem;
signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanged(QObject* object, QPointF newPos, QPointF oldPos);

View File

@ -258,7 +258,11 @@ void DataSourceManager::clearGroupFuntionsExpressions()
QString DataSourceManager::getExpression(QString index)
{
bool ok = false;
int i = index.toInt(&ok);
if (ok && m_groupFunctionsExpressions.size()>i)
return m_groupFunctionsExpressions.at(index.toInt());
else return "";
}
bool DataSourceManager::designTime() const

View File

@ -0,0 +1,117 @@
#include "lritemscontainerdesignitf.h"
#include "lritemdesignintf.h"
namespace LimeReport {
bool Segment::intersect(Segment value)
{
return ((value.m_end>=m_begin)&&(value.m_end<=m_end)) ||
((value.m_begin>=m_begin)&&(value.m_end>=m_end)) ||
((value.m_begin>=m_begin)&&(value.m_end<=m_end)) ||
((value.m_begin<m_begin)&&(value.m_end>m_end)) ;
}
qreal Segment::intersectValue(Segment value)
{
if ((value.m_end>=m_begin)&&(value.m_end<=m_end)){
return value.m_end-m_begin;
}
if ((value.m_begin>=m_begin)&&(value.m_end>=m_end)){
return m_end-value.m_begin;
}
if ((value.m_begin>=m_begin)&&(value.m_end<=m_end)){
return value.m_end-value.m_begin;
}
if ((value.m_begin<m_begin)&&(value.m_end>m_end)){
return m_end-m_begin;
}
return 0;
}
bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2)
{
VSegment vS1(c1->m_rect),vS2(c2->m_rect);
HSegment hS1(c1->m_rect),hS2(c2->m_rect);
if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2))
return c1->m_rect.x()<c2->m_rect.x();
else return c1->m_rect.y()<c2->m_rect.y();
}
void ItemsContainerDesignInft::snapshotItemsLayout()
{
m_containerItems.clear();
foreach(BaseDesignIntf *childItem,childBaseItems()){
m_containerItems.append(PItemSortContainer(new ItemSortContainer(childItem)));
}
qSort(m_containerItems.begin(),m_containerItems.end(),itemSortContainerLessThen);
}
void ItemsContainerDesignInft::arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type)
{
bool needArrage=(type==Force);
foreach (PItemSortContainer item, m_containerItems) {
if (item->m_item->isNeedUpdateSize(pass)){
item->m_item->updateItemSize(dataManager, pass);
needArrage=true;
}
}
if (needArrage){
for (int i=0;i<m_containerItems.count();i++){
for (int j=i;j<m_containerItems.count();j++){
if ((i!=j) && (m_containerItems[i]->m_item->collidesWithItem(m_containerItems[j]->m_item))){
HSegment hS1(m_containerItems[j]->m_rect),hS2(m_containerItems[i]->m_rect);
VSegment vS1(m_containerItems[j]->m_rect),vS2(m_containerItems[i]->m_rect);
if (m_containerItems[i]->m_rect.bottom()<m_containerItems[i]->m_item->geometry().bottom()){
if (hS1.intersectValue(hS2)>vS1.intersectValue(vS2))
m_containerItems[j]->m_item->setY(m_containerItems[i]->m_item->y()+m_containerItems[i]->m_item->height()
+m_containerItems[j]->m_rect.top()-m_containerItems[i]->m_rect.bottom());
}
if (m_containerItems[i]->m_rect.right()<m_containerItems[i]->m_item->geometry().right()){
if (vS1.intersectValue(vS2)>hS1.intersectValue(hS2))
m_containerItems[j]->m_item->setX(m_containerItems[i]->m_item->geometry().right()+
(m_containerItems[j]->m_rect.x()-m_containerItems[i]->m_rect.right()));
}
}
}
}
}
if (needArrage||pass==FirstPass){
int maxBottom = findMaxBottom();
foreach(BaseDesignIntf* item,childBaseItems()){
ItemDesignIntf* childItem=dynamic_cast<ItemDesignIntf*>(item);
if (childItem){
if (childItem->stretchToMaxHeight())
childItem->setHeight(maxBottom-childItem->geometry().top());
}
}
}
}
qreal ItemsContainerDesignInft::findMaxBottom()
{
qreal maxBottom=0;
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if ( subItem->isVisible() && (subItem->geometry().bottom()>maxBottom) )
maxBottom=subItem->geometry().bottom();
}
return maxBottom;
}
qreal ItemsContainerDesignInft::findMaxHeight()
{
qreal maxHeight=0;
foreach(QGraphicsItem* item,childItems()){
BaseDesignIntf* subItem = dynamic_cast<BaseDesignIntf *>(item);
if(subItem)
if (subItem->geometry().height()>maxHeight) maxHeight=subItem->geometry().height();
}
return maxHeight;
}
} // namespace LimeReport

View File

@ -0,0 +1,56 @@
#ifndef ITEMSCONTAINERDESIGNITF_H
#define ITEMSCONTAINERDESIGNITF_H
#include "lrbasedesignintf.h"
namespace LimeReport{
class Segment{
public:
Segment(qreal segmentStart,qreal segmentEnd):m_begin(segmentStart),m_end(segmentEnd){}
bool intersect(Segment value);
qreal intersectValue(Segment value);
private:
qreal m_begin;
qreal m_end;
};
class VSegment : public Segment{
public:
VSegment(QRectF rect):Segment(rect.top(),rect.bottom()){}
};
struct HSegment :public Segment{
public:
HSegment(QRectF rect):Segment(rect.left(),rect.right()){}
};
struct ItemSortContainer {
QRectF m_rect;
BaseDesignIntf * m_item;
ItemSortContainer(BaseDesignIntf *item){
m_item=item;
m_rect=item->geometry();
}
};
typedef QSharedPointer< ItemSortContainer > PItemSortContainer;
bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2);
class ItemsContainerDesignInft : public BaseDesignIntf{
public:
ItemsContainerDesignInft(const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0):
BaseDesignIntf(xmlTypeName, owner, parent){}
protected:
void snapshotItemsLayout();
void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded);
qreal findMaxBottom();
qreal findMaxHeight();
private:
QVector<PItemSortContainer> m_containerItems;
};
} // namespace LimeReport
#endif // ITEMSCONTAINERDESIGNITF_H

View File

@ -46,24 +46,26 @@ bool bandSortBandLessThenByIndex(const BandDesignIntf *c1, const BandDesignIntf
}
PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
BaseDesignIntf("PageItem",owner,parent),
ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
initPageSize(m_pageSize);
}
PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &rect, QObject *owner, QGraphicsItem *parent) :
BaseDesignIntf("PageItem",owner,parent),
ItemsContainerDesignInft("PageItem",owner,parent),
m_topMargin(0), m_bottomMargin(0), m_leftMargin(0), m_rightMargin(0),
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false)
{
setFixedPos(true);
setPossibleResizeDirectionFlags(Fixed);
setFlag(QGraphicsItem::ItemClipsChildrenToShape);
initPageSize(rect.size());
}
@ -316,6 +318,12 @@ void PageItemDesignIntf::setResetPageNumber(bool resetPageNumber)
}
}
void PageItemDesignIntf::updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager)
{
snapshotItemsLayout();
arrangeSubItems(pass, dataManager);
}
bool PageItemDesignIntf::oldPrintMode() const
{
return m_oldPrintMode;

View File

@ -31,13 +31,14 @@
#define LRPAGEITEM_H
#include "lrbasedesignintf.h"
#include "lrbanddesignintf.h"
#include "lritemscontainerdesignitf.h"
#include <QList>
#include <QColor>
namespace LimeReport{
class ReportRender;
class PageItemDesignIntf : public LimeReport::BaseDesignIntf
class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft
{
Q_OBJECT
Q_ENUMS(Orientation)
@ -115,6 +116,7 @@ public:
bool canContainChildren(){ return true;}
bool resetPageNumber() const;
void setResetPageNumber(bool resetPageNumber);
void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager);
protected slots:
void bandDeleted(QObject* band);

View File

@ -33,6 +33,7 @@
#include "lrreportengine_p.h"
#include "lrbasedesignintf.h"
#include "lrsettingdialog.h"
#include "dialogdesigner/lrdialogdesigner.h"
#include <QDebug>
#include <QObject>
@ -49,7 +50,11 @@ namespace LimeReport {
// ReportDesignIntf
ReportDesignWidget::ReportDesignWidget(ReportEngine *report, QMainWindow *mainWindow, QWidget *parent) :
QWidget(parent), m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false)
QWidget(parent),
#ifdef HAVE_QTDESIGNER_INTEGRATION
m_dialogDesignerManager(new DialogDesignerManager(this)),
#endif
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false)
{
m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South);
@ -72,15 +77,86 @@ ReportDesignWidget::ReportDesignWidget(ReportEngine *report, QMainWindow *mainWi
connect(m_report,SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished()));
connect(m_report,SIGNAL(cleared()),this,SIGNAL(cleared()));
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));
connect(m_report->scriptContext(), SIGNAL(dialogDeleted(QString)), this, SLOT(slotDialogDeleted(QString)));
//m_instance=this;
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
m_zoomer = new GraphicsViewZoomer(activeView());
#ifdef Q_OS_WIN
m_defaultFont = QFont("Arial",10);
#endif
#ifdef HAVE_QTDESIGNER_INTEGRATION
connect(m_dialogDesignerManager, SIGNAL(dialogChanged(QString)),
this, SLOT(slotDialogChanged(QString)));
connect(m_dialogDesignerManager, SIGNAL(dialogNameChanged(QString,QString)),
this, SLOT(slotDialogNameChanged(QString,QString)));
#endif
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
DialogDesignerManager *ReportDesignWidget::dialogDesignerManager() const
{
return m_dialogDesignerManager;
}
QString ReportDesignWidget::activeDialogName()
{
if (activeDialogPage())
return activeDialogPage()->dialogName();
return "";
}
QWidget *ReportDesignWidget::toolWindow(ReportDesignWidget::ToolWindowType windowType)
{
switch (windowType) {
case WidgetBox:
return dialogDesignerManager()->widgetBox();
case PropertyEditor:
return dialogDesignerManager()->propertyEditor();
case ObjectInspector:
return dialogDesignerManager()->objectInspector();
case ActionEditor:
return dialogDesignerManager()->actionEditor();
case ResourceEditor:
return dialogDesignerManager()->resourcesEditor();
case SignalSlotEditor:
return dialogDesignerManager()->signalSlotEditor();
default:
return 0;
}
}
#endif
ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType()
{
QString tabType = m_tabWidget->tabWhatsThis(m_tabWidget->currentIndex());
if ( tabType.compare("dialog") == 0) return Dialog;
if ( tabType.compare("script") == 0) return Script;
return Page;
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::initDialogDesignerToolBar(QToolBar *toolBar)
{
m_dialogDesignerManager->initToolBar(toolBar);
}
void ReportDesignWidget::updateDialogs()
{
for ( int i = 0; i<m_tabWidget->count(); ++i ){
if (m_tabWidget->tabWhatsThis(i).compare("dialog") == 0){
m_report->scriptContext()->changeDialog(m_tabWidget->tabText(i), m_dialogDesignerManager->getDialogDescription(m_tabWidget->widget(i)));
}
}
}
#endif
bool ReportDesignWidget::useMagnet() const
{
return m_useMagnet;
@ -139,6 +215,7 @@ void ReportDesignWidget::loadState(QSettings* settings)
void ReportDesignWidget::createTabs(){
int pageIndex = -1;
for (int i = 0; i<m_report->pageCount();++i){
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
@ -152,13 +229,42 @@ void ReportDesignWidget::createTabs(){
view->centerOn(0,0);
view->scale(0.5,0.5);
connectPage(m_report->pageAt(i));
m_tabWidget->addTab(view,QIcon(),tr("Page")+QString::number(i+1));
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page");
}
m_scriptEditor = new QTextEdit(this);
m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
m_tabWidget->setTabWhatsThis(pageIndex,"script");
m_tabWidget->setCurrentIndex(0);
#ifdef HAVE_QTDESIGNER_INTEGRATION
QWidget* dialogDesigner;
foreach(DialogDescriber::Ptr dialogDesc, m_report->scriptContext()->dialogDescribers()){
dialogDesigner = m_dialogDesignerManager->createFormEditor(dialogDesc->description());
pageIndex = m_tabWidget->addTab(dialogDesigner,QIcon(),dialogDesc->name());
m_tabWidget->setTabWhatsThis(pageIndex,"dialog");
}
#endif
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::createNewDialogTab(const QString& dialogName, const QByteArray& description)
{
QWidget* dialogDesigner = m_dialogDesignerManager->createFormEditor(description);
int pageIndex = m_tabWidget->addTab(dialogDesigner,QIcon(),dialogName);
m_tabWidget->setTabWhatsThis(pageIndex,"dialog");
m_tabWidget->setCurrentIndex(pageIndex);
}
DialogDesigner*ReportDesignWidget::activeDialogPage()
{
return dynamic_cast<DialogDesigner*>(m_tabWidget->currentWidget());
}
#endif
ReportDesignWidget::~ReportDesignWidget()
{
delete m_zoomer;
@ -189,7 +295,6 @@ void ReportDesignWidget::connectPage(PageDesignIntf *page)
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
//activeView()->centerOn(0,0);
emit activePageChanged();
}
@ -236,6 +341,8 @@ PageDesignIntf * ReportDesignWidget::activePage()
return 0;
}
QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){
return activePage()->selectedItems();
}
@ -256,34 +363,61 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
emit itemSelected(item);
}
void ReportDesignWidget::saveToFile(const QString &fileName){
bool ReportDesignWidget::saveToFile(const QString &fileName){
bool result = false;
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
if (m_report->saveToFile(fileName)) {
m_report->emitSaveFinished();
result = true;
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (result){
m_dialogChanged = false;
m_dialogDesignerManager->setDirty(false);
}
#endif
return result;
}
bool ReportDesignWidget::save()
{
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
bool result = false;
if (!m_report->reportFileName().isEmpty()){
if (m_report->saveToFile()){
m_report->emitSaveFinished();
return true;
result = true;
}
}
else {
m_report->emitSaveReport();
if (m_report->isSaved()) {
m_report->emitSaveFinished();
return true;
result = true;
}
if (m_report->saveToFile(QFileDialog::getSaveFileName(this,tr("Report file name"),"","Report files (*.lrxml);; All files (*)"))){
else if (m_report->saveToFile(QFileDialog::getSaveFileName(this,tr("Report file name"),"","Report files (*.lrxml);; All files (*)"))){
m_report->emitSaveFinished();
return true;
result = true;
};
}
return false;
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (result){
m_dialogChanged = false;
m_dialogDesignerManager->setDirty(false);
}
#endif
return result;
}
bool ReportDesignWidget::loadFromFile(const QString &fileName)
@ -293,6 +427,7 @@ bool ReportDesignWidget::loadFromFile(const QString &fileName)
//connectPage(m_report->pageAt(0));
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
emit loaded();
m_dialogChanged = false;
return true;
} else {
QMessageBox::critical(this,tr("Error"),tr("Wrong file format"));
@ -316,7 +451,7 @@ QString ReportDesignWidget::reportFileName()
bool ReportDesignWidget::isNeedToSave()
{
if(m_report)
return m_report->isNeedToSave();
return (m_report->isNeedToSave() || m_dialogChanged);
return false;
}
@ -335,12 +470,20 @@ void ReportDesignWidget::undo()
{
if (activePage())
activePage()->undo();
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeDialogPage())
activeDialogPage()->undo();
#endif
}
void ReportDesignWidget::redo()
{
if (activePage())
activePage()->redo();
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeDialogPage())
activeDialogPage()->redo();
#endif
}
void ReportDesignWidget::copy()
@ -457,12 +600,18 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders)
void ReportDesignWidget::previewReport()
{
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
report()->previewReport();
}
void ReportDesignWidget::printReport()
{
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
setCursor(Qt::WaitCursor);
report()->printReport();
setCursor(Qt::ArrowCursor);
@ -587,6 +736,16 @@ void ReportDesignWidget::slotPagesLoadFinished()
emit loaded();
}
void ReportDesignWidget::slotDialogDeleted(QString dialogName)
{
for (int i = 0; i<m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(dialogName) == 0){
delete m_tabWidget->widget(i);
break;
}
}
}
void ReportDesignWidget::slotDatasourceCollectionLoaded(const QString & /*collectionName*/)
{
}
@ -605,9 +764,44 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
}
m_zoomer->setView(view);
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeTabType() == Dialog){
m_dialogDesignerManager->setActiveEditor(m_tabWidget->widget(index));
}
updateDialogs();
#endif
emit activePageChanged();
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog()
{
QFile templateUi(":/templates/templates/Dialog.ui");
templateUi.open(QIODevice::ReadOnly|QIODevice::Text);
QString templateStr = templateUi.readAll();
QString dialogName = m_report->scriptContext()->getNewDialogName();
templateStr.replace("$ClassName$", dialogName);
m_report->scriptContext()->addDialog(dialogName,templateStr.toUtf8());
createNewDialogTab(dialogName, templateStr.toUtf8());
}
void ReportDesignWidget::slotDialogChanged(QString )
{
m_dialogChanged = true;
}
void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
{
for (int i = 0; i < m_tabWidget->count(); ++i){
if (m_tabWidget->tabText(i).compare(oldName) == 0)
m_tabWidget->setTabText(i, newName);
}
m_report->scriptContext()->changeDialogName(oldName, newName);
}
#endif
bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
{
if (event->type() == QEvent::Wheel){

View File

@ -48,15 +48,29 @@ namespace LimeReport {
class ReportEnginePrivate;
class DataBrowser;
class ReportDesignWindow;
class DialogDesignerManager;
class DialogDesigner;
class ReportDesignWidget : public QWidget
{
Q_OBJECT
Q_PROPERTY(QObject* datasourcesManager READ dataManager())
friend class ReportDesignWindow;
public:
enum ToolWindowType{
WidgetBox = 1,
ObjectInspector = 2,
ActionEditor = 3,
SignalSlotEditor = 4,
PropertyEditor = 5,
ResourceEditor = 6
};
enum EditorTabType{
Page,
Dialog,
Script
};
ReportDesignWidget(ReportEngine* report, QMainWindow *mainWindow, QWidget *parent = 0);
~ReportDesignWidget();
// static ReportDesignWidget* instance(){return m_instance;}
void createStartPage();
void clear();
DataSourceManager* dataManager();
@ -76,7 +90,6 @@ public:
QList<QGraphicsItem *> selectedItems();
QStringList datasourcesNames();
void scale( qreal sx, qreal sy);
// void setDatabrowser(DataBrowser* databrowser);
ReportEnginePrivate* report(){return m_report;}
QString reportFileName();
bool isNeedToSave();
@ -88,9 +101,17 @@ public:
bool useGrid(){ return m_useGrid;}
bool useMagnet() const;
void setUseMagnet(bool useMagnet);
EditorTabType activeTabType();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void initDialogDesignerToolBar(QToolBar* toolBar);
void updateDialogs();
DialogDesignerManager *dialogDesignerManager() const;
QString activeDialogName();
DialogDesigner* activeDialogPage();
QWidget* toolWindow(ToolWindowType windowType);
#endif
public slots:
void saveToFile(const QString&);
bool saveToFile(const QString&);
bool save();
bool loadFromFile(const QString&);
void deleteSelectedItems();
@ -121,13 +142,21 @@ public slots:
void printReport();
void addPage();
void deleteCurrentPage();
void slotPagesLoadFinished();
void slotDialogDeleted(QString dialogName);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void addNewDialog();
#endif
private slots:
void slotItemSelected(LimeReport::BaseDesignIntf *item);
void slotSelectionChanged();
void slotPagesLoadFinished();
void slotDatasourceCollectionLoaded(const QString&);
void slotSceneRectChanged(QRectF);
void slotCurrentTabChanged(int index);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName);
#endif
signals:
void insertModeStarted();
void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&);
@ -148,13 +177,18 @@ signals:
void pageDeleted();
protected:
void createTabs();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
private:
bool eventFilter(QObject *target, QEvent *event);
ReportDesignWidget(ReportEngine* report,QMainWindow *mainWindow,QWidget *parent = 0);
private:
ReportEnginePrivate* m_report;
QGraphicsView *m_view;
QTextEdit* m_scriptEditor;
#ifdef HAVE_QTDESIGNER_INTEGRATION
DialogDesignerManager* m_dialogDesignerManager;
#endif
QMainWindow *m_mainWindow;
QTabWidget* m_tabWidget;
GraphicsViewZoomer* m_zoomer;
@ -163,7 +197,7 @@ private:
int m_horizontalGridStep;
bool m_useGrid;
bool m_useMagnet;
// static ReportDesignWidget* m_instance;
bool m_dialogChanged;
};
}

View File

@ -73,15 +73,27 @@ ReportDesignWindow::ReportDesignWindow(ReportEngine *report, QWidget *parent, QS
createDataWindow();
createScriptWindow();
createObjectsBrowser();
#ifdef HAVE_QTDESIGNER_INTEGRATION
createDialogWidgetBox();
createDialogPropertyEditor();
createDialogObjectInspector();
createDialogActionEditor();
createDialogSignalSlotEditor();
createDialogResourceEditor();
createDialogDesignerToolBar();
#endif
m_instance=this;
m_statusBar=new QStatusBar(this);
m_lblReportName = new QLabel(report->reportFileName(),this);
m_statusBar->insertWidget(0,m_lblReportName);
setStatusBar(m_statusBar);
setWindowTitle("Lime Report Designer");
showDefaultEditors();
showDefaultToolBars();
restoreSetting();
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
m_editorTabType = ReportDesignWidget::Page;
}
ReportDesignWindow::~ReportDesignWindow()
@ -199,11 +211,6 @@ void ReportDesignWindow::createActions()
m_testAction->setIcon(QIcon(":/report/images/pin"));
connect(m_testAction,SIGNAL(triggered()),this,SLOT(slotTest()));
// m_printReportAction = new QAction(tr("Print Report"),this);
// m_printReportAction->setIcon(QIcon(":/report/images/print"));
// m_printReportAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
// connect(m_printReportAction,SIGNAL(triggered()),this,SLOT(slotPrintReport()));
m_editLayoutMode = new QAction(tr("Edit layouts mode"),this);
m_editLayoutMode->setIcon(QIcon(":/report/images/editlayout"));
m_editLayoutMode->setCheckable(true);
@ -219,15 +226,22 @@ void ReportDesignWindow::createActions()
m_hideLeftPanel = new QAction(tr("Hide left panel"),this);
m_hideLeftPanel->setCheckable(true);
// m_hideLeftPanel->setChecked(true);
m_hideLeftPanel->setIcon(QIcon(":/report/images/hideLeftPanel"));
connect(m_hideLeftPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideLeftPanel(bool)));
m_hideRightPanel = new QAction(tr("Hide right panel"),this);
m_hideRightPanel->setCheckable(true);
// m_hideRightPanel->setChecked(true);
m_hideRightPanel->setIcon(QIcon(":/report/images/hideRightPanel"));
connect(m_hideRightPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideRightPanel(bool)));
#ifdef HAVE_QTDESIGNER_INTEGRATION
m_deleteDialogAction = new QAction(tr("Delete dialog"), this);
m_deleteDialogAction->setIcon(QIcon(":/report//images/deleteDialog"));
connect(m_deleteDialogAction, SIGNAL(triggered()), this, SLOT(slotDeleteDialog()));
m_addNewDialogAction = new QAction(tr("Add new dialog"), this);
m_addNewDialogAction->setIcon(QIcon(":/report//images/addDialog"));
connect(m_addNewDialogAction, SIGNAL(triggered()), this, SLOT(slotAddNewDialog()));
#endif
}
void ReportDesignWindow::createReportToolBar()
@ -240,7 +254,6 @@ void ReportDesignWindow::createReportToolBar()
m_reportToolBar->setObjectName("reportTools");
createItemsActions();
m_reportToolBar->addSeparator();
//m_reportToolBar->addAction(m_editLayoutMode);
m_reportToolBar->addAction(m_addHLayout);
m_reportToolBar->addSeparator();
m_reportToolBar->addAction(m_deleteItemAction);
@ -274,6 +287,9 @@ void ReportDesignWindow::createToolBars()
m_mainToolBar->addAction(m_newPageAction);
m_mainToolBar->addAction(m_deletePageAction);
#ifdef HAVE_QTDESIGNER_INTEGRATION
m_mainToolBar->addAction(m_addNewDialogAction);
#endif
m_mainToolBar->addSeparator();
m_mainToolBar->addAction(m_copyAction);
@ -313,6 +329,11 @@ void ReportDesignWindow::createToolBars()
addToolBar(m_itemsBordersEditorBar);
createReportToolBar();
m_pageTools << m_mainToolBar << m_reportToolBar << m_fontEditorBar
<< m_textAlignmentEditorBar << m_itemsAlignmentEditorBar
<< m_itemsBordersEditorBar;
}
void ReportDesignWindow::createItemsActions()
@ -475,7 +496,6 @@ void ReportDesignWindow::createObjectInspector()
m_objectInspector->setModel(m_propertyModel);
m_objectInspector->setAlternatingRowColors(true);
m_objectInspector->setRootIsDecorated(!m_propertyModel->subclassesAsLevel());
QDockWidget *objectDoc = new QDockWidget(this);
QWidget* w = new QWidget(objectDoc);
QVBoxLayout* l = new QVBoxLayout(w);
@ -485,6 +505,7 @@ void ReportDesignWindow::createObjectInspector()
objectDoc->setWindowTitle(tr("Object Inspector"));
objectDoc->setWidget(w);
objectDoc->setObjectName("objectInspector");
m_pageEditors.append(objectDoc);
addDockWidget(Qt::LeftDockWidgetArea,objectDoc);
}
@ -497,9 +518,89 @@ void ReportDesignWindow::createObjectsBrowser()
doc->setObjectName("structureDoc");
addDockWidget(Qt::RightDockWidgetArea,doc);
m_objectsBrowser->setMainWindow(this);
m_pageEditors.append(doc);
m_objectsBrowser->setReportEditor(m_reportDesignWidget);
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWindow::createDialogWidgetBox()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Widget Box"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::WidgetBox));
doc->setObjectName("WidgetBox");
addDockWidget(Qt::LeftDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogPropertyEditor()
{
QDockWidget *doc = new QDockWidget(this);
doc->setWindowTitle(tr("Property Editor"));
doc->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::PropertyEditor));
doc->setObjectName("PropertyEditor");
addDockWidget(Qt::RightDockWidgetArea,doc);
m_dialogEditors.append(doc);
}
void ReportDesignWindow::createDialogObjectInspector()
{
QDockWidget *dock = new QDockWidget(this);
dock->setWindowTitle(tr("Object Inspector"));
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ObjectInspector));
dock->setObjectName("ObjectInspector");
addDockWidget(Qt::RightDockWidgetArea,dock);
m_dialogEditors.append(dock);
}
void ReportDesignWindow::createDialogActionEditor()
{
QDockWidget *dock = new QDockWidget(this);
dock->setWindowTitle(tr("Action Editor"));
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ActionEditor));
dock->setObjectName("ActionEditor");
addDockWidget(Qt::BottomDockWidgetArea,dock);
m_dialogEditors.append(dock);
m_docksToTabify.append(dock);
}
void ReportDesignWindow::createDialogResourceEditor()
{
QDockWidget *dock = new QDockWidget(this);
dock->setWindowTitle(tr("Resource Editor"));
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::ResourceEditor));
dock->setObjectName("ResourceEditor");
addDockWidget(Qt::BottomDockWidgetArea,dock);
m_dialogEditors.append(dock);
m_docksToTabify.append(dock);
}
void ReportDesignWindow::createDialogSignalSlotEditor()
{
QDockWidget *dock = new QDockWidget(this);
dock->setWindowTitle(tr("SignalSlot Editor"));
dock->setWidget(m_reportDesignWidget->toolWindow(ReportDesignWidget::SignalSlotEditor));
dock->setObjectName("SignalSlotEditor");
addDockWidget(Qt::BottomDockWidgetArea,dock);
m_dialogEditors.append(dock);
m_docksToTabify.append(dock);
}
void ReportDesignWindow::createDialogDesignerToolBar()
{
m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools"));
m_dialogDesignerToolBar->setObjectName("DialogDesignerTools");
m_dialogDesignerToolBar->addAction(m_saveReportAction);
m_dialogDesignerToolBar->addAction(m_previewReportAction);
m_dialogDesignerToolBar->addSeparator();
m_dialogDesignerToolBar->addAction(m_deleteDialogAction);
m_dialogDesignerToolBar->addSeparator();
m_reportDesignWidget->initDialogDesignerToolBar(m_dialogDesignerToolBar);
m_dialogTools << m_dialogDesignerToolBar;
}
#endif
void ReportDesignWindow::createDataWindow()
{
QDockWidget *dataDoc = new QDockWidget(this);
@ -510,6 +611,7 @@ void ReportDesignWindow::createDataWindow()
addDockWidget(Qt::LeftDockWidgetArea,dataDoc);
m_dataBrowser->setSettings(settings());
m_dataBrowser->setMainWindow(this);
m_pageEditors.append(dataDoc);
m_dataBrowser->setReportEditor(m_reportDesignWidget);
}
@ -522,6 +624,7 @@ void ReportDesignWindow::createScriptWindow()
dataDoc->setObjectName("scriptDoc");
addDockWidget(Qt::LeftDockWidgetArea,dataDoc);
m_scriptBrowser->setReportEditor(m_reportDesignWidget);
m_pageEditors.append(dataDoc);
#ifdef HAVE_UI_LOADER
m_scriptBrowser->updateDialogsTree();
#endif
@ -544,6 +647,9 @@ void ReportDesignWindow::startNewReport()
m_newPageFooter->setEnabled(true);
m_newReportHeader->setEnabled(true);
m_newReportFooter->setEnabled(true);
m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors();
showDefaultToolBars();
}
void ReportDesignWindow::writePosition()
@ -557,7 +663,16 @@ void ReportDesignWindow::writePosition()
void ReportDesignWindow::writeState()
{
settings()->beginGroup("DesignerWindow");
settings()->setValue("State",saveState());
switch (m_editorTabType) {
case ReportDesignWidget::Page:
settings()->setValue("PageEditorsState", saveState());
settings()->setValue("DialogEditorsState", m_dialogEditorsState);
break;
default:
settings()->setValue("DialogEditorsState", saveState());
settings()->setValue("PageEditorsState", m_pageEditorsState);
break;
}
settings()->setValue("InspectorFirsColumnWidth",m_objectInspector->columnWidth(0));
settings()->endGroup();
settings()->beginGroup("RecentFiles");
@ -650,9 +765,15 @@ void ReportDesignWindow::restoreSetting()
resize(screenWidth*0.8, screenHeight*0.8);
move(x, y);
}
v = settings()->value("State");
v = settings()->value("PageEditorsState");
if (v.isValid()){
m_pageEditorsState = v.toByteArray();
restoreState(v.toByteArray());
m_editorTabType = ReportDesignWidget::Page;
}
v = settings()->value("DialogEditorsState");
if (v.isValid()){
m_dialogEditorsState = v.toByteArray();
}
v = settings()->value("InspectorFirsColumnWidth");
if (v.isValid()){
@ -954,6 +1075,9 @@ void ReportDesignWindow::slotLoadReport()
unsetCursor();
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
addRecentFile(fileName);
m_editorTabType = ReportDesignWidget::Page;
showDefaultToolBars();
showDefaultEditors();
}
}
@ -1120,11 +1244,65 @@ void ReportDesignWindow::updateAvaibleBands(){
}
}
void ReportDesignWindow::showDefaultToolBars(){
foreach (QToolBar* tb, m_pageTools){
tb->setVisible(m_editorTabType != ReportDesignWidget::Dialog);
}
foreach (QToolBar* tb, m_dialogTools){
tb->setVisible(m_editorTabType == ReportDesignWidget::Dialog);
}
}
void ReportDesignWindow::showDefaultEditors(){
foreach (QDockWidget* w, m_pageEditors) {
w->setVisible(m_editorTabType != ReportDesignWidget::Dialog);
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
foreach (QDockWidget* w, m_dialogEditors) {
w->setVisible(m_editorTabType == ReportDesignWidget::Dialog);
}
for ( int i = 0; i < m_docksToTabify.size() - 1; ++i){
tabifyDockWidget(m_docksToTabify.at(i),m_docksToTabify.at(i+1));
}
m_docksToTabify.at(0)->raise();
#endif
}
void ReportDesignWindow::slotActivePageChanged()
{
m_propertyModel->setObject(0);
updateRedoUndo();
updateAvaibleBands();
switch (m_editorTabType) {
case ReportDesignWidget::Dialog:
m_dialogEditorsState = saveState();
m_scriptBrowser->updateDialogsTree();
break;
default:
m_pageEditorsState = saveState();
break;
}
m_editorTabType = m_reportDesignWidget->activeTabType();
switch (m_editorTabType) {
case ReportDesignWidget::Dialog:
if (!m_dialogEditorsState.isEmpty())
restoreState(m_dialogEditorsState);
else
showDefaultEditors();
showDefaultToolBars();
break;
default:
if (!m_pageEditors.isEmpty())
restoreState(m_pageEditorsState);
else
showDefaultEditors();
showDefaultToolBars();
break;
}
}
void ReportDesignWindow::renderStarted()
@ -1231,6 +1409,20 @@ void ReportDesignWindow::slotPageDeleted()
m_deletePageAction->setEnabled(m_reportDesignWidget->report()->pageCount()>1);
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWindow::slotDeleteDialog()
{
if ( m_editorTabType == ReportDesignWidget::Dialog ){
m_reportDesignWidget->report()->scriptContext()->deleteDialog(m_reportDesignWidget->activeDialogName());
}
}
void ReportDesignWindow::slotAddNewDialog()
{
m_reportDesignWidget->addNewDialog();
}
#endif
void ReportDesignWindow::closeEvent(QCloseEvent * event)
{
if (checkNeedToSave()){

View File

@ -119,6 +119,10 @@ private slots:
void slotLoadRecentFile(const QString fileName);
void slotPageAdded(PageDesignIntf* );
void slotPageDeleted();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDeleteDialog();
void slotAddNewDialog();
#endif
protected:
void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *);
@ -126,6 +130,7 @@ protected:
void hideDockWidgets(Qt::DockWidgetArea area, bool value);
bool isDockAreaVisible(Qt::DockWidgetArea area);
private:
void initReportEditor(ReportEnginePrivate* report);
void createActions();
void createBandsButton();
void createMainMenu();
@ -137,6 +142,15 @@ private:
void initReportEditor(ReportEngine *report);
void createDataWindow();
void createScriptWindow();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createDialogWidgetBox();
void createDialogPropertyEditor();
void createDialogObjectInspector();
void createDialogActionEditor();
void createDialogResourceEditor();
void createDialogSignalSlotEditor();
void createDialogDesignerToolBar();
#endif
void updateRedoUndo();
void updateAvaibleBands();
void startNewReport();
@ -146,6 +160,8 @@ private:
void removeNotExistedRecentFiles();
void removeNotExistedRecentFilesFromMenu(const QString& fileName);
void addRecentFile(const QString& fileName);
void showDefaultToolBars();
void showDefaultEditors();
private:
static ReportDesignWindow* m_instance;
QStatusBar* m_statusBar;
@ -153,6 +169,9 @@ private:
QToolBar* m_fontToolBar;
QToolBar* m_reportToolBar;
QToolBar* m_alignToolBar;
#ifdef HAVE_QTDESIGNER_INTEGRATION
QToolBar* m_dialogDesignerToolBar;
#endif
QToolButton* m_newBandButton;
QMenuBar* m_mainMenu;
QMenu* m_fileMenu;
@ -203,6 +222,10 @@ private:
QAction* m_addHLayout;
QAction* m_hideLeftPanel;
QAction* m_hideRightPanel;
#ifdef HAVE_QTDESIGNER_INTEGRATION
QAction* m_deleteDialogAction;
QAction* m_addNewDialogAction;
#endif
QMenu* m_recentFilesMenu;
QSignalMapper* m_bandsAddSignalsMap;
@ -235,6 +258,15 @@ private:
QProgressDialog* m_progressDialog;
bool m_showProgressDialog;
QMap<QString,QDateTime> m_recentFiles;
QVector<QDockWidget*> m_pageEditors;
QVector<QDockWidget*> m_dialogEditors;
QVector<QDockWidget*> m_docksToTabify;
ReportDesignWidget::EditorTabType m_editorTabType;
QByteArray m_pageEditorsState;
QByteArray m_dialogEditorsState;
QVector<QToolBar*> m_pageTools;
QVector<QToolBar*> m_dialogTools;
};
class ObjectNameValidator : public ValidatorIntf{

View File

@ -259,11 +259,8 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
clearPageMap();
startNewPage(true);
renderReportHeader(m_patternPageItem, AfterPageHeader);
// renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, StartNewPageAsNeeded);
BandDesignIntf* lastRenderedBand = 0;
for (int i=0;i<m_patternPageItem->dataBandCount() && !m_renderCanceled;i++){
lastRenderedBand = m_patternPageItem->dataBandAt(i);
@ -318,6 +315,7 @@ void ReportRender::initRenderPage()
m_renderPageItem->initFromItem(m_patternPageItem);
m_renderPageItem->setItemMode(PreviewMode);
m_renderPageItem->setPatternName(m_patternPageItem->objectName());
m_renderPageItem->setPatternItem(m_patternPageItem);
}
}
@ -341,7 +339,7 @@ void registerChildObjects(ScriptEngineType* se, ScriptValueType* sv){
void ReportRender::initDialogs(){
if (m_scriptEngineContext){
ScriptEngineType* se = ScriptEngineManager::instance().scriptEngine();
foreach(DialogDescriber::Ptr dialog, m_scriptEngineContext->dialogsDescriber()){
foreach(DialogDescriber::Ptr dialog, m_scriptEngineContext->dialogDescribers()){
ScriptValueType sv = se->newQObject(m_scriptEngineContext->getDialog(dialog->name()));
#ifdef USE_QJSENGINE
registerChildObjects(se,&sv);
@ -393,6 +391,21 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band)
}
}
bool ReportRender::containsGroupsFunction(BandDesignIntf *band){
foreach(BaseDesignIntf* item,band->childBaseItems()){
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(item);
if (contentItem){
QString content = contentItem->content();
foreach(QString functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
if (rx.indexIn(content)>=0){
return true;
}
}
}
}
return false;
}
void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
{
@ -517,20 +530,20 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
BandDesignIntf* header = dataBand->bandHeader();
BandDesignIntf* footer = dataBand->bandFooter();
if (header && header->printAlways()) renderBand(header, 0);
if (header && header->printAlways()) renderDataHeader(header);
if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){
QString varName = QLatin1String("line_")+dataBand->objectName().toLower();
datasources()->setReportVariable(varName,1);
if (header && !header->printAlways())
renderBand(header, 0);
if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage())
if (header && header->reprintOnEachPage())
m_reprintableBands.append(dataBand->bandHeader());
renderChildHeader(dataBand,PrintNotAlwaysPrintable);
if (header && !header->printAlways())
renderDataHeader(header);
//renderChildHeader(dataBand,PrintNotAlwaysPrintable);
renderGroupHeader(dataBand, bandDatasource, true);
bool firstTime = true;
@ -578,7 +591,8 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
firstTime = false;
}
m_reprintableBands.removeOne(dataBand->bandHeader());
m_reprintableBands.removeOne(header);
if (header) recalcIfNeeded(header);
renderGroupFooter(dataBand);
@ -647,9 +661,10 @@ void ReportRender::renderPageItems(PageItemDesignIntf* patternPage)
}
}
m_renderPageItem->restoreLinks();
foreach(BaseDesignIntf* item, pageItems){
item->updateItemSize(m_datasources);
}
m_renderPageItem->updateSubItemsSize(FirstPass,m_datasources);
// foreach(BaseDesignIntf* item, pageItems){
// item->updateItemSize(m_datasources);
// }
}
qreal ReportRender::calcPageFooterHeight(PageItemDesignIntf *patternPage)
@ -702,13 +717,48 @@ void ReportRender::renderChildBands(BandDesignIntf *parentBand)
}
}
BandDesignIntf* ReportRender::findRecalcableBand(BandDesignIntf* patternBand){
QList<BandDesignIntf*>::iterator it = m_recalcBands.begin();
for (;it !=m_recalcBands.end() ;++it){
if ((*it)->patternItem() == patternBand){
BandDesignIntf* result = (*it);
m_recalcBands.erase(it);
return result;
}
}
return 0;
}
void ReportRender::recalcIfNeeded(BandDesignIntf* band){
BandDesignIntf* recalcBand = findRecalcableBand(band);
if (recalcBand){
QString bandName = recalcBand->objectName();
recalcBand->restoreItems();
recalcBand->setObjectName(recalcBand->patternItem()->objectName());
replaceGroupsFunction(recalcBand);
recalcBand->updateItemSize(datasources());
recalcBand->setObjectName(bandName);
datasources()->clearGroupFunctionValues(recalcBand->patternItem()->objectName());
}
}
void ReportRender::renderDataHeader(BandDesignIntf *header)
{
recalcIfNeeded(header);
BandDesignIntf* renderedHeader = renderBand(header, 0);
if (containsGroupsFunction(header))
m_recalcBands.append(renderedHeader);
}
void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* dataSource, bool firstTime)
{
foreach(BandDesignIntf* band,parentBand->childrenByType(BandDesignIntf::GroupHeader)){
IGroupBand* gb = dynamic_cast<IGroupBand*>(band);
if (gb&&gb->isNeedToClose(m_datasources)){
if (gb&&gb->isNeedToClose(datasources())){
if (band->childBands().count()>0){
dataSource->prior();
foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) {
foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){
renderBand(footer, 0);
@ -723,10 +773,6 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
dataSource->next();
}
closeDataGroup(band);
// if (gb->isNeedToStartNewPage()){
// savePage();
// startNewPage();
// }
}
if (!gb->isStarted()){
@ -734,12 +780,15 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
m_reprintableBands.append(band);
gb->startGroup(m_datasources);
openDataGroup(band);
BandDesignIntf* renderedHeader = 0;
if (!firstTime && gb->startNewPage()){
if (gb->resetPageNumber()) resetPageNumber(BandReset);
renderBand(band, 0, ForcedStartPage);
renderedHeader = renderBand(band, 0, ForcedStartPage);
} else {
renderBand(band, 0, StartNewPageAsNeeded);
renderedHeader = renderBand(band, 0, StartNewPageAsNeeded);
}
if (containsGroupsFunction(band))
m_recalcBands.append(renderedHeader);
}
renderGroupHeader(band, dataSource, firstTime);
@ -753,6 +802,7 @@ void ReportRender::renderGroupFooterByHeader(BandDesignIntf* groupHeader){
foreach (BandDesignIntf* footer, groupHeader->childrenByType(BandDesignIntf::GroupFooter)){
renderBand(footer, 0, StartNewPageAsNeeded);
}
recalcIfNeeded(groupHeader);
}
void ReportRender::renderGroupFooter(BandDesignIntf *parentBand)
@ -780,6 +830,7 @@ void ReportRender::initGroups()
if (band->isHeader()){
IGroupBand* gb = dynamic_cast<IGroupBand*>(band);
if (gb) gb->closeGroup();
extractGroupsFunction(band);
}
}
}
@ -852,6 +903,7 @@ void ReportRender::closeDataGroup(BandDesignIntf *band)
groupBand->closeGroup();
if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band);
}
recalcIfNeeded(band);
closeGroup(band);
}
@ -1056,6 +1108,11 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand)
if (patternBand->isFooter()){
replaceGroupsFunction(bandClone);
}
if (patternBand->isHeader()){
replaceGroupsFunction(bandClone);
}
bandClone->updateItemSize(m_datasources);
baseDesignIntfToScript(bandClone);

View File

@ -90,6 +90,7 @@ private:
void baseDesignIntfToScript(BaseDesignIntf* item);
void renderPage(PageDesignIntf *patternPage);
void initDatasources();
void initDatasource(const QString &name);
@ -112,13 +113,18 @@ private:
void renderChildHeader(BandDesignIntf* parent, BandPrintMode printMode);
void renderChildFooter(BandDesignIntf* parent, BandPrintMode printMode);
void renderChildBands(BandDesignIntf* parentBand);
void recalcIfNeeded(BandDesignIntf *band);
void renderDataHeader(BandDesignIntf* header);
void renderGroupHeader(BandDesignIntf* parentBand, IDataSource* dataSource, bool firstTime);
void renderGroupFooter(BandDesignIntf* parentBand);
void initGroups();
bool containsGroupsFunction(BandDesignIntf* band);
void extractGroupsFunction(BandDesignIntf* band);
void replaceGroupsFunction(BandDesignIntf* band);
BandDesignIntf *findRecalcableBand(BandDesignIntf *patternBand);
void popPageFooterGroupValues(BandDesignIntf* dataBand);
void pushPageFooterGroupValues(BandDesignIntf* dataBand);
@ -162,6 +168,7 @@ private:
QList<PageItemDesignIntf::Ptr> m_renderedPages;
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
QList<BandDesignIntf*> m_reprintableBands;
QList<BandDesignIntf*> m_recalcBands;
// QList<BandDesignIntf*> m_lastRenderedHeaders;
//int m_maxHeightByColumn[0];

View File

@ -1065,6 +1065,49 @@ void DialogDescriber::setDescription(const QByteArray &description)
void ScriptEngineContext::addDialog(const QString& name, const QByteArray& description)
{
m_dialogs.push_back(DialogDescriber::create(name,description));
emit dialogAdded(name);
}
bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& description)
{
foreach( DialogDescriber::Ptr describer, m_dialogs){
if (describer->name().compare(name) == 0){
describer->setDescription(description);
{
QList<DialogPtr>::Iterator it = m_createdDialogs.begin();
while(it!=m_createdDialogs.end()){
if ((*it)->objectName()==name){
it = m_createdDialogs.erase(it);
} else {
++it;
}
}
}
return true;
}
}
return false;
}
bool ScriptEngineContext::changeDialogName(const QString& oldName, const QString& newName)
{
foreach( DialogDescriber::Ptr describer, m_dialogs){
if (describer->name().compare(oldName) == 0){
describer->setName(newName);
{
QList<DialogPtr>::Iterator it = m_createdDialogs.begin();
while(it!=m_createdDialogs.end()){
if ((*it)->objectName()==oldName){
it = m_createdDialogs.erase(it);
} else {
++it;
}
}
}
return true;
}
}
return false;
}
bool ScriptEngineContext::previewDialog(const QString& dialogName)
@ -1095,6 +1138,7 @@ void ScriptEngineContext::deleteDialog(const QString& dialogName)
while(it!=m_dialogs.end()){
if ((*it)->name()==dialogName){
it = m_dialogs.erase(it);
emit dialogDeleted(dialogName);
} else {
++it;
}
@ -1177,6 +1221,10 @@ QDialog* ScriptEngineContext::createDialog(DialogDescriber* cont)
buffer.open(QIODevice::ReadOnly);
QDialog* dialog = dynamic_cast<QDialog*>(loader.load(&buffer));
m_createdDialogs.push_back(QSharedPointer<QDialog>(dialog));
if (cont->name().compare(dialog->objectName())){
cont->setName(dialog->objectName());
emit dialogNameChanged(dialog->objectName());
}
return dialog;
}
@ -1214,6 +1262,18 @@ QDialog* ScriptEngineContext::getDialog(const QString& dialogName)
}
return 0;
}
QString ScriptEngineContext::getNewDialogName()
{
QString result = "Dialog";
int index = m_dialogs.size() - 1;
while (containsDialog(result)){
index++;
result = QString("Dialog%1").arg(index);
}
return result;
}
#endif
QString ScriptEngineContext::initScript() const
{

View File

@ -144,16 +144,23 @@ public:
#endif
explicit ScriptEngineContext(QObject* parent=0):QObject(parent){}
#ifdef HAVE_UI_LOADER
void addDialog(const QString& name, const QByteArray &description);
void addDialog(const QString& name, const QByteArray& description);
bool changeDialog(const QString& name, const QByteArray &description);
bool changeDialogName(const QString& oldName, const QString& newName);
bool previewDialog(const QString& dialogName);
bool containsDialog(const QString& dialogName);
const QVector<DialogDescriber::Ptr>& dialogsDescriber(){return m_dialogs;}
const QVector<DialogDescriber::Ptr>& dialogDescribers(){return m_dialogs;}
void deleteDialog(const QString& dialogName);
QDialog *getDialog(const QString &dialogName);
QString getNewDialogName();
#endif
void clear();
QString initScript() const;
void setInitScript(const QString& initScript);
signals:
void dialogNameChanged(QString dialogName);
void dialogDeleted(QString dialogName);
void dialogAdded(QString dialogName);
protected:
QObject* createElement(const QString& collectionName,const QString& elementType);
int elementsCount(const QString& collectionName);

View File

@ -126,9 +126,9 @@
<file>images/hlayuot_3_24.png</file>
<file>images/addBand1.png</file>
<file>images/delete1.png</file>
<file alias="/images/copy">images/copy2.png</file>
<file>images/copy2.png</file>
<file alias="/images/newReport">images/new_leaf1.png</file>
<file alias="/images/paste">images/paste1.png</file>
<file>images/paste1.png</file>
<file alias="/images/zoomIn">images/zoom_in1.png</file>
<file alias="/images/zoomOut">images/zoom_out1.png</file>
<file alias="/images/folder">images/folder3.png</file>
@ -175,5 +175,9 @@
<file alias="/images/addBand">images/addBand2.png</file>
<file alias="/images/editMode">images/edit_control_4_24.png</file>
<file alias="/images/logo32">images/logo_32x32_1.png</file>
<file alias="/images/addDialog">images/addDialog.png</file>
<file alias="/images/deleteDialog">images/deleteDialog.png</file>
<file alias="/images/copy">images/copy3.png</file>
<file alias="/images/paste">images/paste2.png</file>
</qresource>
</RCC>

View File

@ -59,6 +59,7 @@ void ScriptBrowser::setReportEditor(ReportDesignWidget* report)
m_report=report;
connect(m_report,SIGNAL(cleared()),this,SLOT(slotClear()));
connect(m_report,SIGNAL(loaded()),this,SLOT(slotUpdate()));
connect(m_report->scriptContext(), SIGNAL(dialogAdded(QString)), this, SLOT(slotDialogAdded(QString)));
updateFunctionTree();
}
@ -117,7 +118,7 @@ void ScriptBrowser::updateDialogsTree()
{
ui->twDialogs->clear();
ScriptEngineContext* sc = reportEditor()->scriptContext();
foreach(DialogDescriber::Ptr dc, sc->dialogsDescriber()){
foreach(DialogDescriber::Ptr dc, sc->dialogDescribers()){
QTreeWidgetItem* dialogItem = new QTreeWidgetItem(ui->twDialogs,QStringList(dc->name()));
dialogItem->setIcon(0,QIcon(":/scriptbrowser/images/dialog"));
fillDialog(dialogItem,dc->description());
@ -138,6 +139,11 @@ void ScriptBrowser::slotUpdate()
updateFunctionTree();
}
void ScriptBrowser::slotDialogAdded(QString)
{
updateDialogsTree();
}
#ifdef HAVE_UI_LOADER
void ScriptBrowser::on_tbAddDialog_clicked()
{
@ -157,7 +163,7 @@ void ScriptBrowser::on_tbAddDialog_clicked()
if (!m_report->scriptContext()->containsDialog(dialog->objectName())){
file.seek(0);
m_report->scriptContext()->addDialog(dialog->objectName(),file.readAll());
updateDialogsTree();
//updateDialogsTree();
} else {
QMessageBox::critical(this,tr("Error"),tr("Dialog with name: %1 already exists").arg(dialog->objectName()));
}

View File

@ -62,6 +62,7 @@ protected:
private slots:
void slotClear();
void slotUpdate();
void slotDialogAdded(QString);
#ifdef HAVE_UI_LOADER
void on_tbAddDialog_clicked();
void on_tbRunDialog_clicked();