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:
@@ -57,6 +57,13 @@ public:
|
||||
InputOutput = 0x3
|
||||
};
|
||||
|
||||
struct Device {
|
||||
Device(const QString & n = QString(), const QString & p = QString(), bool e = false) {name = n; devFPath = p; editable = e;}
|
||||
QString name;
|
||||
QString devFPath;
|
||||
bool editable;
|
||||
};
|
||||
|
||||
void setPen(const QPen & p) {ell_item.setPen(p);}
|
||||
QPen pen() const {return ell_item.pen();}
|
||||
void setBrush(const QBrush & b) {ell_item.setBrush(b);}
|
||||
@@ -66,6 +73,8 @@ public:
|
||||
Qt::Alignment alignment() const {return align;}
|
||||
Direction direction() const {return dir;}
|
||||
QString text() const {return text_item.text();}
|
||||
const QMap<QString, Device> & devices() const {return devices_;}
|
||||
QMap<QString, QString> devicesPath() const;
|
||||
State state() const {return state_;}
|
||||
|
||||
void setBusType(int type_) {bus_type = type_;}
|
||||
@@ -73,6 +82,13 @@ public:
|
||||
void setDirection(Direction d) {dir = d; _init(true);}
|
||||
void setText(const QString & t) {text_item.setText(t); _init(true);}
|
||||
void setState(State s) {state_ = s; setBrush(br[int(state_)]); update();}
|
||||
void addDevice(const QString & name, const QString & path, bool editable = false) {devices_[name] = Device(name, path, editable); _updateText();}
|
||||
void setDevicesPath(const QMap<QString, QString> & dp);
|
||||
void removeDevice(const QString & name) {devices_.remove(name); _updateText();}
|
||||
void clearDevices() {devices_.clear(); _updateText();}
|
||||
void setDevices(const QMap<QString, Device> & d) {devices_ = d; _updateText();}
|
||||
Device device(const QString & name) const {return devices_.value(name);}
|
||||
bool isDeviceExists(const QString & name) const {return devices_.contains(name);}
|
||||
|
||||
void saveState() {sstate_.push(state_);}
|
||||
bool restoreState() {if (sstate_.isEmpty()) return false; setState(sstate_.pop()); return true;}
|
||||
@@ -92,6 +108,7 @@ protected:
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent * e);
|
||||
void _init(bool affect_parent = false);
|
||||
void _reparent();
|
||||
void _updateText();
|
||||
int bus_type;
|
||||
State state_;
|
||||
QGraphicsEllipseItem ell_item;
|
||||
@@ -101,6 +118,7 @@ protected:
|
||||
BlockItem * parent_;
|
||||
Qt::Alignment align;
|
||||
Direction dir;
|
||||
QMap<QString, Device> devices_;
|
||||
QBrush br[6];
|
||||
|
||||
};
|
||||
@@ -170,7 +188,7 @@ protected:
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const BlockItemPin * p) {
|
||||
ChunkStream cs;
|
||||
cs << cs.chunk(1, int(p->alignment())) << cs.chunk(2, p->busType()) << cs.chunk(3, p->text());
|
||||
cs << cs.chunk(1, int(p->alignment())) << cs.chunk(2, p->busType()) << cs.chunk(3, p->text()) << cs.chunk(4, p->devices());
|
||||
s << cs.data(); return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, BlockItemPin *& p) {
|
||||
ChunkStream cs(s);
|
||||
@@ -180,6 +198,22 @@ inline QDataStream & operator >>(QDataStream & s, BlockItemPin *& p) {
|
||||
case 1: p->setAlignment((Qt::Alignment)cs.getData<int>()); break;
|
||||
case 2: p->setBusType(cs.getData<int>()); break;
|
||||
case 3: p->setText(cs.getData<QString>()); break;
|
||||
case 4: p->setDevices(cs.getData<QMap<QString, BlockItemPin::Device> >()); break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const BlockItemPin::Device & d) {
|
||||
ChunkStream cs; cs << cs.chunk(1, d.name) << cs.chunk(2, d.devFPath) << cs.chunk(3, d.editable); s << cs.data(); return s;}
|
||||
inline QDataStream & operator >>(QDataStream & s, BlockItemPin::Device & d) {
|
||||
ChunkStream cs(s);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: d.name = cs.getData<QString>(); break;
|
||||
case 2: d.devFPath = cs.getData<QString>(); break;
|
||||
case 3: d.editable = cs.getData<bool>(); break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user