Commit eac3beb4 authored by Tim Jenssen's avatar Tim Jenssen Committed by Thomas Hartmann
Browse files

QmlDesigner: move model roles to header



Change-Id: Ib84c4049ba688159449dd1a88b5d2a046b5ff337
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent 2d20b695
......@@ -43,14 +43,6 @@
#include <QTimer>
namespace {
enum ColumnRoles {
TargetModelNodeRow = 0,
TargetPropertyNameRow = 1,
SourceModelNodeRow = 2,
SourcePropertyNameRow = 3
};
bool compareBindingProperties(const QmlDesigner::BindingProperty &bindingProperty01, const QmlDesigner::BindingProperty &bindingProperty02)
{
if (bindingProperty01.parentModelNode() != bindingProperty02.parentModelNode())
......@@ -524,7 +516,7 @@ QWidget *BindingDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
BindingProperty bindingProperty = model->bindingPropertyForRow(index.row());
switch (index.column()) {
case TargetModelNodeRow: {
case BindingModel::TargetModelNodeRow: {
return 0; //no editor
foreach (const ModelNode &modelNode, model->connectionView()->allModelNodes()) {
if (!modelNode.id().isEmpty()) {
......@@ -532,10 +524,10 @@ QWidget *BindingDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
}
}
} break;
case TargetPropertyNameRow: {
case BindingModel::TargetPropertyNameRow: {
bindingComboBox->addItems(model->possibleTargetProperties(bindingProperty));
} break;
case SourceModelNodeRow: {
case BindingModel::SourceModelNodeRow: {
foreach (const ModelNode &modelNode, model->connectionView()->allModelNodes()) {
if (!modelNode.id().isEmpty()) {
bindingComboBox->addItem(modelNode.id());
......@@ -544,7 +536,7 @@ QWidget *BindingDelegate::createEditor(QWidget *parent, const QStyleOptionViewIt
if (!bindingProperty.parentModelNode().isRootNode())
bindingComboBox->addItem(QLatin1String("parent"));
} break;
case SourcePropertyNameRow: {
case BindingModel::SourcePropertyNameRow: {
bindingComboBox->addItems(model->possibleSourceProperties(bindingProperty));
} break;
default: qWarning() << "BindingDelegate::createEditor column" << index.column();
......
......@@ -46,6 +46,12 @@ class BindingModel : public QStandardItemModel
Q_OBJECT
public:
enum ColumnRoles {
TargetModelNodeRow = 0,
TargetPropertyNameRow = 1,
SourceModelNodeRow = 2,
SourcePropertyNameRow = 3
};
BindingModel(ConnectionView *parent = 0);
void bindingChanged(const BindingProperty &bindingProperty);
void bindingRemoved(const BindingProperty &bindingProperty);
......
......@@ -73,12 +73,6 @@ bool isConnection(const QmlDesigner::ModelNode &modelNode)
}
enum ColumnRoles {
TargetModelNodeRow = 0,
TargetPropertyNameRow = 1,
SourceRow = 2
};
} //namespace
namespace QmlDesigner {
......@@ -436,17 +430,17 @@ QWidget *ConnectionDelegate::createEditor(QWidget *parent, const QStyleOptionVie
}
switch (index.column()) {
case TargetModelNodeRow: {
case ConnectionModel::TargetModelNodeRow: {
foreach (const ModelNode &modelNode, connectionModel->connectionView()->allModelNodes()) {
if (!modelNode.id().isEmpty()) {
connectionComboBox->addItem(modelNode.id());
}
}
} break;
case TargetPropertyNameRow: {
case ConnectionModel::TargetPropertyNameRow: {
connectionComboBox->addItems(prependOnForSignalHandler(connectionModel->getSignalsForRow(index.row())));
} break;
case SourceRow: {
case ConnectionModel::SourceRow: {
ModelNode rootModelNode = connectionModel->connectionView()->rootModelNode();
if (QmlItemNode::isValidQmlItemNode(rootModelNode) && !rootModelNode.id().isEmpty()) {
......
......@@ -47,8 +47,12 @@ class ConnectionView;
class ConnectionModel : public QStandardItemModel
{
Q_OBJECT
public:
enum ColumnRoles {
TargetModelNodeRow = 0,
TargetPropertyNameRow = 1,
SourceRow = 2
};
ConnectionModel(ConnectionView *parent = 0);
void resetModel();
SignalHandlerProperty signalHandlerPropertyForRow(int rowNumber) const;
......
......@@ -45,13 +45,6 @@
namespace {
enum ColumnRoles {
TargetModelNodeRow = 0,
PropertyNameRow = 1,
PropertyTypeRow = 2,
PropertyValueRow = 3
};
bool compareBindingProperties(const QmlDesigner::BindingProperty &bindingProperty01, const QmlDesigner::BindingProperty &bindingProperty02)
{
if (bindingProperty01.parentModelNode() != bindingProperty02.parentModelNode())
......@@ -766,13 +759,13 @@ QWidget *DynamicPropertiesDelegate::createEditor(QWidget *parent, const QStyleOp
BindingProperty bindingProperty = model->bindingPropertyForRow(index.row());
switch (index.column()) {
case TargetModelNodeRow: {
case DynamicPropertiesModel::TargetModelNodeRow: {
return 0; //no editor
} break;
case PropertyNameRow: {
case DynamicPropertiesModel::PropertyNameRow: {
return QStyledItemDelegate::createEditor(parent, option, index);
} break;
case PropertyTypeRow: {
case DynamicPropertiesModel::PropertyTypeRow: {
DynamicPropertiesComboBox *dynamicPropertiesComboBox = new DynamicPropertiesComboBox(parent);
connect(dynamicPropertiesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, [=]() {
......@@ -795,7 +788,7 @@ QWidget *DynamicPropertiesDelegate::createEditor(QWidget *parent, const QStyleOp
dynamicPropertiesComboBox->addItem(QLatin1String("variant"));
return dynamicPropertiesComboBox;
} break;
case PropertyValueRow: {
case DynamicPropertiesModel::PropertyValueRow: {
return QStyledItemDelegate::createEditor(parent, option, index);
} break;
default: qWarning() << "BindingDelegate::createEditor column" << index.column();
......
......@@ -49,6 +49,12 @@ class DynamicPropertiesModel : public QStandardItemModel
Q_OBJECT
public:
enum ColumnRoles {
TargetModelNodeRow = 0,
PropertyNameRow = 1,
PropertyTypeRow = 2,
PropertyValueRow = 3
};
DynamicPropertiesModel(ConnectionView *parent = 0);
void bindingPropertyChanged(const BindingProperty &bindingProperty);
void variantPropertyChanged(const VariantProperty &variantProperty);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment