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 Internal {
|
||||
|
||||
BarDescriptorEditor::BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget)
|
||||
BarDescriptorEditor::BarDescriptorEditor()
|
||||
{
|
||||
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this);
|
||||
setWidget(editorWidget);
|
||||
|
||||
m_file = new BarDescriptorDocument(editorWidget);
|
||||
connect(editorWidget, SIGNAL(changed()), m_file, SIGNAL(changed()));
|
||||
|
||||
m_toolBar = new QToolBar(editorWidget);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
Source
|
||||
};
|
||||
|
||||
explicit BarDescriptorEditor(BarDescriptorEditorWidget *editorWidget);
|
||||
BarDescriptorEditor();
|
||||
|
||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
Core::IDocument *document();
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "bardescriptoreditorfactory.h"
|
||||
|
||||
#include "qnxconstants.h"
|
||||
#include "bardescriptoreditor.h"
|
||||
#include "bardescriptoreditorwidget.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -67,6 +68,6 @@ BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent)
|
||||
|
||||
Core::IEditor *BarDescriptorEditorFactory::createEditor()
|
||||
{
|
||||
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget();
|
||||
return editorWidget->editor();
|
||||
BarDescriptorEditor *editor = new BarDescriptorEditor();
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
BarDescriptorEditorWidget::BarDescriptorEditorWidget(QWidget *parent)
|
||||
BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent)
|
||||
: QStackedWidget(parent)
|
||||
, m_editor(0)
|
||||
, m_editor(editor)
|
||||
, m_dirty(false)
|
||||
{
|
||||
Core::IContext *myContext = new Core::IContext(this);
|
||||
@@ -170,11 +170,6 @@ void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *pan
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -269,8 +264,3 @@ void BarDescriptorEditorWidget::setDirty(bool dirty)
|
||||
m_dirty = dirty;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
BarDescriptorEditor *BarDescriptorEditorWidget::createEditor()
|
||||
{
|
||||
return new BarDescriptorEditor(this);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class BarDescriptorEditorWidget : public QStackedWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BarDescriptorEditorWidget(QWidget *parent = 0);
|
||||
explicit BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent = 0);
|
||||
|
||||
Core::IEditor *editor() const;
|
||||
|
||||
@@ -96,15 +96,13 @@ signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
BarDescriptorEditor *createEditor();
|
||||
|
||||
void initGeneralPage();
|
||||
void initApplicationPage();
|
||||
void initAssetsPage();
|
||||
void initSourcePage();
|
||||
void initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget);
|
||||
|
||||
mutable Core::IEditor *m_editor;
|
||||
Core::IEditor *m_editor;
|
||||
|
||||
bool m_dirty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user