Dialog Designer intergration has been finished

This commit is contained in:
Arin Alexander 2017-04-14 02:43:34 +03:00
parent 0692435b26
commit 7b04b6efca
15 changed files with 448 additions and 76 deletions

View File

@ -6,4 +6,7 @@
<file>images/tabordertool.png</file> <file>images/tabordertool.png</file>
<file>images/widgettool.png</file> <file>images/widgettool.png</file>
</qresource> </qresource>
<qresource prefix="/templates">
<file>templates/Dialog.ui</file>
</qresource>
</RCC> </RCC>

View File

@ -18,6 +18,7 @@
#include <QDesignerFormEditorInterface> #include <QDesignerFormEditorInterface>
#include <QAction> #include <QAction>
#include <QDebug> #include <QDebug>
#include <QVBoxLayout>
#include "pluginmanager_p.h" #include "pluginmanager_p.h"
//#include <QExtensionManager> //#include <QExtensionManager>
@ -25,14 +26,14 @@
namespace LimeReport{ namespace LimeReport{
DialogDesigner::DialogDesigner(QObject *parent) : QObject(parent) DialogDesignerManager::DialogDesignerManager(QObject *parent) : QObject(parent)
{ {
QDesignerComponents::initializeResources(); QDesignerComponents::initializeResources();
m_formEditor = QDesignerComponents::createFormEditor(this); m_formEditor = QDesignerComponents::createFormEditor(this);
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 = new QAction(tr("Edit Widgets"), this);
m_editWidgetsAction->setIcon(QIcon(":/images/images/widgettool.png")); m_editWidgetsAction->setIcon(QIcon(":/images/images/widgettool.png"));
m_editWidgetsAction->setEnabled(false); m_editWidgetsAction->setEnabled(false);
connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets())); connect(m_editWidgetsAction, SIGNAL(triggered()), this, SLOT(slotEditWidgets()));
@ -102,7 +103,7 @@ DialogDesigner::DialogDesigner(QObject *parent) : QObject(parent)
} }
DialogDesigner::~DialogDesigner() DialogDesignerManager::~DialogDesignerManager()
{ {
for (int i = 0; i<m_designerToolWindows.size();++i){ for (int i = 0; i<m_designerToolWindows.size();++i){
if (m_designerToolWindows[i]) if (m_designerToolWindows[i])
@ -113,13 +114,18 @@ DialogDesigner::~DialogDesigner()
delete m_formEditor; delete m_formEditor;
} }
void DialogDesigner::initToolBar(QToolBar *tb) void DialogDesignerManager::initToolBar(QToolBar *tb)
{ {
tb->setIconSize(QSize(16,16)); tb->setIconSize(QSize(16,16));
m_formEditor->formWindowManager()->actionCopy()->setIcon(QIcon(":/report/images/copy"));
tb->addAction(m_formEditor->formWindowManager()->actionCopy()); tb->addAction(m_formEditor->formWindowManager()->actionCopy());
m_formEditor->formWindowManager()->actionPaste()->setIcon(QIcon(":/report/images/paste"));
tb->addAction(m_formEditor->formWindowManager()->actionPaste()); tb->addAction(m_formEditor->formWindowManager()->actionPaste());
m_formEditor->formWindowManager()->actionCut()->setIcon(QIcon(":/report/images/cut"));
tb->addAction(m_formEditor->formWindowManager()->actionCut()); tb->addAction(m_formEditor->formWindowManager()->actionCut());
m_formEditor->formWindowManager()->actionUndo()->setIcon(QIcon(":/report/images/undo"));
tb->addAction(m_formEditor->formWindowManager()->actionUndo()); tb->addAction(m_formEditor->formWindowManager()->actionUndo());
m_formEditor->formWindowManager()->actionRedo()->setIcon(QIcon(":/report/images/redo"));
tb->addAction(m_formEditor->formWindowManager()->actionRedo()); tb->addAction(m_formEditor->formWindowManager()->actionRedo());
tb->addActions(m_modes->actions()); tb->addActions(m_modes->actions());
@ -135,7 +141,7 @@ void DialogDesigner::initToolBar(QToolBar *tb)
tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize()); tb->addAction(m_formEditor->formWindowManager()->actionAdjustSize());
} }
QWidget *DialogDesigner::createFormEditor(const QString &content) QWidget *DialogDesignerManager::createFormEditor(const QString &content)
{ {
QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window); QDesignerFormWindowInterface* wnd = m_formEditor->formWindowManager()->createFormWindow(0, Qt::Window);
wnd->setContents(content); wnd->setContents(content);
@ -143,25 +149,32 @@ 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())); DialogDesigner* dialogDesigner = new DialogDesigner(wnd, m_formEditor);
SharedTools::WidgetHost *placeholder = new SharedTools::WidgetHost(0,wnd); connect(dialogDesigner, SIGNAL(dialogChanged()), this, SLOT(slotDialogChanged()));
placeholder->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); connect(dialogDesigner, SIGNAL(dialogNameChanged(QString,QString)), this, SIGNAL(dialogNameChanged(QString,QString)));
placeholder->setFocusProxy( wnd ); connect(dialogDesigner, SIGNAL(destroyed(QObject*)), this, SLOT(slotObjectDestroyed(QObject*)));
m_dialogDesigners.append(dialogDesigner);
return dialogDesigner;
return placeholder;
} }
QByteArray DialogDesigner::getDialogDescription(QWidget *form) QByteArray DialogDesignerManager::getDialogDescription(QWidget *form)
{ {
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form); QByteArray result;
if (wh){ DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(form);
return wh->formWindow()->contents().toUtf8(); Q_ASSERT(dialogDesigner != NULL);
//SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(form);
if (dialogDesigner){
result = dialogDesigner->dialogContent();
//wh->formWindow()->setDirty(false);
} }
return QByteArray(); return result;
} }
void DialogDesigner::setActiveEditor(QWidget *widget) void DialogDesignerManager::setActiveEditor(QWidget *widget)
{ {
SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget); SharedTools::WidgetHost* wh = dynamic_cast<SharedTools::WidgetHost*>(widget);
if (wh){ if (wh){
@ -169,52 +182,70 @@ void DialogDesigner::setActiveEditor(QWidget *widget)
} }
} }
QWidget* DialogDesigner::widgetBox() const void DialogDesignerManager::setDirty(bool value)
{
foreach(DialogDesigner* dialogDesigner, m_dialogDesigners){
dialogDesigner->setChanged(value);
}
}
QWidget* DialogDesignerManager::widgetBox() const
{ {
return m_widgetBox; return m_widgetBox;
} }
QWidget* DialogDesigner::actionEditor() const QWidget* DialogDesignerManager::actionEditor() const
{ {
return m_actionEditor; return m_actionEditor;
} }
QWidget* DialogDesigner::propertyEditor() const QWidget* DialogDesignerManager::propertyEditor() const
{ {
return m_propertyEditor; return m_propertyEditor;
} }
QWidget* DialogDesigner::objectInspector() const QWidget* DialogDesignerManager::objectInspector() const
{ {
return m_objectInspector; return m_objectInspector;
} }
QWidget *DialogDesigner::signalSlotEditor() const QWidget *DialogDesignerManager::signalSlotEditor() const
{ {
return m_signalSlotEditor; return m_signalSlotEditor;
} }
QWidget *DialogDesigner::resourcesEditor() const QWidget *DialogDesignerManager::resourcesEditor() const
{ {
return m_resourcesEditor; return m_resourcesEditor;
} }
void DialogDesigner::slotObjectDestroyed(QObject *object) void DialogDesignerManager::slotObjectDestroyed(QObject* object)
{ {
QList<DialogDesigner*>::Iterator it = m_dialogDesigners.begin();
while(it!=m_dialogDesigners.end()){
if (*it == object){
it = m_dialogDesigners.erase(it);
return;
} else {
++it;
}
}
for ( int i = 0; i<m_designerToolWindows.size();++i){ 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];
} }
} }
void DialogDesigner::slotEditWidgets() void DialogDesignerManager::slotEditWidgets()
{ {
for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){ for (int i = 0; i<m_formEditor->formWindowManager()->formWindowCount(); ++i){
m_formEditor->formWindowManager()->formWindow(i)->editWidgets(); m_formEditor->formWindowManager()->formWindow(i)->editWidgets();
} }
} }
void DialogDesigner::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow) void DialogDesignerManager::slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow)
{ {
if (formWindow){ if (formWindow){
m_editWidgetsAction->setEnabled(true); m_editWidgetsAction->setEnabled(true);
@ -222,7 +253,15 @@ void DialogDesigner::slotActiveFormWindowChanged(QDesignerFormWindowInterface *f
} }
} }
QString DialogDesigner::iconPathByName(const QString &name) void DialogDesignerManager::slotDialogChanged()
{
DialogDesigner* dialogDesigner = dynamic_cast<DialogDesigner*>(sender());
if (dialogDesigner){
emit dialogChanged(dialogDesigner->dialogName());
}
}
QString DialogDesignerManager::iconPathByName(const QString &name)
{ {
if (name.compare("__qt_edit_signals_slots_action") == 0) if (name.compare("__qt_edit_signals_slots_action") == 0)
return ":/images/images/signalslottool.png"; return ":/images/images/signalslottool.png";
@ -233,4 +272,74 @@ QString DialogDesigner::iconPathByName(const QString &name)
return ""; return "";
} }
DialogDesigner::DialogDesigner(QDesignerFormWindowInterface* wnd, QDesignerFormEditorInterface* formEditor, QWidget *parent, Qt::WindowFlags flags)
:QWidget(parent, flags), m_formEditor(formEditor)
{
m_dialogName = wnd->mainContainer()->objectName();
connect(wnd, SIGNAL(changed()), this, SIGNAL(dialogChanged()));
connect(wnd->mainContainer(), SIGNAL(objectNameChanged(QString)), this, SLOT(slotMainContainerNameChanged(QString)));
m_designerHolder = new SharedTools::WidgetHost(this,wnd);
m_designerHolder->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
m_designerHolder->setFocusProxy( wnd );
QVBoxLayout* l = new QVBoxLayout(this);
l->addWidget(m_designerHolder);
setLayout(l);
}
DialogDesigner::~DialogDesigner(){}
QString DialogDesigner::dialogName() const
{
return m_dialogName;
}
void DialogDesigner::setDialogName(const QString &dialogName)
{
m_dialogName = dialogName;
}
bool DialogDesigner::isChanged()
{
return m_designerHolder->formWindow()->isDirty();
}
void DialogDesigner::setChanged(bool value)
{
m_designerHolder->formWindow()->setDirty(false);
}
QByteArray DialogDesigner::dialogContent()
{
if (m_designerHolder && m_designerHolder->formWindow())
return m_designerHolder->formWindow()->contents().toUtf8();
return QByteArray();
}
void DialogDesigner::undo()
{
Q_ASSERT(m_formEditor != NULL);
if (m_formEditor){
m_formEditor->formWindowManager()->actionUndo()->trigger();
}
}
void DialogDesigner::redo()
{
Q_ASSERT(m_formEditor != NULL);
if (m_formEditor){
m_formEditor->formWindowManager()->actionRedo()->trigger();
}
}
void DialogDesigner::slotMainContainerNameChanged(QString newName)
{
if (m_dialogName.compare(newName) != 0){
emit dialogNameChanged(m_dialogName, newName);
m_dialogName = newName;
}
}
} }

