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

QmlDesigner: refactor connection editor models



  - no behavior change
  - use modern Qt connect
  - moved reset method to the same location in all models

Change-Id: I5686e20a9b072e756f9bc6cc06df1377f1ca2c03
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@theqtcompany.com>
parent ad23e7a9
......@@ -41,13 +41,27 @@ namespace QmlDesigner {
namespace Internal {
BindingModel::BindingModel(ConnectionView *parent) :
QStandardItemModel(parent),
m_connectionView(parent),
m_lock(false),
m_handleDataChanged(false)
BindingModel::BindingModel(ConnectionView *parent)
: QStandardItemModel(parent)
, m_connectionView(parent)
{
connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
connect(this, &QStandardItemModel::dataChanged, this, &BindingModel::handleDataChanged);
}
void BindingModel::resetModel()
{
beginResetModel();
clear();
setHorizontalHeaderLabels(QStringList()
<< tr("Item")
<< tr("Property")
<< tr("Source Item")
<< tr("Source Property"));
foreach (const ModelNode modelNode, m_selectedModelNodes)
addModelNode(modelNode);
endResetModel();
}
void BindingModel::bindingChanged(const BindingProperty &bindingProperty)
......@@ -225,27 +239,6 @@ void BindingModel::addBindingForCurrentNode()
}
}
void BindingModel::resetModel()
{
beginResetModel();
clear();
QStringList labels;
labels << tr("Item");
labels <<tr("Property");
labels <<tr("Source Item");
labels <<tr("Source Property");
setHorizontalHeaderLabels(labels);
foreach (const ModelNode modelNode, m_selectedModelNodes) {
addModelNode(modelNode);
}
endResetModel();
}
void BindingModel::addBindingProperty(const BindingProperty &property)
{
QStandardItem *idItem;
......
......@@ -81,8 +81,8 @@ private slots:
private:
QList<ModelNode> m_selectedModelNodes;
ConnectionView *m_connectionView;
bool m_lock;
bool m_handleDataChanged;
bool m_lock = false;
bool m_handleDataChanged = false;
QString m_exceptionError;
};
......
......@@ -64,31 +64,27 @@ namespace QmlDesigner {
namespace Internal {
ConnectionModel::ConnectionModel(ConnectionView *parent) : QStandardItemModel(parent), m_connectionView(parent), m_lock(false)
ConnectionModel::ConnectionModel(ConnectionView *parent)
: QStandardItemModel(parent)
, m_connectionView(parent)
{
connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
connect(this, &QStandardItemModel::dataChanged, this, &ConnectionModel::handleDataChanged);
}
void ConnectionModel::resetModel()
{
beginResetModel();
clear();
QStringList labels;
labels << tr("Target");
labels << tr("Signal Handler");
labels <<tr("Action");
setHorizontalHeaderLabels(labels);
setHorizontalHeaderLabels(QStringList()
<< tr("Target")
<< tr("Signal Handler")
<< tr("Action"));
if (connectionView()->isAttached()) {
foreach (const ModelNode modelNode, connectionView()->allModelNodes()) {
foreach (const ModelNode modelNode, connectionView()->allModelNodes())
addModelNode(modelNode);
}
}
const int columnWidthTarget = connectionView()->connectionTableView()->columnWidth(0);
connectionView()->connectionTableView()->setColumnWidth(0, columnWidthTarget - 80);
......@@ -163,6 +159,7 @@ void ConnectionModel::removeModelNode(const ModelNode &modelNode)
void ConnectionModel::removeConnection(const ModelNode & /*modelNode*/)
{
Q_ASSERT_X(false, "not implemented", Q_FUNC_INFO);
}
void ConnectionModel::updateSource(int row)
......@@ -235,8 +232,6 @@ void ConnectionModel::updateTargetNode(int rowNumber)
} else {
qWarning() << "BindingModel::updatePropertyName invalid target id";
}
}
void ConnectionModel::updateCustomData(QStandardItem *item, const SignalHandlerProperty &signalHandlerProperty)
......
......@@ -80,7 +80,7 @@ private slots:
private:
ConnectionView *m_connectionView;
bool m_lock;
bool m_lock = false;
QString m_exceptionError;
};
......
......@@ -117,13 +117,27 @@ namespace QmlDesigner {
namespace Internal {
DynamicPropertiesModel::DynamicPropertiesModel(ConnectionView *parent) :
QStandardItemModel(parent),
m_connectionView(parent),
m_lock(false),
m_handleDataChanged(false)
DynamicPropertiesModel::DynamicPropertiesModel(ConnectionView *parent)
: QStandardItemModel(parent)
, m_connectionView(parent)
{
connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
connect(this, &QStandardItemModel::dataChanged, this, &DynamicPropertiesModel::handleDataChanged);
}
void DynamicPropertiesModel::resetModel()
{
beginResetModel();
clear();
setHorizontalHeaderLabels(QStringList()
<< tr("Item")
<< tr("Property")
<< tr("Property Type")
<< tr("Property Value"));
foreach (const ModelNode modelNode, m_selectedModelNodes)
addModelNode(modelNode);
endResetModel();
}
void DynamicPropertiesModel::bindingPropertyChanged(const BindingProperty &bindingProperty)
......@@ -323,27 +337,6 @@ void DynamicPropertiesModel::deleteDynamicPropertyByRow(int rowNumber)
resetModel();
}
void DynamicPropertiesModel::resetModel()
{
beginResetModel();
clear();
QStringList labels;
labels << tr("Item");
labels <<tr("Property");
labels <<tr("Property Type");
labels <<tr("Property Value");
setHorizontalHeaderLabels(labels);
foreach (const ModelNode modelNode, m_selectedModelNodes) {
addModelNode(modelNode);
}
endResetModel();
}
void DynamicPropertiesModel::addProperty(const QVariant &propertyValue,
const QString &propertyType,
const AbstractProperty &abstractProperty)
......
......@@ -95,8 +95,8 @@ private slots:
private:
QList<ModelNode> m_selectedModelNodes;
ConnectionView *m_connectionView;
bool m_lock;
bool m_handleDataChanged;
bool m_lock = false;
bool m_handleDataChanged = false;
QString m_exceptionError;
};
......
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