diff --git a/common.pri b/common.pri index 9f44335..f65f87b 100644 --- a/common.pri +++ b/common.pri @@ -1,6 +1,8 @@ CONFIG += build_translations CONFIG += zint CONFIG += qjsengine +CONFIG += dialogdesigner + greaterThan(QT_MAJOR_VERSION, 4) { QT += uitools } diff --git a/limereport/dialogdesigner/3rdparty/designer/pluginmanager_p.h b/limereport/dialogdesigner/3rdparty/designer/pluginmanager_p.h new file mode 100644 index 0000000..1706182 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/designer/pluginmanager_p.h @@ -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 +#include + +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 instances() const; + QList 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 diff --git a/limereport/dialogdesigner/3rdparty/designer/qdesigner_integration_p.h b/limereport/dialogdesigner/3rdparty/designer/qdesigner_integration_p.h new file mode 100644 index 0000000..f59c001 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/designer/qdesigner_integration_p.h @@ -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 + +#include + +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 diff --git a/limereport/dialogdesigner/3rdparty/designer/shared_global_p.h b/limereport/dialogdesigner/3rdparty/designer/shared_global_p.h new file mode 100644 index 0000000..3b9ff24 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/designer/shared_global_p.h @@ -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 + +#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 diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/README.txt b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/README.txt new file mode 100644 index 0000000..f5351ea --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/README.txt @@ -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 diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/designerintegration.pri b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/designerintegration.pri new file mode 100644 index 0000000..f3a02f6 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/designerintegration.pri @@ -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 diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp new file mode 100644 index 0000000..e0d88ed --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.cpp @@ -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 + +#include + +#include +#include +#include +#include +#include + +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(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(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() << "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); + } +} diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.h b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.h new file mode 100644 index 0000000..c7bd689 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/formresizer.h @@ -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 +#include + +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 Handles; + Handles m_handles; + QDesignerFormWindowInterface * m_formWindow; +}; + +} +} // namespace SharedTools + +#endif // FORMRESIZER_H diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp new file mode 100644 index 0000000..4247769 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.cpp @@ -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 + +#include +#include +#include +#include + +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; +} diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h new file mode 100644 index 0000000..c916b00 --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/sizehandlerect.h @@ -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 +#include + +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 + diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.cpp b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.cpp new file mode 100644 index 0000000..b78eb4b --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.cpp @@ -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 +#include + +#include +#include +#include +#include +#include + +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; +} diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.h b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.h new file mode 100644 index 0000000..82b9fef --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethost.h @@ -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 + +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 diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethostconstants.h b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethostconstants.h new file mode 100644 index 0000000..b1f7fff --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/designerintegrationv2/widgethostconstants.h @@ -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 + diff --git a/limereport/dialogdesigner/3rdparty/qtcreator/namespace_global.h b/limereport/dialogdesigner/3rdparty/qtcreator/namespace_global.h new file mode 100644 index 0000000..7b6ba3f --- /dev/null +++ b/limereport/dialogdesigner/3rdparty/qtcreator/namespace_global.h @@ -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 + +#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 diff --git a/limereport/dialogdesigner/dialogdesigner.pri b/limereport/dialogdesigner/dialogdesigner.pri new file mode 100644 index 0000000..df76e68 --- /dev/null +++ b/limereport/dialogdesigner/dialogdesigner.pri @@ -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 diff --git a/limereport/dialogdesigner/dialogdesigner.qrc b/limereport/dialogdesigner/dialogdesigner.qrc new file mode 100644 index 0000000..3911131 --- /dev/null +++ b/limereport/dialogdesigner/dialogdesigner.qrc @@ -0,0 +1,12 @@ + + + images/buddytool.png + images/editform.png + images/signalslottool.png + images/tabordertool.png + images/widgettool.png + + + templates/Dialog.ui + + diff --git a/limereport/dialogdesigner/images/buddytool.png b/limereport/dialogdesigner/images/buddytool.png new file mode 100644 index 0000000..4cd968b Binary files /dev/null and b/limereport/dialogdesigner/images/buddytool.png differ diff --git a/limereport/dialogdesigner/images/editform.png b/limereport/dialogdesigner/images/editform.png new file mode 100644 index 0000000..452fcd8 Binary files /dev/null and b/limereport/dialogdesigner/images/editform.png differ diff --git a/limereport/dialogdesigner/images/signalslottool.png b/limereport/dialogdesigner/images/signalslottool.png new file mode 100644 index 0000000..e80fd1c Binary files /dev/null and b/limereport/dialogdesigner/images/signalslottool.png differ diff --git a/limereport/dialogdesigner/images/tabordertool.png b/limereport/dialogdesigner/images/tabordertool.png new file mode 100644 index 0000000..7e6e2de Binary files /dev/null and b/limereport/dialogdesigner/images/tabordertool.png differ diff --git a/limereport/dialogdesigner/images/widgettool.png b/limereport/dialogdesigner/images/widgettool.png new file mode 100644 index 0000000..a52224e Binary files /dev/null and b/limereport/dialogdesigner/images/widgettool.png differ diff --git a/limereport/dialogdesigner/lrdialogdesigner.cpp b/limereport/dialogdesigner/lrdialogdesigner.cpp new file mode 100644 index 0000000..6a33752 --- /dev/null +++ b/limereport/dialogdesigner/lrdialogdesigner.cpp @@ -0,0 +1,345 @@ +#include "lrdialogdesigner.h" + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pluginmanager_p.h" +//#include + +#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( 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; isetIconSize(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(form); + Q_ASSERT(dialogDesigner != NULL); + //SharedTools::WidgetHost* wh = dynamic_cast(form); + if (dialogDesigner){ + result = dialogDesigner->dialogContent(); + //wh->formWindow()->setDirty(false); + } + return result; +} + +void DialogDesignerManager::setActiveEditor(QWidget *widget) +{ + SharedTools::WidgetHost* wh = dynamic_cast(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::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; iformWindowManager()->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(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; + } +} + +} diff --git a/limereport/dialogdesigner/lrdialogdesigner.h b/limereport/dialogdesigner/lrdialogdesigner.h new file mode 100644 index 0000000..8a0bfbe --- /dev/null +++ b/limereport/dialogdesigner/lrdialogdesigner.h @@ -0,0 +1,93 @@ +#ifndef DIALOGDESIGNER_H +#define DIALOGDESIGNER_H + +#include +#include +#include + +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 m_designerToolWindows; + QAction* m_editWidgetsAction; + QActionGroup* m_modes; + QString m_activeWindowName; + QList m_dialogDesigners; +}; + +} // namespace LimeReport + +#endif // DIALOGDESIGNER_H diff --git a/limereport/dialogdesigner/templates/Dialog.ui b/limereport/dialogdesigner/templates/Dialog.ui new file mode 100644 index 0000000..6eb9e5f --- /dev/null +++ b/limereport/dialogdesigner/templates/Dialog.ui @@ -0,0 +1,18 @@ + + $ClassName$ + + + + 0 + 0 + 400 + 300 + + + + $ClassName$ + + + + + diff --git a/limereport/images/addDialog.png b/limereport/images/addDialog.png new file mode 100644 index 0000000..6023700 Binary files /dev/null and b/limereport/images/addDialog.png differ diff --git a/limereport/images/copy3.png b/limereport/images/copy3.png new file mode 100644 index 0000000..928dcf1 Binary files /dev/null and b/limereport/images/copy3.png differ diff --git a/limereport/images/deleteDialog.png b/limereport/images/deleteDialog.png new file mode 100644 index 0000000..5391490 Binary files /dev/null and b/limereport/images/deleteDialog.png differ diff --git a/limereport/images/paste2.png b/limereport/images/paste2.png new file mode 100644 index 0000000..11399d9 Binary files /dev/null and b/limereport/images/paste2.png differ diff --git a/limereport/images/save.png b/limereport/images/save.png index e6fe0b2..2b31666 100644 Binary files a/limereport/images/save.png and b/limereport/images/save.png differ diff --git a/limereport/images/toBack.png b/limereport/images/toBack.png index 883ae19..1fc9fe1 100644 Binary files a/limereport/images/toBack.png and b/limereport/images/toBack.png differ diff --git a/limereport/images/toBottom.png b/limereport/images/toBottom.png index 73c104d..3f9fe61 100644 Binary files a/limereport/images/toBottom.png and b/limereport/images/toBottom.png differ diff --git a/limereport/images/toCenter.png b/limereport/images/toCenter.png index 6cb7660..95a5bdd 100644 Binary files a/limereport/images/toCenter.png and b/limereport/images/toCenter.png differ diff --git a/limereport/images/toFront.png b/limereport/images/toFront.png index 8d04661..f6666ba 100644 Binary files a/limereport/images/toFront.png and b/limereport/images/toFront.png differ diff --git a/limereport/images/toLeft1.png b/limereport/images/toLeft1.png index 1890060..88cc447 100644 Binary files a/limereport/images/toLeft1.png and b/limereport/images/toLeft1.png differ diff --git a/limereport/images/toRight.png b/limereport/images/toRight.png index e4946f4..14b348f 100644 Binary files a/limereport/images/toRight.png and b/limereport/images/toRight.png differ diff --git a/limereport/images/toSameHeight.png b/limereport/images/toSameHeight.png index 5cb3ff4..d46e0c3 100644 Binary files a/limereport/images/toSameHeight.png and b/limereport/images/toSameHeight.png differ diff --git a/limereport/images/toSameWidth.png b/limereport/images/toSameWidth.png index 52b1e8e..c32f646 100644 Binary files a/limereport/images/toSameWidth.png and b/limereport/images/toSameWidth.png differ diff --git a/limereport/images/toTop.png b/limereport/images/toTop.png index 7b91b8e..58c25e4 100644 Binary files a/limereport/images/toTop.png and b/limereport/images/toTop.png differ diff --git a/limereport/images/toVCernter.png b/limereport/images/toVCernter.png index 3e0689b..79f2fe0 100644 Binary files a/limereport/images/toVCernter.png and b/limereport/images/toVCernter.png differ diff --git a/limereport/images/zoom_in1.png b/limereport/images/zoom_in1.png index 4e6fc7a..f1d1b62 100644 Binary files a/limereport/images/zoom_in1.png and b/limereport/images/zoom_in1.png differ diff --git a/limereport/images/zoom_out1.png b/limereport/images/zoom_out1.png index cce6ea2..04db406 100644 Binary files a/limereport/images/zoom_out1.png and b/limereport/images/zoom_out1.png differ diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 605f96a..5d98aab 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -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){ diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 6a6ff0c..7c7c2bc 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -33,6 +33,7 @@ #include "lrreportengine_p.h" #include "lrbasedesignintf.h" #include "lrsettingdialog.h" +#include "dialogdesigner/lrdialogdesigner.h" #include #include @@ -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; icount(); ++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; ipageCount();++i){ QGraphicsView* view = new QGraphicsView(qobject_cast(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(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 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; icount(); ++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){ diff --git a/limereport/lrreportdesignwidget.h b/limereport/lrreportdesignwidget.h index 28a1998..455b685 100644 --- a/limereport/lrreportdesignwidget.h +++ b/limereport/lrreportdesignwidget.h @@ -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 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; }; } diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index 358aa6b..b44eff7 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -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()){ diff --git a/limereport/lrreportdesignwindow.h b/limereport/lrreportdesignwindow.h index 147f47f..658c984 100644 --- a/limereport/lrreportdesignwindow.h +++ b/limereport/lrreportdesignwindow.h @@ -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 m_recentFiles; + QVector m_pageEditors; + QVector m_dialogEditors; + QVector m_docksToTabify; + ReportDesignWidget::EditorTabType m_editorTabType; + QByteArray m_pageEditorsState; + QByteArray m_dialogEditorsState; + QVector m_pageTools; + QVector m_dialogTools; + }; class ObjectNameValidator : public ValidatorIntf{ diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index 46446bb..e7e061c 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -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); diff --git a/limereport/lrscriptenginemanager.cpp b/limereport/lrscriptenginemanager.cpp index 613b4dc..785640a 100644 --- a/limereport/lrscriptenginemanager.cpp +++ b/limereport/lrscriptenginemanager.cpp @@ -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::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::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(loader.load(&buffer)); m_createdDialogs.push_back(QSharedPointer(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 { diff --git a/limereport/lrscriptenginemanager.h b/limereport/lrscriptenginemanager.h index 726013b..235599a 100644 --- a/limereport/lrscriptenginemanager.h +++ b/limereport/lrscriptenginemanager.h @@ -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& dialogsDescriber(){return m_dialogs;} + const QVector& 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); diff --git a/limereport/report.qrc b/limereport/report.qrc index 6548420..7e5f56d 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -126,9 +126,9 @@ images/hlayuot_3_24.png images/addBand1.png images/delete1.png - images/copy2.png + images/copy2.png images/new_leaf1.png - images/paste1.png + images/paste1.png images/zoom_in1.png images/zoom_out1.png images/folder3.png @@ -175,5 +175,9 @@ images/addBand2.png images/edit_control_4_24.png images/logo_32x32_1.png + images/addDialog.png + images/deleteDialog.png + images/copy3.png + images/paste2.png diff --git a/limereport/scriptbrowser/lrscriptbrowser.cpp b/limereport/scriptbrowser/lrscriptbrowser.cpp index 8e6dcc3..1ef6b73 100644 --- a/limereport/scriptbrowser/lrscriptbrowser.cpp +++ b/limereport/scriptbrowser/lrscriptbrowser.cpp @@ -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())); } diff --git a/limereport/scriptbrowser/lrscriptbrowser.h b/limereport/scriptbrowser/lrscriptbrowser.h index 3214617..dd7d9ae 100644 --- a/limereport/scriptbrowser/lrscriptbrowser.h +++ b/limereport/scriptbrowser/lrscriptbrowser.h @@ -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();