View File

@ -14,18 +14,48 @@ class QDesignerPropertyEditorInterface;
class QDesignerObjectInspectorInterface; class QDesignerObjectInspectorInterface;
class QDesignerFormWindowManagerInterface; class QDesignerFormWindowManagerInterface;
namespace SharedTools{
class WidgetHost;
}
namespace LimeReport{ namespace LimeReport{
class DialogDesigner : public QObject 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 Q_OBJECT
public: public:
explicit DialogDesigner(QObject *parent = 0); explicit DialogDesignerManager(QObject *parent = 0);
~DialogDesigner(); ~DialogDesignerManager();
void initToolBar(QToolBar* tb); void initToolBar(QToolBar* tb);
QWidget* createFormEditor(const QString& content); QWidget* createFormEditor(const QString& content);
QByteArray getDialogDescription(QWidget* form); QByteArray getDialogDescription(QWidget* form);
void setActiveEditor(QWidget* widget); void setActiveEditor(QWidget* widget);
void setDirty(bool value);
QWidget* widgetBox() const; QWidget* widgetBox() const;
QWidget* actionEditor() const; QWidget* actionEditor() const;
QWidget* propertyEditor() const; QWidget* propertyEditor() const;
@ -33,11 +63,13 @@ public:
QWidget* signalSlotEditor() const; QWidget* signalSlotEditor() const;
QWidget* resourcesEditor() const; QWidget* resourcesEditor() const;
signals: signals:
void dialogChanged(); void dialogChanged(QString dialogName);
void dialogNameChanged(QString oldName, QString newName);
private slots: private slots:
void slotObjectDestroyed(QObject* object); void slotObjectDestroyed(QObject* object);
void slotEditWidgets(); void slotEditWidgets();
void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow); void slotActiveFormWindowChanged(QDesignerFormWindowInterface *formWindow);
void slotDialogChanged();
private: private:
QString iconPathByName(const QString& name); QString iconPathByName(const QString& name);
private: private:
@ -53,6 +85,7 @@ private:
QAction* m_editWidgetsAction; QAction* m_editWidgetsAction;
QActionGroup* m_modes; QActionGroup* m_modes;
QString m_activeWindowName; QString m_activeWindowName;
QList<DialogDesigner*> m_dialogDesigners;
}; };
} // namespace LimeReport } // namespace LimeReport

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

