0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 17:18:10 +03:00

Dialog designers tool bar integration has been added

This commit is contained in:
Arin Alexander 2017-04-11 11:23:34 +03:00
parent cd2e748a9b
commit 0692435b26
15 changed files with 209 additions and 24 deletions

View File

@ -15,3 +15,6 @@ QT += designer designercomponents-private
SOURCES += $$PWD/lrdialogdesigner.cpp SOURCES += $$PWD/lrdialogdesigner.cpp
HEADERS += $$PWD/lrdialogdesigner.h HEADERS += $$PWD/lrdialogdesigner.h
RESOURCES += \
$$PWD/dialogdesigner.qrc

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -16,6 +16,8 @@
#include <QDesignerPropertyEditorInterface> #include <QDesignerPropertyEditorInterface>
#include <QDesignerObjectInspectorInterface> #include <QDesignerObjectInspectorInterface>
#include <QDesignerFormEditorInterface> #include <QDesignerFormEditorInterface>
#include <QAction>
#include <QDebug>
#include "pluginmanager_p.h" #include "pluginmanager_p.h"
//#include <QExtensionManager> //#include <QExtensionManager>
@ -30,64 +32,70 @@ DialogDesigner::DialogDesigner(QObject *parent) : QObject(parent)
QDesignerComponents::initializePlugins(m_formEditor); QDesignerComponents::initializePlugins(m_formEditor);
QDesignerComponents::createTaskMenu(m_formEditor, this); QDesignerComponents::createTaskMenu(m_formEditor, this);
m_editWidgetsAction = new QAction(tr("Edit Widgets"));
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() ) foreach ( QObject* o, QPluginLoader::staticInstances() << m_formEditor->pluginManager()->instances() )
{ {
if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) ) if ( QDesignerFormEditorPluginInterface* fep = qobject_cast<QDesignerFormEditorPluginInterface*>( o ) )
{ {
// initialize plugin if needed
if ( !fep->isInitialized() ) if ( !fep->isInitialized() )
fep->initialize( m_formEditor ); fep->initialize( m_formEditor );
fep->action()->setCheckable( true );
// set action chackable fep->action()->setIcon(QIcon(iconPathByName(fep->action()->objectName())));
// fep->action()->setCheckable( true ); m_modes->addAction(fep->action());
// // add action mode to group
// aModes->addAction( fep->action() );
} }
} }
m_widgetBox = QDesignerComponents::createWidgetBox(m_formEditor, 0); m_widgetBox = QDesignerComponents::createWidgetBox(m_formEditor, 0);
m_widgetBox->setWindowTitle(tr("Widget Box")); m_widgetBox->setWindowTitle(tr("Widget Box"));
m_widgetBox->setObjectName(QLatin1String("WidgetBox")); m_widgetBox->setObjectName(QLatin1String("WidgetBox"));
m_formEditor->setWidgetBox(m_widgetBox); m_formEditor->setWidgetBox(m_widgetBox);
m_formEditor->setTopLevel(m_widgetBox); m_formEditor->setTopLevel(m_widgetBox);
m_designerToolWindows.append(m_widgetBox); m_designerToolWindows.append(m_widgetBox);
connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_widgetBox, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0); m_objectInspector = QDesignerComponents::createObjectInspector(m_formEditor, 0);
m_objectInspector->setWindowTitle(tr("Object Inspector")); m_objectInspector->setWindowTitle(tr("Object Inspector"));
m_objectInspector->setObjectName(QLatin1String("ObjectInspector")); m_objectInspector->setObjectName(QLatin1String("ObjectInspector"));
m_formEditor->setObjectInspector(m_objectInspector); m_formEditor->setObjectInspector(m_objectInspector);
m_designerToolWindows.append(m_objectInspector); m_designerToolWindows.append(m_objectInspector);
connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_objectInspector, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0); m_propertyEditor = QDesignerComponents::createPropertyEditor(m_formEditor, 0);
m_propertyEditor->setWindowTitle(tr("Property Editor")); m_propertyEditor->setWindowTitle(tr("Property Editor"));
m_propertyEditor->setObjectName(QLatin1String("PropertyEditor")); m_propertyEditor->setObjectName(QLatin1String("PropertyEditor"));
m_formEditor->setPropertyEditor(m_propertyEditor); m_formEditor->setPropertyEditor(m_propertyEditor);
m_designerToolWindows.append(m_propertyEditor); m_designerToolWindows.append(m_propertyEditor);
connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_propertyEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0); m_signalSlotEditor = QDesignerComponents::createSignalSlotEditor(m_formEditor, 0);
m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor")); m_signalSlotEditor->setWindowTitle(tr("Signals && Slots Editor"));
m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor")); m_signalSlotEditor->setObjectName(QLatin1String("SignalsAndSlotsEditor"));
m_designerToolWindows.append(m_signalSlotEditor); m_designerToolWindows.append(m_signalSlotEditor);
connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_signalSlotEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0); m_resourcesEditor = QDesignerComponents::createResourceEditor(m_formEditor, 0);
m_resourcesEditor->setWindowTitle(tr("Resource Editor")); m_resourcesEditor->setWindowTitle(tr("Resource Editor"));
m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor")); m_resourcesEditor->setObjectName(QLatin1String("ResourceEditor"));
m_designerToolWindows.append(m_resourcesEditor); m_designerToolWindows.append(m_resourcesEditor);
connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_resourcesEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0); m_actionEditor = QDesignerComponents::createActionEditor(m_formEditor, 0);
m_actionEditor->setWindowTitle(tr("Action Editor")); m_actionEditor->setWindowTitle(tr("Action Editor"));
m_actionEditor->setObjectName("ActionEditor"); m_actionEditor->setObjectName("ActionEditor");
m_formEditor->setActionEditor(m_actionEditor); m_formEditor->setActionEditor(m_actionEditor);
m_designerToolWindows.append(m_actionEditor); m_designerToolWindows.append(m_actionEditor);
connect(m_formEditor, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)) ); connect(m_formEditor, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)) );
m_designerIntegration = new QDesignerIntegration(m_formEditor,this); m_designerIntegration = new QDesignerIntegration(m_formEditor,this);
m_formEditor->setIntegration(m_designerIntegration); m_formEditor->setIntegration(m_designerIntegration);
@ -105,6 +113,28 @@ DialogDesigner::~DialogDesigner()
delete m_formEditor; delete m_formEditor;
} }
void DialogDesigner::initToolBar(QToolBar *tb)
{
tb->setIconSize(QSize(16,16));
tb->addAction(m_formEditor->formWindowManager()->actionCopy());
tb->addAction(m_formEditor->formWindowManager()->actionPaste());
tb->addAction(m_formEditor->formWindowManager()->actionCut());
tb->addAction(m_formEditor->formWindowManager()->actionUndo());
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 *DialogDesigner::createFormEditor(const QString &content) QWidget *DialogDesigner::createFormEditor(const QString &content)
{ {
QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window); QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
@ -113,12 +143,22 @@ QWidget *DialogDesigner::createFormEditor(const QString &content)
m_formEditor->objectInspector()->setFormWindow(wnd); m_formEditor->objectInspector()->setFormWindow(wnd);
wnd->editWidgets(); wnd->editWidgets();
connect(wnd, SIGNAL(changed()), this, SIGNAL(dialogChanged()));
SharedTools::WidgetHost *placeholder = new SharedTools::WidgetHost(0,wnd); SharedTools::WidgetHost *placeholder = new SharedTools::WidgetHost(0,wnd);
placeholder->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); placeholder->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
placeholder->setFocusProxy( wnd ); placeholder->setFocusProxy( wnd );
return placeholder; return placeholder;
}
QByteArray DialogDesigner::getDialogDescription(QWidget *form)
{
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form);
if (wh){
return wh->formWindow()->contents().toUtf8();
}
return QByteArray();
} }
void DialogDesigner::setActiveEditor(QWidget *widget) void DialogDesigner::setActiveEditor(QWidget *widget)
@ -127,7 +167,6 @@ void DialogDesigner::setActiveEditor(QWidget *widget)
if (wh){ if (wh){
m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow()); m_formEditor->formWindowManager()->setActiveFormWindow(wh->formWindow());
} }
} }
QWidget* DialogDesigner::widgetBox() const QWidget* DialogDesigner::widgetBox() const
@ -160,7 +199,7 @@ QWidget *DialogDesigner::resourcesEditor() const
return m_resourcesEditor; return m_resourcesEditor;
} }
void DialogDesigner::objectDestroyed(QObject *object) void DialogDesigner::slotObjectDestroyed(QObject *object)
{ {
for ( int i = 0; i<m_designerToolWindows.size();++i){ for ( int i = 0; i<m_designerToolWindows.size();++i){
m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i]; m_designerToolWindows[i] = m_designerToolWindows[i] == object ? 0 : m_designerToolWindows[i];
@ -168,4 +207,30 @@ void DialogDesigner::objectDestroyed(QObject *object)
} }
void DialogDesigner::slotEditWidgets()
{
for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){
m_formEditor->formWindowManager()->formWindow(i)->editWidgets();
}
}
void DialogDesigner::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow)
{
if (formWindow){
m_editWidgetsAction->setEnabled(true);
m_activeWindowName = formWindow->objectName();
}
}
QString DialogDesigner::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 "";
}
} }

