Finish Dialog_Designer

# Conflicts:
#	limereport/limereport.pri
This commit is contained in:
Arin Alexander 2017-04-18 21:53:19 +03:00
commit d0cf6f4961
52 changed files with 2254 additions and 58 deletions

View File

@ -1,6 +1,8 @@
CONFIG += build_translations
CONFIG += zint
CONFIG += qjsengine
CONFIG += dialogdesigner
greaterThan(QT_MAJOR_VERSION, 4) {
QT += uitools
}

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

@ -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 \
@ -44,16 +57,8 @@ SOURCES += \
$$REPORT_PATH/objectinspector/lrobjectitemmodel.cpp \
$$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/objectsbrowser/lrobjectbrowser.cpp \
$$REPORT_PATH/scriptbrowser/lrscriptbrowser.cpp \
$$REPORT_PATH/items/lrsubitemparentpropitem.cpp \
$$REPORT_PATH/items/lralignpropitem.cpp \
$$REPORT_PATH/items/lrhorizontallayout.cpp \
@ -89,8 +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
@ -146,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 \
@ -189,7 +195,6 @@ 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){

View File

@ -33,6 +33,7 @@
#include "lrreportengine_p.h"
#include "lrbasedesignintf.h"
#include "lrsettingdialog.h"
#include "dialogdesigner/lrdialogdesigner.h"
#include <QDebug>
#include <QObject>
@ -46,10 +47,12 @@
namespace LimeReport {
// ReportDesignIntf
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *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 +75,85 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
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(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 +212,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 +226,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 +292,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 +338,8 @@ PageDesignIntf * ReportDesignWidget::activePage()
return 0;
}
QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){
return activePage()->selectedItems();
}
@ -256,34 +360,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();
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 +424,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 +448,7 @@ QString ReportDesignWidget::reportFileName()
bool ReportDesignWidget::isNeedToSave()
{
if(m_report)
return m_report->isNeedToSave();
return (m_report->isNeedToSave() || m_dialogChanged);
return false;
}
@ -335,12 +467,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 +597,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 +733,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 +761,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(ReportEnginePrivate* 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(ReportEnginePrivate* 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(ReportEnginePrivate *report, QWidget *par
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();
@ -134,9 +139,17 @@ private:
void createItemsActions();
void createObjectInspector();
void createObjectsBrowser();
void initReportEditor(ReportEnginePrivate* 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 +159,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 +168,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 +221,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 +257,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

@ -339,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);

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,21 +144,28 @@ 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();
void clear();
QString initScript() const;
void setInitScript(const QString& initScript);
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);
int elementsCount(const QString& collectionName);
QObject* elementAt(const QString& collectionName,int index);
void collectionLoadFinished(const QString &collectionName);
void collectionLoadFinished(const QString &collectionName);
#ifdef HAVE_UI_LOADER
QDialog *createDialog(DialogDescriber *cont);
QDialog *findDialog(const QString &dialogName);

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