View File

@ -50,9 +50,9 @@ namespace LimeReport {
ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) : ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow *mainWindow, QWidget *parent) :
QWidget(parent), QWidget(parent),
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
m_dialogDesigner(new DialogDesigner(this)), m_dialogDesignerManager(new DialogDesignerManager(this)),
#endif #endif
m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false) m_mainWindow(mainWindow), m_verticalGridStep(10), m_horizontalGridStep(10), m_useGrid(false), m_dialogChanged(false)
{ {
m_tabWidget = new QTabWidget(this); m_tabWidget = new QTabWidget(this);
m_tabWidget->setTabPosition(QTabWidget::South); m_tabWidget->setTabPosition(QTabWidget::South);
@ -75,6 +75,7 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
connect(m_report,SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished())); connect(m_report,SIGNAL(pagesLoadFinished()),this,SLOT(slotPagesLoadFinished()));
connect(m_report,SIGNAL(cleared()),this,SIGNAL(cleared())); connect(m_report,SIGNAL(cleared()),this,SIGNAL(cleared()));
connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int))); connect(m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));
connect(m_report->scriptContext(), SIGNAL(dialogDeleted(QString)), this, SLOT(slotDialogDeleted(QString)));
m_scriptEditor->setPlainText(report->scriptContext()->initScript()); m_scriptEditor->setPlainText(report->scriptContext()->initScript());
m_zoomer = new GraphicsViewZoomer(activeView()); m_zoomer = new GraphicsViewZoomer(activeView());
@ -84,35 +85,49 @@ ReportDesignWidget::ReportDesignWidget(ReportEnginePrivate *report, QMainWindow
#endif #endif
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
connect(m_dialogDesigner, SIGNAL(dialogChanged()), this, SLOT(slotDialogChanged())); connect(m_dialogDesignerManager, SIGNAL(dialogChanged(QString)),
this, SLOT(slotDialogChanged(QString)));
connect(m_dialogDesignerManager, SIGNAL(dialogNameChanged(QString,QString)),
this, SLOT(slotDialogNameChanged(QString,QString)));
#endif #endif
} }
DialogDesigner *ReportDesignWidget::dialogDesigner() const #ifdef HAVE_QTDESIGNER_INTEGRATION
DialogDesignerManager *ReportDesignWidget::dialogDesignerManager() const
{ {
return m_dialogDesigner; return m_dialogDesignerManager;
} }
QString ReportDesignWidget::activeDialogName()
{
if (activeDialogPage())
return activeDialogPage()->dialogName();
return "";
}
QWidget *ReportDesignWidget::toolWindow(ReportDesignWidget::ToolWindowType windowType) QWidget *ReportDesignWidget::toolWindow(ReportDesignWidget::ToolWindowType windowType)
{ {
switch (windowType) { switch (windowType) {
case WidgetBox: case WidgetBox:
return dialogDesigner()->widgetBox(); return dialogDesignerManager()->widgetBox();
case PropertyEditor: case PropertyEditor:
return dialogDesigner()->propertyEditor(); return dialogDesignerManager()->propertyEditor();
case ObjectInspector: case ObjectInspector:
return dialogDesigner()->objectInspector(); return dialogDesignerManager()->objectInspector();
case ActionEditor: case ActionEditor:
return dialogDesigner()->actionEditor(); return dialogDesignerManager()->actionEditor();
case ResourceEditor: case ResourceEditor:
return dialogDesigner()->resourcesEditor(); return dialogDesignerManager()->resourcesEditor();
case SignalSlotEditor: case SignalSlotEditor:
return dialogDesigner()->signalSlotEditor(); return dialogDesignerManager()->signalSlotEditor();
default: default:
return 0; return 0;
} }
} }
#endif
ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType() ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType()
{ {
QString tabType = m_tabWidget->tabWhatsThis(m_tabWidget->currentIndex()); QString tabType = m_tabWidget->tabWhatsThis(m_tabWidget->currentIndex());
@ -121,20 +136,24 @@ ReportDesignWidget::EditorTabType ReportDesignWidget::activeTabType()
return Page; return Page;
} }
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::initDialogDesignerToolBar(QToolBar *toolBar) void ReportDesignWidget::initDialogDesignerToolBar(QToolBar *toolBar)
{ {
m_dialogDesigner->initToolBar(toolBar); m_dialogDesignerManager->initToolBar(toolBar);
} }
void ReportDesignWidget::updateDialogs() void ReportDesignWidget::updateDialogs()
{ {
for ( int i = 0; i<m_tabWidget->count(); ++i ){ for ( int i = 0; i<m_tabWidget->count(); ++i ){
if (m_tabWidget->tabWhatsThis(i).compare("dialog") == 0){ if (m_tabWidget->tabWhatsThis(i).compare("dialog") == 0){
m_report->scriptContext()->changeDialog(m_tabWidget->tabText(i), m_dialogDesigner->getDialogDescription(m_tabWidget->widget(i))); m_report->scriptContext()->changeDialog(m_tabWidget->tabText(i), m_dialogDesignerManager->getDialogDescription(m_tabWidget->widget(i)));
} }
} }
} }
#endif
bool ReportDesignWidget::useMagnet() const bool ReportDesignWidget::useMagnet() const
{ {
return m_useMagnet; return m_useMagnet;
@ -210,21 +229,38 @@ void ReportDesignWidget::createTabs(){
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName()); pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page"); m_tabWidget->setTabWhatsThis(pageIndex, "page");
} }
#ifdef HAVE_QTDESIGNER_INTEGRATION
QWidget* dialogEditor;
foreach(DialogDescriber::Ptr dialogDesc, m_report->scriptContext()->dialogDescribers()){
dialogEditor = m_dialogDesigner->createFormEditor(dialogDesc->description());
pageIndex = m_tabWidget->addTab(dialogEditor,QIcon(),dialogDesc->name());
m_tabWidget->setTabWhatsThis(pageIndex,"dialog");
}
#endif
m_scriptEditor = new QTextEdit(this); m_scriptEditor = new QTextEdit(this);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script")); pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
m_tabWidget->setTabWhatsThis(pageIndex,"script"); m_tabWidget->setTabWhatsThis(pageIndex,"script");
m_tabWidget->setCurrentIndex(0); 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");
}
DialogDesigner*ReportDesignWidget::activeDialogPage()
{
return dynamic_cast<DialogDesigner*>(m_tabWidget->currentWidget());
}
#endif
ReportDesignWidget::~ReportDesignWidget() ReportDesignWidget::~ReportDesignWidget()
{ {
delete m_zoomer; delete m_zoomer;
@ -301,6 +337,8 @@ PageDesignIntf * ReportDesignWidget::activePage()
return 0; return 0;
} }
QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){ QList<QGraphicsItem *> ReportDesignWidget::selectedItems(){
return activePage()->selectedItems(); return activePage()->selectedItems();
} }
@ -321,16 +359,26 @@ void ReportDesignWidget::slotItemSelected(BaseDesignIntf *item){
emit itemSelected(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()); m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
updateDialogs(); updateDialogs();
#endif #endif
if (m_report->saveToFile(fileName)) { 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() bool ReportDesignWidget::save()
@ -340,24 +388,32 @@ bool ReportDesignWidget::save()
updateDialogs(); updateDialogs();
#endif #endif
bool result = false;
if (!m_report->reportFileName().isEmpty()){ if (!m_report->reportFileName().isEmpty()){
if (m_report->saveToFile()){ if (m_report->saveToFile()){
m_report->emitSaveFinished(); m_report->emitSaveFinished();
return true; result = true;
} }
} }
else { else {
m_report->emitSaveReport(); m_report->emitSaveReport();
if (m_report->isSaved()) { if (m_report->isSaved()) {
m_report->emitSaveFinished(); 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(); 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) bool ReportDesignWidget::loadFromFile(const QString &fileName)
@ -367,6 +423,7 @@ bool ReportDesignWidget::loadFromFile(const QString &fileName)
//connectPage(m_report->pageAt(0)); //connectPage(m_report->pageAt(0));
m_scriptEditor->setPlainText(m_report->scriptContext()->initScript()); m_scriptEditor->setPlainText(m_report->scriptContext()->initScript());
emit loaded(); emit loaded();
m_dialogChanged = false;
return true; return true;
} else { } else {
QMessageBox::critical(this,tr("Error"),tr("Wrong file format")); QMessageBox::critical(this,tr("Error"),tr("Wrong file format"));
@ -390,7 +447,7 @@ QString ReportDesignWidget::reportFileName()
bool ReportDesignWidget::isNeedToSave() bool ReportDesignWidget::isNeedToSave()
{ {
if(m_report) if(m_report)
return m_report->isNeedToSave(); return (m_report->isNeedToSave() || m_dialogChanged);
return false; return false;
} }
@ -409,12 +466,20 @@ void ReportDesignWidget::undo()
{ {
if (activePage()) if (activePage())
activePage()->undo(); activePage()->undo();
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeDialogPage())
activeDialogPage()->undo();
#endif
} }
void ReportDesignWidget::redo() void ReportDesignWidget::redo()
{ {
if (activePage()) if (activePage())
activePage()->redo(); activePage()->redo();
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeDialogPage())
activeDialogPage()->redo();
#endif
} }
void ReportDesignWidget::copy() void ReportDesignWidget::copy()
@ -667,6 +732,16 @@ void ReportDesignWidget::slotPagesLoadFinished()
emit loaded(); emit loaded();
} }
void ReportDesignWidget::slotDialogDeleted(QString dialogName)
{
for (int i = 0; i<m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(dialogName) == 0){
delete m_tabWidget->widget(i);
break;
}
}
}
void ReportDesignWidget::slotDatasourceCollectionLoaded(const QString & /*collectionName*/) void ReportDesignWidget::slotDatasourceCollectionLoaded(const QString & /*collectionName*/)
{ {
} }
@ -685,16 +760,40 @@ void ReportDesignWidget::slotCurrentTabChanged(int index)
} }
m_zoomer->setView(view); m_zoomer->setView(view);
} }
#ifdef HAVE_QTDESIGNER_INTEGRATION
if (activeTabType() == Dialog){ if (activeTabType() == Dialog){
m_dialogDesigner->setActiveEditor(m_tabWidget->widget(index)); m_dialogDesignerManager->setActiveEditor(m_tabWidget->widget(index));
} }
updateDialogs();
#endif
emit activePageChanged(); emit activePageChanged();
} }
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::slotDialogChanged() 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 #endif

