forked from qt-creator/qt-creator
BarDescriptorEditor: Create widget from editor
Not the other way round. Results in less, and less convoluted code. Change-Id: I58a8d1e7785c0d712ff518d38425fc5646a262dd Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -54,11 +54,12 @@ using namespace ProjectExplorer;
|
|||||||
namespace Qnx {
|
namespace Qnx {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
BarDescriptorEditor::BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget)
|
BarDescriptorEditor::BarDescriptorEditor()
|
||||||
{
|
{
|
||||||
|
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this);
|
||||||
setWidget(editorWidget);
|
setWidget(editorWidget);
|
||||||
|
|
||||||
m_file = new BarDescriptorDocument(editorWidget);
|
m_file = new BarDescriptorDocument(editorWidget);
|
||||||
|
connect(editorWidget, SIGNAL(changed()), m_file, SIGNAL(changed()));
|
||||||
|
|
||||||
m_toolBar = new QToolBar(editorWidget);
|
m_toolBar = new QToolBar(editorWidget);
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
Source
|
Source
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget);
|
BarDescriptorEditor();
|
||||||
|
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
Core::IDocument *document();
|
Core::IDocument *document();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "bardescriptoreditorfactory.h"
|
#include "bardescriptoreditorfactory.h"
|
||||||
|
|
||||||
#include "qnxconstants.h"
|
#include "qnxconstants.h"
|
||||||
|
#include "bardescriptoreditor.h"
|
||||||
#include "bardescriptoreditorwidget.h"
|
#include "bardescriptoreditorwidget.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -67,6 +68,6 @@ BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent)
|
|||||||
|
|
||||||
Core::IEditor *BarDescriptorEditorFactory::createEditor()
|
Core::IEditor *BarDescriptorEditorFactory::createEditor()
|
||||||
{
|
{
|
||||||
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget();
|
BarDescriptorEditor *editor = new BarDescriptorEditor();
|
||||||
return editorWidget->editor();
|
return editor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,9 @@
|
|||||||
using namespace Qnx;
|
using namespace Qnx;
|
||||||
using namespace Qnx::Internal;
|
using namespace Qnx::Internal;
|
||||||
|
|
||||||
BarDescriptorEditorWidget::BarDescriptorEditorWidget(QWidget *parent)
|
BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent)
|
||||||
: QStackedWidget(parent)
|
: QStackedWidget(parent)
|
||||||
, m_editor(0)
|
, m_editor(editor)
|
||||||
, m_dirty(false)
|
, m_dirty(false)
|
||||||
{
|
{
|
||||||
Core::IContext *myContext = new Core::IContext(this);
|
Core::IContext *myContext = new Core::IContext(this);
|
||||||
@@ -170,11 +170,6 @@ void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *pan
|
|||||||
|
|
||||||
Core::IEditor *BarDescriptorEditorWidget::editor() const
|
Core::IEditor *BarDescriptorEditorWidget::editor() const
|
||||||
{
|
{
|
||||||
if (!m_editor) {
|
|
||||||
m_editor = const_cast<BarDescriptorEditorWidget *>(this)->createEditor();
|
|
||||||
connect(this, SIGNAL(changed()), m_editor->document(), SIGNAL(changed()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_editor;
|
return m_editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,8 +264,3 @@ void BarDescriptorEditorWidget::setDirty(bool dirty)
|
|||||||
m_dirty = dirty;
|
m_dirty = dirty;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
BarDescriptorEditor *BarDescriptorEditorWidget::createEditor()
|
|
||||||
{
|
|
||||||
return new BarDescriptorEditor(this);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class BarDescriptorEditorWidget : public QStackedWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BarDescriptorEditorWidget(QWidget *parent = 0);
|
explicit BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent = 0);
|
||||||
|
|
||||||
Core::IEditor *editor() const;
|
Core::IEditor *editor() const;
|
||||||
|
|
||||||
@@ -96,15 +96,13 @@ signals:
|
|||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BarDescriptorEditor *createEditor();
|
|
||||||
|
|
||||||
void initGeneralPage();
|
void initGeneralPage();
|
||||||
void initApplicationPage();
|
void initApplicationPage();
|
||||||
void initAssetsPage();
|
void initAssetsPage();
|
||||||
void initSourcePage();
|
void initSourcePage();
|
||||||
void initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget);
|
void initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget);
|
||||||
|
|
||||||
mutable Core::IEditor *m_editor;
|
Core::IEditor *m_editor;
|
||||||
|
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user