remove devices from blockview

git-svn-id: svn://db.shs.com.ru/libs@12 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2015-05-06 08:00:29 +00:00
parent 591db5f3bd
commit 3b56ff030e
2 changed files with 2 additions and 85 deletions

View File

@@ -52,43 +52,6 @@ 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();
@@ -112,8 +75,6 @@ void BlockItemPin::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
}
BlockItem::BlockItem(QGraphicsItem * parent): QGraphicsObject(parent), PropertyStorage(),
g_main(this), g_selection(this) {
setData(1006, "item");
@@ -329,13 +290,11 @@ 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(4, pdp) << cs.chunk(5, pp);
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, props) << cs.chunk(5, pp);
return cs.data();
}
@@ -343,19 +302,12 @@ QByteArray BlockItem::save() {
void BlockItem::load(const QByteArray & data) {
if (data.isEmpty()) return;
ChunkStream cs(data);
QMap<QString, QMap<QString, QString> > _v;
QMap<QString, QList<BlockItem::Property> > _p;
while (!cs.atEnd()) {
switch (cs.read()) {
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())
@@ -380,7 +332,6 @@ 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);
}