View File

@ -48,6 +48,7 @@ namespace LimeReport {
class ReportEnginePrivate; class ReportEnginePrivate;
class DataBrowser; class DataBrowser;
class ReportDesignWindow; class ReportDesignWindow;
class DialogDesignerManager;
class DialogDesigner; class DialogDesigner;
class ReportDesignWidget : public QWidget class ReportDesignWidget : public QWidget
@ -100,15 +101,17 @@ public:
bool useGrid(){ return m_useGrid;} bool useGrid(){ return m_useGrid;}
bool useMagnet() const; bool useMagnet() const;
void setUseMagnet(bool useMagnet); void setUseMagnet(bool useMagnet);
DialogDesigner *dialogDesigner() const;
QWidget* toolWindow(ToolWindowType windowType);
EditorTabType activeTabType(); EditorTabType activeTabType();
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void initDialogDesignerToolBar(QToolBar* toolBar); void initDialogDesignerToolBar(QToolBar* toolBar);
void updateDialogs(); void updateDialogs();
DialogDesignerManager *dialogDesignerManager() const;
QString activeDialogName();
DialogDesigner* activeDialogPage();
QWidget* toolWindow(ToolWindowType windowType);
#endif #endif
public slots: public slots:
void saveToFile(const QString&); bool saveToFile(const QString&);
bool save(); bool save();
bool loadFromFile(const QString&); bool loadFromFile(const QString&);
void deleteSelectedItems(); void deleteSelectedItems();
@ -140,6 +143,10 @@ public slots:
void addPage(); void addPage();
void deleteCurrentPage(); void deleteCurrentPage();
void slotPagesLoadFinished(); void slotPagesLoadFinished();
void slotDialogDeleted(QString dialogName);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void addNewDialog();
#endif
private slots: private slots:
void slotItemSelected(LimeReport::BaseDesignIntf *item); void slotItemSelected(LimeReport::BaseDesignIntf *item);
void slotSelectionChanged(); void slotSelectionChanged();
@ -147,7 +154,8 @@ private slots:
void slotSceneRectChanged(QRectF); void slotSceneRectChanged(QRectF);
void slotCurrentTabChanged(int index); void slotCurrentTabChanged(int index);
#ifdef HAVE_QTDESIGNER_INTEGRATION #ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(); void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName);
#endif #endif
signals: signals:
void insertModeStarted(); void insertModeStarted();
@ -169,13 +177,18 @@ signals:
void pageDeleted(); void pageDeleted();
protected: protected:
void createTabs(); void createTabs();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
private: private:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
private: private:
ReportEnginePrivate* m_report; ReportEnginePrivate* m_report;
QGraphicsView *m_view; QGraphicsView *m_view;
QTextEdit* m_scriptEditor; QTextEdit* m_scriptEditor;
DialogDesigner* m_dialogDesigner; #ifdef HAVE_QTDESIGNER_INTEGRATION
DialogDesignerManager* m_dialogDesignerManager;
#endif
QMainWindow *m_mainWindow; QMainWindow *m_mainWindow;
QTabWidget* m_tabWidget; QTabWidget* m_tabWidget;
GraphicsViewZoomer* m_zoomer; GraphicsViewZoomer* m_zoomer;
@ -184,6 +197,7 @@ private:
int m_horizontalGridStep; int m_horizontalGridStep;
bool m_useGrid; bool m_useGrid;
bool m_useMagnet; bool m_useMagnet;
bool m_dialogChanged;
}; };
} }