View File

@ -3,6 +3,7 @@
#include <QObject> #include <QObject>
#include <QVector> #include <QVector>
#include <QToolBar>
class QDesignerFormEditorInterface; class QDesignerFormEditorInterface;
class QDesignerFormWindowInterface; class QDesignerFormWindowInterface;
@ -21,7 +22,9 @@ class DialogDesigner : public QObject
public: public:
explicit DialogDesigner(QObject *parent = 0); explicit DialogDesigner(QObject *parent = 0);
~DialogDesigner(); ~DialogDesigner();
void initToolBar(QToolBar* tb);
QWidget* createFormEditor(const QString& content); QWidget* createFormEditor(const QString& content);
QByteArray getDialogDescription(QWidget* form);
void setActiveEditor(QWidget* widget); void setActiveEditor(QWidget* widget);
QWidget* widgetBox() const; QWidget* widgetBox() const;
QWidget* actionEditor() const; QWidget* actionEditor() const;
@ -29,8 +32,14 @@ public:
QWidget* objectInspector() const; QWidget* objectInspector() const;
QWidget* signalSlotEditor() const; QWidget* signalSlotEditor() const;
QWidget* resourcesEditor() const; QWidget* resourcesEditor() const;
signals:
void dialogChanged();
private slots: private slots:
void objectDestroyed(QObject* object); void slotObjectDestroyed(QObject* object);
void slotEditWidgets();
void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow);
private:
QString iconPathByName(const QString& name);
private: private:
QDesignerFormEditorInterface* m_formEditor; QDesignerFormEditorInterface* m_formEditor;
QDesignerIntegrationInterface* m_designerIntegration; QDesignerIntegrationInterface* m_designerIntegration;
@ -41,6 +50,9 @@ private:
QWidget* m_signalSlotEditor; QWidget* m_signalSlotEditor;
QWidget* m_resourcesEditor; QWidget* m_resourcesEditor;
QVector<QWidget*> m_designerToolWindows; QVector<QWidget*> m_designerToolWindows;
QAction* m_editWidgetsAction;
QActionGroup* m_modes;
QString m_activeWindowName;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

