git-svn-id: svn://db.shs.com.ru/libs@414 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -270,7 +270,7 @@ QByteArray BlockItem::save() const {
|
||||
pp[p->text()] = p->properties();
|
||||
}
|
||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, props) << cs.chunk(5, pp) << cs.chunk(6, size());
|
||||
cs << cs.chunk(10, data(2000)) << cs.chunk(11, data(2001)) << cs.chunk(0xFF, _blockitem_current_version_);
|
||||
cs << cs.chunk(10, data(2000)) << cs.chunk(11, data(2001)) << cs.chunk(12, prop_bindings) << cs.chunk(0xFF, _blockitem_current_version_);
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
@@ -297,6 +297,7 @@ void BlockItem::load(const QByteArray & data) {
|
||||
case 6: setSize(cs.getData<QSizeF>()); break;
|
||||
case 10: setData(2000, cs.getData<QVariant>()); break;
|
||||
case 11: setData(2001, cs.getData<QVariant>()); break;
|
||||
case 12: prop_bindings = cs.getData<QList<QPair<QString, QString> > >(); break;
|
||||
case 0xFF: cs.get(version); break;
|
||||
}
|
||||
}
|
||||
@@ -418,6 +419,86 @@ void BlockItem::arrangePins() {
|
||||
#undef _POS
|
||||
|
||||
|
||||
void BlockItem::removeBindings(const QString & bind_name) {
|
||||
for(int i=0; i<prop_bindings.size(); ++i) {
|
||||
if (prop_bindings[i].second == bind_name) {
|
||||
prop_bindings.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::removeBindingByProperty(const QString & prop_name) {
|
||||
for(int i=0; i<prop_bindings.size(); ++i) {
|
||||
if (prop_bindings[i].first == prop_name) {
|
||||
prop_bindings.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::addBinding(const QString & prop_name, const QString & bind_name) {
|
||||
QPair<QString, QString> pb(prop_name, bind_name);
|
||||
prop_bindings.removeAll(pb);
|
||||
prop_bindings << pb;
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::applyBinding(const QString & bind_name, const QVariant & bind_value) {
|
||||
for(int i=0; i<prop_bindings.size(); ++i) {
|
||||
if (prop_bindings[i].second == bind_name) {
|
||||
setPropertyValue(prop_bindings[i].first, bind_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::applyBindings(const PropertyStorage & bindings) {
|
||||
for(int i=0; i<prop_bindings.size(); ++i) {
|
||||
if (bindings.isPropertyExists(prop_bindings[i].second)) {
|
||||
setPropertyValue(prop_bindings[i].first, bindings.propertyValueByName(prop_bindings[i].second));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::setBindings(const QList<QPair<QString, QString> > & bindings) {
|
||||
prop_bindings = bindings;
|
||||
}
|
||||
|
||||
|
||||
QList<QPair<QString, QString> > BlockItem::getBindings() {
|
||||
return prop_bindings;
|
||||
}
|
||||
|
||||
|
||||
QString BlockItem::getBindName(const QString & prop_name) const {
|
||||
for(int i=0; i<prop_bindings.size(); ++i) {
|
||||
if (prop_bindings[i].first == prop_name) {
|
||||
return prop_bindings[i].second;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
QStringList BlockItem::getBindNames() const {
|
||||
QStringList ret;
|
||||
for(int i=0; i<prop_bindings.size(); ++i)
|
||||
if (!ret.contains(prop_bindings[i].second)) ret << prop_bindings[i].second;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QStringList BlockItem::getBindProps() const {
|
||||
QStringList ret;
|
||||
for(int i=0; i<prop_bindings.size(); ++i)
|
||||
ret << prop_bindings[i].first;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
//if ()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user