View File

@ -211,11 +211,6 @@ void ReportDesignWindow::createActions()
m_testAction->setIcon(QIcon(":/report/images/pin")); m_testAction->setIcon(QIcon(":/report/images/pin"));
connect(m_testAction,SIGNAL(triggered()),this,SLOT(slotTest())); 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 = new QAction(tr("Edit layouts mode"),this);
m_editLayoutMode->setIcon(QIcon(":/report/images/editlayout")); m_editLayoutMode->setIcon(QIcon(":/report/images/editlayout"));
m_editLayoutMode->setCheckable(true); m_editLayoutMode->setCheckable(true);
@ -231,15 +226,22 @@ void ReportDesignWindow::createActions()
m_hideLeftPanel = new QAction(tr("Hide left panel"),this); m_hideLeftPanel = new QAction(tr("Hide left panel"),this);
m_hideLeftPanel->setCheckable(true); m_hideLeftPanel->setCheckable(true);
// m_hideLeftPanel->setChecked(true);
m_hideLeftPanel->setIcon(QIcon(":/report/images/hideLeftPanel")); m_hideLeftPanel->setIcon(QIcon(":/report/images/hideLeftPanel"));
connect(m_hideLeftPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideLeftPanel(bool))); connect(m_hideLeftPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideLeftPanel(bool)));
m_hideRightPanel = new QAction(tr("Hide right panel"),this); m_hideRightPanel = new QAction(tr("Hide right panel"),this);
m_hideRightPanel->setCheckable(true); m_hideRightPanel->setCheckable(true);
// m_hideRightPanel->setChecked(true);
m_hideRightPanel->setIcon(QIcon(":/report/images/hideRightPanel")); m_hideRightPanel->setIcon(QIcon(":/report/images/hideRightPanel"));
connect(m_hideRightPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideRightPanel(bool))); 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() void ReportDesignWindow::createReportToolBar()
@ -252,7 +254,6 @@ void ReportDesignWindow::createReportToolBar()
m_reportToolBar->setObjectName("reportTools"); m_reportToolBar->setObjectName("reportTools");
createItemsActions(); createItemsActions();
m_reportToolBar->addSeparator(); m_reportToolBar->addSeparator();
//m_reportToolBar->addAction(m_editLayoutMode);
m_reportToolBar->addAction(m_addHLayout); m_reportToolBar->addAction(m_addHLayout);
m_reportToolBar->addSeparator(); m_reportToolBar->addSeparator();
m_reportToolBar->addAction(m_deleteItemAction); m_reportToolBar->addAction(m_deleteItemAction);
@ -286,6 +287,9 @@ void ReportDesignWindow::createToolBars()
m_mainToolBar->addAction(m_newPageAction); m_mainToolBar->addAction(m_newPageAction);
m_mainToolBar->addAction(m_deletePageAction); m_mainToolBar->addAction(m_deletePageAction);
#ifdef HAVE_QTDESIGNER_INTEGRATION
m_mainToolBar->addAction(m_addNewDialogAction);
#endif
m_mainToolBar->addSeparator(); m_mainToolBar->addSeparator();
m_mainToolBar->addAction(m_copyAction); m_mainToolBar->addAction(m_copyAction);
@ -582,6 +586,11 @@ void ReportDesignWindow::createDialogDesignerToolBar()
{ {
m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools")); m_dialogDesignerToolBar = addToolBar(tr("Dialog Designer Tools"));
m_dialogDesignerToolBar->setObjectName("DialogDesignerTools"); 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_reportDesignWidget->initDialogDesignerToolBar(m_dialogDesignerToolBar);
m_dialogTools << m_dialogDesignerToolBar; m_dialogTools << m_dialogDesignerToolBar;
} }
@ -1257,6 +1266,7 @@ void ReportDesignWindow::slotActivePageChanged()
switch (m_editorTabType) { switch (m_editorTabType) {
case ReportDesignWidget::Dialog: case ReportDesignWidget::Dialog:
m_dialogEditorsState = saveState(); m_dialogEditorsState = saveState();
m_scriptBrowser->updateDialogsTree();
break; break;
default: default:
m_pageEditorsState = saveState(); m_pageEditorsState = saveState();
@ -1388,6 +1398,20 @@ void ReportDesignWindow::slotPageDeleted()
m_deletePageAction->setEnabled(m_reportDesignWidget->report()->pageCount()>1); 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) void ReportDesignWindow::closeEvent(QCloseEvent * event)
{ {
if (checkNeedToSave()){ if (checkNeedToSave()){

View File

@ -119,6 +119,10 @@ private slots:
void slotLoadRecentFile(const QString fileName); void slotLoadRecentFile(const QString fileName);
void slotPageAdded(PageDesignIntf* ); void slotPageAdded(PageDesignIntf* );
void slotPageDeleted(); void slotPageDeleted();
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDeleteDialog();
void slotAddNewDialog();
#endif
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void resizeEvent(QResizeEvent *); void resizeEvent(QResizeEvent *);
@ -217,6 +221,10 @@ private:
QAction* m_addHLayout; QAction* m_addHLayout;
QAction* m_hideLeftPanel; QAction* m_hideLeftPanel;
QAction* m_hideRightPanel; QAction* m_hideRightPanel;
#ifdef HAVE_QTDESIGNER_INTEGRATION
QAction* m_deleteDialogAction;
QAction* m_addNewDialogAction;
#endif
QMenu* m_recentFilesMenu; QMenu* m_recentFilesMenu;
QSignalMapper* m_bandsAddSignalsMap; QSignalMapper* m_bandsAddSignalsMap;

View File

@ -1065,6 +1065,7 @@ void DialogDescriber::setDescription(const QByteArray &description)
void ScriptEngineContext::addDialog(const QString& name, const QByteArray& description) void ScriptEngineContext::addDialog(const QString& name, const QByteArray& description)
{ {
m_dialogs.push_back(DialogDescriber::create(name,description)); m_dialogs.push_back(DialogDescriber::create(name,description));
emit dialogAdded(name);
} }
bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& description) bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& description)
@ -1072,6 +1073,37 @@ bool ScriptEngineContext::changeDialog(const QString& name, const QByteArray& de
foreach( DialogDescriber::Ptr describer, m_dialogs){ foreach( DialogDescriber::Ptr describer, m_dialogs){
if (describer->name().compare(name) == 0){ if (describer->name().compare(name) == 0){
describer->setDescription(description); describer->setDescription(description);
{
QList<DialogPtr>::Iterator it = m_createdDialogs.begin();
while(it!=m_createdDialogs.end()){
if ((*it)->objectName()==name){
it = m_createdDialogs.erase(it);
} else {
++it;
}
}
}
return true;
}
}
return false;
}
bool ScriptEngineContext::changeDialogName(const QString& oldName, const QString& newName)
{
foreach( DialogDescriber::Ptr describer, m_dialogs){
if (describer->name().compare(oldName) == 0){
describer->setName(newName);
{
QList<DialogPtr>::Iterator it = m_createdDialogs.begin();
while(it!=m_createdDialogs.end()){
if ((*it)->objectName()==oldName){
it = m_createdDialogs.erase(it);
} else {
++it;
}
}
}
return true; return true;
} }
} }
@ -1106,6 +1138,7 @@ void ScriptEngineContext::deleteDialog(const QString& dialogName)
while(it!=m_dialogs.end()){ while(it!=m_dialogs.end()){
if ((*it)->name()==dialogName){ if ((*it)->name()==dialogName){
it = m_dialogs.erase(it); it = m_dialogs.erase(it);
emit dialogDeleted(dialogName);
} else { } else {
++it; ++it;
} }
@ -1188,6 +1221,10 @@ QDialog* ScriptEngineContext::createDialog(DialogDescriber* cont)
buffer.open(QIODevice::ReadOnly); buffer.open(QIODevice::ReadOnly);
QDialog* dialog = dynamic_cast<QDialog*>(loader.load(&buffer)); QDialog* dialog = dynamic_cast<QDialog*>(loader.load(&buffer));
m_createdDialogs.push_back(QSharedPointer<QDialog>(dialog)); m_createdDialogs.push_back(QSharedPointer<QDialog>(dialog));
if (cont->name().compare(dialog->objectName())){
cont->setName(dialog->objectName());
emit dialogNameChanged(dialog->objectName());
}
return dialog; return dialog;
} }
@ -1225,6 +1262,18 @@ QDialog* ScriptEngineContext::getDialog(const QString& dialogName)
} }
return 0; 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 #endif
QString ScriptEngineContext::initScript() const QString ScriptEngineContext::initScript() const
{ {

View File

@ -146,15 +146,21 @@ public:
#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 changeDialog(const QString& name, const QByteArray &description);
bool changeDialogName(const QString& oldName, const QString& newName);
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;}
void deleteDialog(const QString& dialogName); void deleteDialog(const QString& dialogName);
QDialog *getDialog(const QString &dialogName); QDialog *getDialog(const QString &dialogName);
QString getNewDialogName();
#endif #endif
void clear(); void clear();
QString initScript() const; 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: protected:
QObject* createElement(const QString& collectionName,const QString& elementType); QObject* createElement(const QString& collectionName,const QString& elementType);
int elementsCount(const QString& collectionName); int elementsCount(const QString& collectionName);

View File

@ -175,5 +175,7 @@
<file alias="/images/addBand">images/addBand2.png</file> <file alias="/images/addBand">images/addBand2.png</file>
<file alias="/images/editMode">images/edit_control_4_24.png</file> <file alias="/images/editMode">images/edit_control_4_24.png</file>
<file alias="/images/logo32">images/logo_32x32_1.png</file> <file alias="/images/logo32">images/logo_32x32_1.png</file>
<file alias="/images/addDialog">images/addDialog.png</file>
<file alias="/images/deleteDialog">images/deleteDialog.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -59,6 +59,7 @@ void ScriptBrowser::setReportEditor(ReportDesignWidget* report)
m_report=report; m_report=report;
connect(m_report,SIGNAL(cleared()),this,SLOT(slotClear())); connect(m_report,SIGNAL(cleared()),this,SLOT(slotClear()));
connect(m_report,SIGNAL(loaded()),this,SLOT(slotUpdate())); connect(m_report,SIGNAL(loaded()),this,SLOT(slotUpdate()));
connect(m_report->scriptContext(), SIGNAL(dialogAdded(QString)), this, SLOT(slotDialogAdded(QString)));
updateFunctionTree(); updateFunctionTree();
} }
@ -138,6 +139,11 @@ void ScriptBrowser::slotUpdate()
updateFunctionTree(); updateFunctionTree();
} }
void ScriptBrowser::slotDialogAdded(QString)
{
updateDialogsTree();
}
#ifdef HAVE_UI_LOADER #ifdef HAVE_UI_LOADER
void ScriptBrowser::on_tbAddDialog_clicked() void ScriptBrowser::on_tbAddDialog_clicked()
{ {
@ -157,7 +163,7 @@ void ScriptBrowser::on_tbAddDialog_clicked()
if (!m_report->scriptContext()->containsDialog(dialog->objectName())){ if (!m_report->scriptContext()->containsDialog(dialog->objectName())){
file.seek(0); file.seek(0);
m_report->scriptContext()->addDialog(dialog->objectName(),file.readAll()); m_report->scriptContext()->addDialog(dialog->objectName(),file.readAll());
updateDialogsTree(); //updateDialogsTree();
} else { } else {
QMessageBox::critical(this,tr("Error"),tr("Dialog with name: %1 already exists").arg(dialog->objectName())); QMessageBox::critical(this,tr("Error"),tr("Dialog with name: %1 already exists").arg(dialog->objectName()));
} }

View File

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