@ -48,7 +48,11 @@
namespace LimeReport { namespace LimeReport {
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) : ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) :
QWidget(parent), m_dialogDesigner(new DialogDesigner(this)), m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false) QWidget(parent),
#ifdef HAVE_QTDESIGNER_INTEGRATION
m_dialogDesigner(new DialogDesigner(this)),
#endif
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false)
{ {
m_tabWidget = new QTabWidget(this); m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setTabPosition(QTabWidget::South);
@ -74,9 +78,14 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
m_scriptEditor->setPlainText(report->scriptContext()->initScript()); m_scriptEditor->setPlainText(report->scriptContext()->initScript());
m_zoomer = new GraphicsViewZoomer(activeView()); m_zoomer = new GraphicsViewZoomer(activeView());
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
m_defaultFont = QFont("Arial",10); m_defaultFont = QFont("Arial",10);
#endif #endif
#ifdef HAVE_QTDESIGNER_INTEGRATION
connect(m_dialogDesigner, SIGNAL(dialogChanged()), this, SLOT(slotDialogChanged()));
#endif
} }
DialogDesigner *ReportDesignWidget::dialogDesigner() const DialogDesigner *ReportDesignWidget::dialogDesigner() const
@ -112,6 +121,20 @@ ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType()
return Page; return Page;
} }
void ReportDesignWidget::initDialogDesignerToolBar(QToolBar *toolBar)
{
m_dialogDesigner->initToolBar(toolBar);
}
void ReportDesignWidget::updateDialogs()
{
for ( int i = 0; i<m_tabWidget->count(); ++i ){
if (m_tabWidget->tabWhatsThis(i).compare("dialog") == 0){
m_report->scriptContext()->changeDialog(m_tabWidget->tabText(i), m_dialogDesigner->getDialogDescription(m_tabWidget->widget(i)));
}
}
}
bool ReportDesignWidget::useMagnet() const bool ReportDesignWidget::useMagnet() const
{ {
return m_useMagnet; return m_useMagnet;
@ -299,7 +322,12 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
} }
void ReportDesignWidget::saveToFile(const QString &fileName){ void ReportDesignWidget::saveToFile(const QString &fileName){
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
if (m_report->saveToFile(fileName)) { if (m_report->saveToFile(fileName)) {
m_report->emitSaveFinished(); m_report->emitSaveFinished();
} }
@ -308,6 +336,10 @@ void ReportDesignWidget::saveToFile(const QString &fileName){
bool ReportDesignWidget::save() bool ReportDesignWidget::save()
{ {
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
if (!m_report->reportFileName().isEmpty()){ if (!m_report->reportFileName().isEmpty()){
if (m_report->saveToFile()){ if (m_report->saveToFile()){
m_report->emitSaveFinished(); m_report->emitSaveFinished();
@ -499,12 +531,18 @@ void ReportDesignWidget::setBorders(const BaseDesignIntf::BorderLines& borders)
void ReportDesignWidget::previewReport() void ReportDesignWidget::previewReport()
{ {
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
report()->previewReport(); report()->previewReport();
} }
void ReportDesignWidget::printReport() void ReportDesignWidget::printReport()
{ {
report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText()); report()->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs();
#endif
setCursor(Qt::WaitCursor); setCursor(Qt::WaitCursor);
report()->printReport(); report()->printReport();
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
@ -653,6 +691,14 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
emit activePageChanged(); emit activePageChanged();
} }
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::slotDialogChanged()
{
}
#endif
bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event) bool ReportDesignWidget::eventFilter(QObject *target, QEvent *event)
{ {
if (event->type() == QEvent::Wheel){ if (event->type() == QEvent::Wheel){

View File

@ -54,7 +54,6 @@ class ReportDesignWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QObject* datasourcesManager READ dataManager()) Q_PROPERTY(QObject* datasourcesManager READ dataManager())
friend class ReportDesignWindow;
public: public:
enum ToolWindowType{ enum ToolWindowType{
WidgetBox = 1, WidgetBox = 1,
@ -69,6 +68,7 @@ public:
Dialog, Dialog,
Script Script
}; };
ReportDesignWidget(ReportEnginePrivate* report,QMainWindow *mainWindow,QWidget *parent = 0);
~ReportDesignWidget(); ~ReportDesignWidget();
void createStartPage(); void createStartPage();
void clear(); void clear();
@ -103,6 +103,10 @@ public:
DialogDesigner *dialogDesigner() const; DialogDesigner *dialogDesigner() const;
QWidget* toolWindow(ToolWindowType windowType); QWidget* toolWindow(ToolWindowType windowType);
EditorTabType activeTabType(); EditorTabType activeTabType();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void initDialogDesignerToolBar(QToolBar* toolBar);
void updateDialogs();
#endif
public slots: public slots:
void saveToFile(const QString&); void saveToFile(const QString&);
bool save(); bool save();
@ -135,13 +139,16 @@ public slots:
void printReport(); void printReport();
void addPage(); void addPage();
void deleteCurrentPage(); void deleteCurrentPage();
void slotPagesLoadFinished();
private slots: private slots:
void slotItemSelected(LimeReport::BaseDesignIntf *item); void slotItemSelected(LimeReport::BaseDesignIntf *item);
void slotSelectionChanged(); void slotSelectionChanged();
void slotPagesLoadFinished();
void slotDatasourceCollectionLoaded(const QString&); void slotDatasourceCollectionLoaded(const QString&);
void slotSceneRectChanged(QRectF); void slotSceneRectChanged(QRectF);
void slotCurrentTabChanged(int index); void slotCurrentTabChanged(int index);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged();
#endif
signals: signals:
void insertModeStarted(); void insertModeStarted();
void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&); void itemInserted(LimeReport::PageDesignIntf*,QPointF,const QString&);
@ -164,7 +171,6 @@ protected:
void createTabs(); void createTabs();
private: private:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
ReportDesignWidget(ReportEnginePrivate* report,QMainWindow *mainWindow,QWidget *parent = 0);
private: private:
ReportEnginePrivate* m_report; ReportEnginePrivate* m_report;
QGraphicsView *m_view; QGraphicsView *m_view;

View File

@ -80,6 +80,7 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par
createDialogActionEditor(); createDialogActionEditor();
createDialogResourceEditor(); createDialogResourceEditor();
createDialogSignalSlotEditor(); createDialogSignalSlotEditor();
createDialogDesignerToolBar();
#endif #endif
m_instance=this; m_instance=this;
m_statusBar=new QStatusBar(this); m_statusBar=new QStatusBar(this);
@ -87,11 +88,12 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par
m_statusBar->insertWidget(0,m_lblReportName); m_statusBar->insertWidget(0,m_lblReportName);
setStatusBar(m_statusBar); setStatusBar(m_statusBar);
setWindowTitle("Lime Report Designer"); setWindowTitle("Lime Report Designer");
showDefaultEditors();
showDefaultToolBars();
restoreSetting(); restoreSetting();
m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea)); m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea));
m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea)); m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea));
m_editorTabType = ReportDesignWidget::Page; m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors();
} }
ReportDesignWindow::~ReportDesignWindow() ReportDesignWindow::~ReportDesignWindow()
@ -323,6 +325,9 @@ void ReportDesignWindow::createToolBars()
addToolBar(m_itemsBordersEditorBar); addToolBar(m_itemsBordersEditorBar);
createReportToolBar(); createReportToolBar();
m_pageTools << m_mainToolBar << m_reportToolBar << m_fontEditorBar << m_textAlignmentEditorBar << m_itemsBordersEditorBar;
} }
void ReportDesignWindow::createItemsActions() void ReportDesignWindow::createItemsActions()
@ -573,6 +578,14 @@ void ReportDesignWindow::createDialogSignalSlotEditor()
m_dialogEditors.append(doc); m_dialogEditors.append(doc);
} }
void ReportDesignWindow::createDialogDesignerToolBar()
{
m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools"));
m_dialogDesignerToolBar->setObjectName("DialogDesignerTools");
m_reportDesignWidget->initDialogDesignerToolBar(m_dialogDesignerToolBar);
m_dialogTools << m_dialogDesignerToolBar;
}
#endif #endif
void ReportDesignWindow::createDataWindow() void ReportDesignWindow::createDataWindow()
{ {
@ -622,6 +635,7 @@ void ReportDesignWindow::startNewReport()
m_newReportFooter->setEnabled(true); m_newReportFooter->setEnabled(true);
m_editorTabType = ReportDesignWidget::Page; m_editorTabType = ReportDesignWidget::Page;
showDefaultEditors(); showDefaultEditors();
showDefaultToolBars();
} }
void ReportDesignWindow::writePosition() void ReportDesignWindow::writePosition()
@ -1048,6 +1062,7 @@ void ReportDesignWindow::slotLoadReport()
setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer"); setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer");
addRecentFile(fileName); addRecentFile(fileName);
m_editorTabType = ReportDesignWidget::Page; m_editorTabType = ReportDesignWidget::Page;
showDefaultToolBars();
showDefaultEditors(); showDefaultEditors();
} }
} }
@ -1215,6 +1230,14 @@ 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(){ void ReportDesignWindow::showDefaultEditors(){
foreach (QDockWidget* w, m_pageEditors) { foreach (QDockWidget* w, m_pageEditors) {
@ -1248,12 +1271,14 @@ void ReportDesignWindow::slotActivePageChanged()
restoreState(m_dialogEditorsState); restoreState(m_dialogEditorsState);
else else
showDefaultEditors(); showDefaultEditors();
showDefaultToolBars();
break; break;
default: default:
if (!m_pageEditors.isEmpty()) if (!m_pageEditors.isEmpty())
restoreState(m_pageEditorsState); restoreState(m_pageEditorsState);
else else
showDefaultEditors(); showDefaultEditors();
showDefaultToolBars();
break; break;
} }

View File

@ -144,6 +144,7 @@ private:
void createDialogActionEditor(); void createDialogActionEditor();
void createDialogResourceEditor(); void createDialogResourceEditor();
void createDialogSignalSlotEditor(); void createDialogSignalSlotEditor();
void createDialogDesignerToolBar();
#endif #endif
void updateRedoUndo(); void updateRedoUndo();
void updateAvaibleBands(); void updateAvaibleBands();
@ -154,6 +155,7 @@ private:
void removeNotExistedRecentFiles(); void removeNotExistedRecentFiles();
void removeNotExistedRecentFilesFromMenu(const QString& fileName); void removeNotExistedRecentFilesFromMenu(const QString& fileName);
void addRecentFile(const QString& fileName); void addRecentFile(const QString& fileName);
void showDefaultToolBars();
void showDefaultEditors(); void showDefaultEditors();
private: private:
static ReportDesignWindow* m_instance; static ReportDesignWindow* m_instance;
@ -162,6 +164,9 @@ private:
QToolBar* m_fontToolBar; QToolBar* m_fontToolBar;
QToolBar* m_reportToolBar; QToolBar* m_reportToolBar;
QToolBar* m_alignToolBar; QToolBar* m_alignToolBar;
#ifdef HAVE_QTDESIGNER_INTEGRATION
QToolBar* m_dialogDesignerToolBar;
#endif
QToolButton* m_newBandButton; QToolButton* m_newBandButton;
QMenuBar* m_mainMenu; QMenuBar* m_mainMenu;
QMenu* m_fileMenu; QMenu* m_fileMenu;
@ -249,6 +254,8 @@ private:
ReportDesignWidget::EditorTabType m_editorTabType; ReportDesignWidget::EditorTabType m_editorTabType;
QByteArray m_pageEditorsState; QByteArray m_pageEditorsState;
QByteArray m_dialogEditorsState; QByteArray m_dialogEditorsState;
QVector<QToolBar*> m_pageTools;
QVector<QToolBar*> m_dialogTools;
}; };

