forked from qt-creator/qt-creator
QmlDesigner.documentController: adding instance()
Also exposing changeCurrentModelTo() as public API. Change-Id: I7c9ed3679ef5859b1349f1d1fe3088e78bccc7ad Reviewed-on: http://codereview.qt.nokia.com/787 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -45,6 +45,11 @@ ComponentAction::ComponentAction(ComponentView *componentView)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComponentAction::setCurrentIndex(int i)
|
||||||
|
{
|
||||||
|
emit currentIndexChanged(i);
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *ComponentAction::createWidget(QWidget *parent)
|
QWidget *ComponentAction::createWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
QComboBox *comboBox = new QComboBox(parent);
|
QComboBox *comboBox = new QComboBox(parent);
|
||||||
@@ -52,6 +57,7 @@ QWidget *ComponentAction::createWidget(QWidget *parent)
|
|||||||
comboBox->setToolTip(tr("Edit sub components defined in this file"));
|
comboBox->setToolTip(tr("Edit sub components defined in this file"));
|
||||||
comboBox->setModel(m_componentView->standardItemModel());
|
comboBox->setModel(m_componentView->standardItemModel());
|
||||||
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitCurrentComponentChanged(int)));
|
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitCurrentComponentChanged(int)));
|
||||||
|
connect(this, SIGNAL(currentIndexChanged(int)), comboBox, SLOT(setCurrentIndex(int)));
|
||||||
|
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ ModelNode ComponentView::modelNode(int index) const
|
|||||||
return ModelNode();
|
return ModelNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComponentView::setComponentNode(const ModelNode &node)
|
||||||
|
{
|
||||||
|
m_componentAction->setCurrentIndex(indexForNode(node));
|
||||||
|
}
|
||||||
|
|
||||||
void ComponentView::appendWholeDocumentAsComponent()
|
void ComponentView::appendWholeDocumentAsComponent()
|
||||||
{
|
{
|
||||||
QStandardItem *item = new QStandardItem(tr("whole document"));
|
QStandardItem *item = new QStandardItem(tr("whole document"));
|
||||||
@@ -88,6 +93,16 @@ void ComponentView::removeSingleNodeFromList(const ModelNode &node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ComponentView::indexForNode(const ModelNode &node)
|
||||||
|
{
|
||||||
|
for (int row = 0; row < m_standardItemModel->rowCount(); row++) {
|
||||||
|
if (m_standardItemModel->item(row)->data(ModelNodeRole).value<ModelNode>() == node)
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void ComponentView::modelAttached(Model *model)
|
void ComponentView::modelAttached(Model *model)
|
||||||
{
|
{
|
||||||
if (AbstractView::model() == model)
|
if (AbstractView::model() == model)
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ public:
|
|||||||
int qt_versionId;
|
int qt_versionId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DesignDocumentController *DesignDocumentController::m_this = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class QmlDesigner::DesignDocumentController
|
\class QmlDesigner::DesignDocumentController
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@ DesignDocumentController::DesignDocumentController(QObject *parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_d(new DesignDocumentControllerPrivate)
|
m_d(new DesignDocumentControllerPrivate)
|
||||||
{
|
{
|
||||||
|
m_this = this;
|
||||||
m_d->documentLoaded = false;
|
m_d->documentLoaded = false;
|
||||||
m_d->syncBlocked = false;
|
m_d->syncBlocked = false;
|
||||||
|
|
||||||
@@ -143,6 +146,7 @@ DesignDocumentController::DesignDocumentController(QObject *parent) :
|
|||||||
|
|
||||||
DesignDocumentController::~DesignDocumentController()
|
DesignDocumentController::~DesignDocumentController()
|
||||||
{
|
{
|
||||||
|
m_this = 0;
|
||||||
delete m_d->model.data();
|
delete m_d->model.data();
|
||||||
delete m_d->subComponentModel.data();
|
delete m_d->subComponentModel.data();
|
||||||
|
|
||||||
@@ -296,6 +300,11 @@ void DesignDocumentController::setComponentView(ComponentView *componentView)
|
|||||||
connect(m_d->componentView->action(), SIGNAL(currentComponentChanged(ModelNode)), SLOT(changeCurrentModelTo(ModelNode)));
|
connect(m_d->componentView->action(), SIGNAL(currentComponentChanged(ModelNode)), SLOT(changeCurrentModelTo(ModelNode)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesignDocumentController *DesignDocumentController::instance()
|
||||||
|
{
|
||||||
|
return m_this;
|
||||||
|
}
|
||||||
|
|
||||||
QString DesignDocumentController::displayName() const
|
QString DesignDocumentController::displayName() const
|
||||||
{
|
{
|
||||||
if (fileName().isEmpty())
|
if (fileName().isEmpty())
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ public:
|
|||||||
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
|
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
|
||||||
void setComponentView(ComponentView *componentView);
|
void setComponentView(ComponentView *componentView);
|
||||||
|
|
||||||
|
static DesignDocumentController *instance();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayNameChanged(const QString &newFileName);
|
void displayNameChanged(const QString &newFileName);
|
||||||
void dirtyStateChanged(bool newState);
|
void dirtyStateChanged(bool newState);
|
||||||
@@ -123,6 +125,7 @@ public slots:
|
|||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
void activeQtVersionChanged();
|
void activeQtVersionChanged();
|
||||||
|
void changeCurrentModelTo(const ModelNode &node);
|
||||||
|
|
||||||
#ifdef ENABLE_TEXT_VIEW
|
#ifdef ENABLE_TEXT_VIEW
|
||||||
void showText();
|
void showText();
|
||||||
@@ -131,7 +134,6 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void doRealSaveAs(const QString &fileName);
|
void doRealSaveAs(const QString &fileName);
|
||||||
void changeCurrentModelTo(const ModelNode &node);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void detachNodeInstanceView();
|
void detachNodeInstanceView();
|
||||||
@@ -142,6 +144,8 @@ private:
|
|||||||
QString pathToQt() const;
|
QString pathToQt() const;
|
||||||
|
|
||||||
class DesignDocumentControllerPrivate *m_d;
|
class DesignDocumentControllerPrivate *m_d;
|
||||||
|
|
||||||
|
static DesignDocumentController* m_this;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
|||||||
Reference in New Issue
Block a user