actual version libs withiout pip
git-svn-id: svn://db.shs.com.ru/libs@2 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -52,6 +52,43 @@ void BlockItemPin::_reparent() {
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::_updateText() {
|
||||
QString p;
|
||||
QMapIterator<QString, Device> it(devices_);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!p.isEmpty()) p += "\n";
|
||||
if (it.key().isEmpty()) p += it.value().devFPath;
|
||||
else p += QString("%1 = %2").arg(it.key(), it.value().devFPath);
|
||||
}
|
||||
text_item.setToolTip(p);
|
||||
setToolTip(p);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BlockItemPin::devicesPath() const {
|
||||
QMap<QString, QString> ret;
|
||||
QMapIterator<QString, Device> it(devices_);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!it.value().editable) continue;
|
||||
ret[it.key()] = it.value().devFPath;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void BlockItemPin::setDevicesPath(const QMap<QString, QString> & dp) {
|
||||
QMapIterator<QString, Device> it(devices_);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!it.value().editable) continue;
|
||||
if (!dp.contains(it.key())) continue;
|
||||
devices_[it.key()].devFPath = dp[it.key()];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariant BlockItemPin::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant & value) {
|
||||
if (change == QGraphicsItem::ItemParentChange)
|
||||
_reparent();
|
||||
@@ -292,11 +329,13 @@ void BlockItem::loadModel(const QByteArray & data) {
|
||||
|
||||
QByteArray BlockItem::save() {
|
||||
ChunkStream cs;
|
||||
QMap<QString, QMap<QString, QString> > pdp;
|
||||
QMap<QString, QList<BlockItem::Property> > pp;
|
||||
foreach (BlockItemPin * p, pins()) {
|
||||
pdp[p->text()] = p->devicesPath();
|
||||
pp[p->text()] = p->properties();
|
||||
}
|
||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, props) << cs.chunk(5, pp);
|
||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, props) << cs.chunk(4, pdp) << cs.chunk(5, pp);
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
@@ -311,6 +350,12 @@ void BlockItem::load(const QByteArray & data) {
|
||||
case 1: setPos(cs.getData<QPointF>()); break;
|
||||
case 2: setRotation(cs.getData<qreal>()); break;
|
||||
case 3: props = cs.getData<QList<BlockItem::Property> >(); break;
|
||||
case 4:
|
||||
_v = cs.getData<QMap<QString, QMap<QString, QString> > >();
|
||||
foreach (BlockItemPin * p, pins())
|
||||
if (_v.contains(p->text()))
|
||||
p->setDevicesPath(_v[p->text()]);
|
||||
break;
|
||||
case 5:
|
||||
_p = cs.getData<QMap<QString, QList<BlockItem::Property> > >();
|
||||
foreach (BlockItemPin * p, pins())
|
||||
@@ -335,6 +380,7 @@ BlockItem * BlockItem::copy() const {
|
||||
np->setBusType(p->busType());
|
||||
np->setAlignment(p->alignment());
|
||||
np->setText(p->text());
|
||||
np->setDevices(p->devices());
|
||||
np->properties() = p->properties();
|
||||
ret->addPin(np);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user