View File

@ -1067,6 +1067,17 @@ void ScriptEngineContext::addDialog(const QString& name, const QByteArray& descr
m_dialogs.push_back(DialogDescriber::create(name,description)); m_dialogs.push_back(DialogDescriber::create(name,description));
} }
bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& description)
{
foreach( DialogDescriber::Ptr describer, m_dialogs){
if (describer->name().compare(name) == 0){
describer->setDescription(description);
return true;
}
}
return false;
}
bool ScriptEngineContext::previewDialog(const QString& dialogName) bool ScriptEngineContext::previewDialog(const QString& dialogName)
{ {
QDialog* dialog = getDialog(dialogName); QDialog* dialog = getDialog(dialogName);

View File

@ -144,7 +144,8 @@ public:
#endif #endif
explicit ScriptEngineContext(QObject* parent=0):QObject(parent){} explicit ScriptEngineContext(QObject* parent=0):QObject(parent){}
#ifdef HAVE_UI_LOADER #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 previewDialog(const QString& dialogName); bool previewDialog(const QString& dialogName);
bool containsDialog(const QString& dialogName); bool containsDialog(const QString& dialogName);
const QVector<DialogDescriber::Ptr>& dialogDescribers(){return m_dialogs;} const QVector<DialogDescriber::Ptr>& dialogDescribers(){return m_dialogs;}