code brush
This commit is contained in:
@@ -105,9 +105,8 @@ bool EMainWindow::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e->type() == QEvent::Show || e->type() == QEvent::Hide /*|| e->type() == QEvent::ChildAdded || e->type() == QEvent::ChildRemoved*/) {
|
||||
if (e->type() == QEvent::Show || e->type() == QEvent::Hide) {
|
||||
//qDebug() << "filter";
|
||||
//QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection);
|
||||
changedDock();
|
||||
}
|
||||
}
|
||||
@@ -293,7 +292,6 @@ void EMainWindow::changedDock() {
|
||||
if (isHidden()) return;
|
||||
QList<QTabBar * > tabs(findChildren<QTabBar * >());
|
||||
QList<QDockWidget * > docks = findChildren<QDockWidget * >();
|
||||
// QSet<QDockWidget * > docks_tabs;
|
||||
QDockWidget * dock;
|
||||
// qDebug() << "### change";
|
||||
foreach (QTabBar * t, tabs) {
|
||||
@@ -316,7 +314,6 @@ void EMainWindow::changedDock() {
|
||||
t->setIconSize(dockTabsIconSize());
|
||||
#endif
|
||||
t->setTabIcon(i, dock->windowIcon());
|
||||
// docks_tabs << dock;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,11 +330,8 @@ void EMainWindow::changedDock() {
|
||||
}
|
||||
if (!tdocks.contains(d)) {
|
||||
tdocks << d;
|
||||
// qDebug() << "connect" << d;
|
||||
// connect(d, SIGNAL(destroyed(QObject*)), this, SLOT(changedDockClose(QObject*)), Qt::UniqueConnection);
|
||||
d->installEventFilter(this);
|
||||
}
|
||||
//d->titleBarWidget()->setHidden(docks_tabs.contains(d));
|
||||
if (tabifiedDockWidgets(d).isEmpty()) {
|
||||
if (d->titleBarWidget() != (QWidget * )(d->property("__titleWidget").toULongLong()))
|
||||
d->setTitleBarWidget((QWidget * )(d->property("__titleWidget").toULongLong()));
|
||||
@@ -351,19 +345,6 @@ void EMainWindow::changedDock() {
|
||||
}
|
||||
|
||||
|
||||
//void EMainWindow::changedDockClose(QObject * dock) {
|
||||
// qDebug() << "changedDockClose" << dock;
|
||||
// if (!dock) return;
|
||||
// foreach (QTabBar * t, tbars) {
|
||||
// for (int i = 0; i < t->count(); ++i)
|
||||
// if (t->tabData(i).toULongLong() == (qulonglong)dock) {
|
||||
// t->removeTab(i);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
void EMainWindow::closeDock(int index) {
|
||||
QDockWidget * dock = (QDockWidget * )((QTabBar*)sender())->tabData(index).toULongLong();
|
||||
if (dock == 0) return;
|
||||
|
||||
@@ -127,7 +127,6 @@ private slots:
|
||||
void changedDock();
|
||||
void sessionLoading(QPIConfig & conf) {loadingSession(conf);}
|
||||
void sessionSaving(QPIConfig & conf) {savingSession(conf);}
|
||||
// void changedDockClose(QObject * dock);
|
||||
void closeDock(int index);
|
||||
void recentTriggered();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
void setAlignment(Qt::Alignment align) {align_ = align; _move();}
|
||||
|
||||
QString text() const {return text_.text();}
|
||||
QFont font() const {return /*text_.font()*/font_;}
|
||||
QFont font() const {return font_;}
|
||||
QPen pen() const {return text_.pen();}
|
||||
QBrush brush() const {return text_.brush();}
|
||||
Qt::Alignment alignment() const {return align_;}
|
||||
|
||||
@@ -68,7 +68,7 @@ void BlockBusItem::reconnect() {
|
||||
if (temp_) return;
|
||||
if (!scene()) return;
|
||||
if (scene()->views().isEmpty()) return;
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "reconnectAll");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->reconnectAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,6 @@ void BlockBusItem::simplify(bool full) {
|
||||
}
|
||||
if (pcnt == pol.size()) return;
|
||||
updateGeometry();
|
||||
//if (scene()) scene()->update();
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +301,6 @@ int BlockBusItem::endpointCount() const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
QList<BlockItem * > BlockBusItem::connectedBlocks() const {
|
||||
QList<BlockItemPin * > pins = connections_.values();
|
||||
QSet<BlockItem * > ret;
|
||||
@@ -413,8 +411,8 @@ bool BlockBusItem::checkDelete() {
|
||||
|
||||
|
||||
void BlockBusItem::emitAction(BlockItemBase::Action a) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "schemeAction", Q_ARG(BlockItemBase::Action, a), Q_ARG(QList<QGraphicsItem*>, QList<QGraphicsItem*>() << this));
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "connectionsChanged");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->schemeAction(a, QList<QGraphicsItem*>() << this);
|
||||
qobject_cast<BlockView*>(scene()->views().back())->connectionsChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -438,7 +436,6 @@ QVector<int> BlockBusItem::endpointLine(int ep, double angle) const {
|
||||
int np = segmentPointPair(ep, &seg), pp = np;
|
||||
if (ep < 0 || np < 0) return ret;
|
||||
if (pol[np] == pol[ep]) return ret;
|
||||
//QPointF sp = pol[np] - pol[ep];
|
||||
QLineF l(pol[ep], pol[np]);
|
||||
//qDebug() << "first" << l.angle() << angle << (l.angle() != angle);
|
||||
if (qAbs(l.angle() - angle) > 0.1) return ret;
|
||||
@@ -597,7 +594,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
bv->cur_bus = this;
|
||||
}
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchCancel");
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranchCancel();
|
||||
}
|
||||
new_segment = false;
|
||||
if ((selPoint < 0 || selPoint > pol.size() - 1) && (selSegment < 0) && e->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
@@ -606,8 +603,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
}
|
||||
int btncnt = 0;
|
||||
if ((e->button() == Qt::LeftButton) && e->modifiers().testFlag(Qt::ShiftModifier)) {
|
||||
if (endpoints().contains(selPoint))
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "startBusPointMove", Q_ARG(int, busType()));
|
||||
if (endpoints().contains(selPoint)) qobject_cast<BlockView*>(scene()->views().back())->startBusPointMove(bus_type);
|
||||
}
|
||||
if (e->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (e->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
@@ -617,16 +613,6 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
//qDebug() << "bus revert";
|
||||
mm_cancel = true;
|
||||
moved = false;
|
||||
/*QPointF lp = qp - press_pos;
|
||||
//qDebug() << lp;
|
||||
if (selPoint >= 0 && selPoint <= pol.size() - 1) {
|
||||
pol[selPoint] += lp;
|
||||
}
|
||||
if (selSegment >= 0 && selSegment <= segments.size() - 1) {
|
||||
pol[segments[selSegment].first] += lp;
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;*/
|
||||
pol = bpol;
|
||||
prepareGeometryChange();
|
||||
return;
|
||||
@@ -645,7 +631,7 @@ void BlockBusItem::mousePressEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (pointSegmentsCount(selPoint) >= 2 || selSegment >= 0)
|
||||
return;
|
||||
}
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranch", Q_ARG(BlockBusItem * , this));
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranch(this);
|
||||
new_segment = true;
|
||||
return;
|
||||
}
|
||||
@@ -694,8 +680,7 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
qp = quantize(e->scenePos(), grid_step);
|
||||
lp = qp - lp;
|
||||
if (e->buttons().testFlag(Qt::LeftButton) && mm_mods.testFlag(Qt::NoModifier) && new_segment) {
|
||||
if (bv)
|
||||
QMetaObject::invokeMethod(bv, "newBranchTrace", Q_ARG(BlockBusItem * , this), Q_ARG(QPointF, e->scenePos()));
|
||||
if (bv) qobject_cast<BlockView*>(scene()->views().back())->newBranchTrace(this, e->scenePos());
|
||||
return;
|
||||
}
|
||||
if (new_segment) {
|
||||
@@ -711,7 +696,6 @@ void BlockBusItem::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
|
||||
pol[segments[selSegment].second] += lp;
|
||||
}
|
||||
moved = true;
|
||||
//if (bv) bv->bus_moved = true;
|
||||
prepareGeometryChange();
|
||||
}
|
||||
}
|
||||
@@ -727,7 +711,7 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||
if (e->buttons().testFlag(QT_MID_BUTTON )) btncnt++;
|
||||
if (btncnt == 0) mm_cancel = false;
|
||||
if (new_segment) {
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "newBranchAccept", Q_ARG(BlockBusItem * , this));
|
||||
qobject_cast<BlockView*>(scene()->views().back())->newBranchAccept(this);
|
||||
updateGeometry();
|
||||
selPoint = selSegment = -1;
|
||||
}
|
||||
@@ -740,7 +724,6 @@ void BlockBusItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
|
||||
emitAction( BlockItemBase::BusSegmentMove);
|
||||
}
|
||||
}
|
||||
QMetaObject::invokeMethod(scene()->views().back(), "endBusPointMove");
|
||||
moved = new_segment = false;
|
||||
QGraphicsObject::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -760,8 +743,6 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
p->setPen(pu);
|
||||
p->setBrush(bu);
|
||||
}
|
||||
//if (mark_in) {p->setPen(pa); p->setBrush(ba);}
|
||||
//if (mark_out) {p->setPen(pr); p->setBrush(br);}
|
||||
if (im_bus.isNull()) {
|
||||
QPen _pen(p->pen());
|
||||
for (int i = 0; i < segments.size(); ++i) {
|
||||
@@ -787,16 +768,10 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
tf.rotate(-QLineF(sp, ep).angle());
|
||||
tf.translate(0., -im_bus.height() / 2. * im_bus_scale);
|
||||
tf.scale(im_bus_scale, im_bus_scale);
|
||||
/*
|
||||
br.setTransform(tf);
|
||||
p->setPen(QPen(br, im_bus.height(), Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
|
||||
p->drawLine(sp, ep);
|
||||
*/
|
||||
p->save();
|
||||
p->setTransform(tf, true);
|
||||
p->setPen(Qt::NoPen);
|
||||
p->setBrush(br);
|
||||
//p->drawLine(QPointF(0., 0.), QPointF(QLineF(sp, ep).length(), 0.));
|
||||
p->drawRect(QRectF(0., 0., QLineF(sp, ep).length() / qMax<double>(im_bus_scale, 1E-3), im_bus.height()));
|
||||
p->restore();
|
||||
}
|
||||
@@ -836,8 +811,6 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
p->drawLine(pol[segments[i].first], pol[segments[i].second]);
|
||||
}
|
||||
}
|
||||
//if (mark_in) {p->setPen(pa); p->setBrush(ba);}
|
||||
//if (mark_out) {p->setPen(pr); p->setBrush(br);}
|
||||
if (selPoint >= 0) {
|
||||
p->save();
|
||||
p->setPen(ph);
|
||||
|
||||
@@ -47,29 +47,16 @@ public:
|
||||
double endpointImageScale() const {return im_end_scale;}
|
||||
void appendPoint(const QPointF & p);
|
||||
void appendPoint(qreal x, qreal y);
|
||||
void testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace = false);
|
||||
void movePolyline(const QPointF & dp);
|
||||
void clear();
|
||||
/*void setStart(const QPointF & p) {pol[0] = p; scene()->update();}
|
||||
void setStart(qreal x, qreal y) {setStart(QPointF(x, y));}
|
||||
void setFinish(const QPointF & p) {pol[pol.size() - 1] = p; scene()->update();}
|
||||
void setFinish(qreal x, qreal y) {setFinish(QPointF(x, y));}
|
||||
void setPoint(int index, const QPointF & p) {pol[index] = p; scene()->update();}
|
||||
void setPoint(int index, qreal x, qreal y) {setPoint(index, QPointF(x, y));}*/
|
||||
void setPen(const QPen & p) {p_ = p; update();}
|
||||
QPen pen() const {return p_;}
|
||||
void setBrush(const QBrush & b) {b_ = b; update();}
|
||||
QBrush brush() const {return b_;}
|
||||
//void disconnectBrick() {BrickBase::disconnect(brickFrom, portFrom, brickTo, portTo);}
|
||||
void movePolyline(const QPointF & dp);
|
||||
void movePoint(int index, const QPointF & dp);
|
||||
double width() const {return pen_width;}
|
||||
void setWidth(const double & w);
|
||||
void setColor(const QColor & c);
|
||||
void setSquareNodes(bool yes);
|
||||
int addPoint(const QPointF & point, bool update = true);
|
||||
int segmentPointPair(int point, int * seg = 0) const;
|
||||
void removePoint(int index);
|
||||
void removeSegment(int index);
|
||||
void markAsInput();
|
||||
void markAsOutput();
|
||||
void unmark();
|
||||
@@ -99,9 +86,15 @@ protected:
|
||||
void updateGeometry();
|
||||
bool checkDelete();
|
||||
void emitAction(BlockItemBase::Action a);
|
||||
void testPoint(QPointF pos, int * sel_point, int * sel_segment, bool for_trace = false);
|
||||
int addPoint(const QPointF & point, bool update = true);
|
||||
int segmentPointPair(int point, int * seg = 0) const;
|
||||
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
||||
void removePoint(int index);
|
||||
void removeSegment(int index);
|
||||
void movePoint(int index, const QPointF & dp);
|
||||
QVector<int> endpoints() const;
|
||||
QVector<int> endpointLine(int ep, double angle) const;
|
||||
int pointSegmentsCount(int point, QList<int> * segs = 0) const;
|
||||
int neighborSegmentPoint(int point, int * seg) const;
|
||||
int type() const {return Type;}
|
||||
QRectF boundingRect() const;
|
||||
|
||||
@@ -199,7 +199,6 @@ void BlockEditor::on_buttonSave_clicked() {
|
||||
QFile f(cur_file);
|
||||
if (f.open(QIODevice::WriteOnly)) {
|
||||
f.write(saveModel());
|
||||
//setWindowTitle(src_title + QString(" - %1").arg(QFileInfo(c).baseName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +300,6 @@ void BlockEditor::on_treePins_itemChanged(QTreeWidgetItem * item, int column) {
|
||||
|
||||
void BlockEditor::arrangePins() {
|
||||
QVector<BlockItemPin * > pins = block.pins();
|
||||
// block.clearPins();
|
||||
QList<QTreeWidgetItem*> tli = pin_tli.values();
|
||||
foreach (QTreeWidgetItem * ti, tli) {
|
||||
for (int i = 0; i < ti->childCount(); ++i) {
|
||||
@@ -315,19 +313,6 @@ void BlockEditor::arrangePins() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i = 0; i < ui->treePins->topLevelItemCount(); ++i) {
|
||||
// QTreeWidgetItem * ti = ui->treePins->topLevelItem(i);
|
||||
// if (tli.contains(ti)) continue;
|
||||
// ti = ui->treePins->takeTopLevelItem(i);
|
||||
// pin_tli[ti->data(0, Qt::UserRole + 1).toInt()]->addChild(ti);
|
||||
// foreach (BlockItemPin * p, pins)
|
||||
// if (p->text() == ti->text(0)) {
|
||||
// p->setAlignment((Qt::Alignment)ti->data(0, Qt::UserRole + 1).toInt());
|
||||
// block.addPin(p, false);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
block.arrangePins();
|
||||
}
|
||||
|
||||
@@ -392,9 +377,3 @@ void PinBusDelegate::setModelData(QWidget * editor, QAbstractItemModel * model,
|
||||
model->setData(index, ((QSpinBox*)editor)->value());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//void BlockEditor::on_treePins_itemSelectionChanged() {
|
||||
// arrangePins();
|
||||
// qDebug() << "111111111111111";
|
||||
//}
|
||||
|
||||
@@ -68,7 +68,6 @@ private slots:
|
||||
void on_buttonPinDelete_clicked();
|
||||
void on_buttonPinClear_clicked();
|
||||
void on_treePins_itemChanged(QTreeWidgetItem *item, int column);
|
||||
// void on_treePins_itemSelectionChanged();
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
|
||||
@@ -32,18 +32,6 @@ g_main(this), g_selection(this) {
|
||||
anim_sel.setEasingCurve(QEasingCurve::OutCubic);
|
||||
anim_sel.setDuration(400);
|
||||
t_sel.start();
|
||||
//g_main.setBrush(QColor(128, 128, 128, 64));
|
||||
/*
|
||||
BlockItemPin * pin = new BlockItemPin(Qt::AlignRight, 0, this);
|
||||
pin->setText("text");
|
||||
pin->setBusType(0);
|
||||
addPin(pin);
|
||||
pin = new BlockItemPin(Qt::AlignTop, this);
|
||||
pin->setBusType(0); addPin(pin);
|
||||
pin = new BlockItemPin(Qt::AlignLeft, this);
|
||||
pin->setBusType(1); addPin(pin);
|
||||
pin = new BlockItemPin(Qt::AlignRight, this);
|
||||
pin->setBusType(1); addPin(pin);*/
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +125,6 @@ void BlockItem::addDecor(QGraphicsItem & item) {
|
||||
qgraphicsitem_cast<AlignedTextItem*>(&item)->setData(bvidDecorText, qgraphicsitem_cast<AlignedTextItem*>(&item)->text());
|
||||
item.setData(bvidMoveParent, true);
|
||||
item.setData(bvidBlockDecor, true);
|
||||
//decors_ << &item;
|
||||
item.setParentItem(this);
|
||||
}
|
||||
|
||||
@@ -176,7 +163,7 @@ void BlockItem::clearDecors() {
|
||||
decors_.clear();
|
||||
if (scene()) {
|
||||
scene()->blockSignals(pbs);
|
||||
QMetaObject::invokeMethod(scene(), "selectionChanged");
|
||||
scene()->selectionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,14 +178,6 @@ QVector<BlockItemPin * > BlockItem::pins() const {
|
||||
|
||||
|
||||
QByteArray BlockItem::saveModel() {
|
||||
/*QDataStream s(&ret, QIODevice::ReadWrite);
|
||||
QVector<BlockItemPin * > ps = pins();
|
||||
s << pos() << rotation() << size() << color() << ps.size();
|
||||
foreach (BlockItemPin * p, ps)
|
||||
s << int(p->alignment()) << p->busType() << p->text() << p->devices();
|
||||
s << decors_.size();
|
||||
foreach (QGraphicsItem * i, decors_)
|
||||
s << i;*/
|
||||
ChunkStream cs;
|
||||
cs << cs.chunk(1, pos()) << cs.chunk(2, rotation()) << cs.chunk(3, size()) << cs.chunk(4, color()) << cs.chunk(5, pins())
|
||||
<< cs.chunk(6, decors_) << cs.chunk(7, pins_margin) << cs.chunk(0xFF, _blockitem_current_version_);
|
||||
@@ -213,29 +192,6 @@ void BlockItem::loadModel(const QByteArray & data) {
|
||||
col = Qt::lightGray;
|
||||
_resize(QSizeF(100., 60.));
|
||||
if (data.isEmpty()) return;
|
||||
/*QDataStream s(data);
|
||||
{QPointF _v; s >> _v;}
|
||||
{qreal _v; s >> _v;}
|
||||
{QSizeF _v; s >> _v; setSize(_v);}
|
||||
{QColor _v; s >> _v; setColor(_v);}
|
||||
int _s; s >> _s;
|
||||
for (int i = 0; i < _s; ++i) {
|
||||
BlockItemPin * pin = new BlockItemPin();
|
||||
{int _v; s >> _v; pin->setAlignment((Qt::Alignment)_v);}
|
||||
{int _v; s >> _v; pin->setBusType(_v);}
|
||||
{QString _v; s >> _v; pin->setText(_v);}
|
||||
{QMap<QString, BlockItemPin::Device> _v; s >> _v; pin->setDevices(_v);}
|
||||
addPin(pin);
|
||||
}
|
||||
s >> _s;
|
||||
for (int i = 0; i < _s; ++i) {
|
||||
if (s.atEnd()) break;
|
||||
QGraphicsItem * ni = 0;
|
||||
s >> ni;
|
||||
if (ni) {
|
||||
addDecor(ni);
|
||||
}
|
||||
}*/
|
||||
ChunkStream cs(data);
|
||||
QVector<BlockItemPin * > tp;
|
||||
QList<QGraphicsItem * > dl;
|
||||
@@ -374,11 +330,6 @@ QRectF BlockItem::boundingRect() const {
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
|
||||
//QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::hoverEnterEvent(QGraphicsSceneHoverEvent * e) {
|
||||
bool anim = ((BlockView *)scene()->views().back())->isBlockAnimationEnabled();
|
||||
if (anim) {
|
||||
@@ -406,9 +357,7 @@ void BlockItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
#define _POS(m) (i - ((cp.size() - 1) / 2)) * m
|
||||
|
||||
void BlockItem::arrangePins() {
|
||||
//double w = g_main.rect().width(), h = g_main.rect().height();
|
||||
QVector<BlockItemPin * > pl = pins();
|
||||
// pl = pl.fromList(pins().toList());
|
||||
pins_.clear();
|
||||
foreach (BlockItemPin * p, pl)
|
||||
pins_[p->alignment()] << p;
|
||||
@@ -505,11 +454,6 @@ QStringList BlockItem::getBindProps() const {
|
||||
}
|
||||
|
||||
|
||||
void BlockItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
//if ()
|
||||
}
|
||||
|
||||
|
||||
QVariant BlockItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant & value) {
|
||||
if (change == QGraphicsItem::ItemSelectedChange) {
|
||||
// qDebug() << "select" << value.toBool();
|
||||
|
||||
@@ -89,14 +89,13 @@ protected:
|
||||
void _moveToTop(bool only_decors = false);
|
||||
int type() const {return Type;}
|
||||
QRectF boundingRect() const;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
|
||||
double left() const {return boundingRect().left();}
|
||||
double right() const {return boundingRect().right();}
|
||||
double top() const {return boundingRect().top();}
|
||||
double bottom() const {return boundingRect().bottom();}
|
||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||
void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr) {}
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value);
|
||||
|
||||
QGraphicsRectItem g_main, g_selection;
|
||||
|
||||
@@ -143,8 +143,8 @@ void BlockItemPin::hoverEnterEvent(QGraphicsSceneHoverEvent * e) {
|
||||
QGraphicsView * v = _view();
|
||||
bool m_pin_mc = false;
|
||||
if (v) {
|
||||
QMetaObject::invokeMethod(v, "getPinMC", Q_ARG(bool*, &m_pin_mc));
|
||||
QMetaObject::invokeMethod(v, "pinHoverInOut", Qt::QueuedConnection, Q_ARG(BlockItemPin*, this));
|
||||
qobject_cast<BlockView*>(v)->getPinMC(&m_pin_mc);
|
||||
QMetaObject::invokeMethod(v, [this, v](){qobject_cast<BlockView*>(v)->pinHoverInOut(this);}, Qt::QueuedConnection);
|
||||
}
|
||||
if ((state() != Disconnected) && !m_pin_mc) return;
|
||||
saveState();
|
||||
@@ -159,5 +159,7 @@ void BlockItemPin::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) {
|
||||
restoreState();
|
||||
enlargePin(false);
|
||||
update();
|
||||
if (v) QMetaObject::invokeMethod(v, "pinHoverInOut", Q_ARG(BlockItemPin*, 0));
|
||||
if (v) {
|
||||
qobject_cast<BlockView*>(v)->pinHoverInOut(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,6 @@ void BlockView::_init() {
|
||||
scene_->installEventFilter(this);
|
||||
scene_->addItem(&tmp_bus);
|
||||
widget_thumb.setParent(this);
|
||||
//widget_thumb.setAutoFillBackground(true);
|
||||
//widget_thumb.setStyleSheet("background-color: rgb(255, 0, 0);");
|
||||
widget_thumb.installEventFilter(this);
|
||||
widget_thumb.setMouseTracking(true);
|
||||
widget_thumb.show();
|
||||
@@ -171,45 +169,23 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
foreach (QGraphicsItem * i, mil) {
|
||||
if (i->data(bvidTmpItem).toBool()) continue;
|
||||
if (i->data(bvidType).toInt() == bvitBlock) {
|
||||
//emit blockDoubleClicked((BlockItem * )i);
|
||||
QMetaObject::invokeMethod(this, "blockDoubleClicked", Qt::QueuedConnection, Q_ARG(BlockItem * , (BlockItem*)i));
|
||||
QMetaObject::invokeMethod(this, [this, i](){blockDoubleClicked(qgraphicsitem_cast<BlockItem*>(i));}, Qt::QueuedConnection);
|
||||
return true;
|
||||
}
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(i)->isBusSelected()) {
|
||||
//emit busDoubleClicked(qgraphicsitem_cast<BlockBusItem*>(i));
|
||||
QMetaObject::invokeMethod(this, "busDoubleClicked", Qt::QueuedConnection, Q_ARG(BlockBusItem * , (BlockBusItem*)i));
|
||||
QMetaObject::invokeMethod(this, [this, i](){busDoubleClicked(qgraphicsitem_cast<BlockBusItem*>(i));}, Qt::QueuedConnection);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//return true;
|
||||
break;
|
||||
/*case QEvent::GraphicsSceneHoverMove:
|
||||
mil = scene_->items(scene_point);
|
||||
mm_ci = (mil.isEmpty() ? 0 : mil.front());
|
||||
if (mm_ci != 0) {
|
||||
while (mm_ci->data(bvidType).toInt() == bvitBus) {
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci))
|
||||
if (qgraphicsitem_cast<BlockBusItem*>(mm_ci)->isBusSelected())
|
||||
break;
|
||||
if (mil.size() > 1) {
|
||||
mm_ci = mil[1];
|
||||
mil.pop_front();
|
||||
} else {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;*/
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
if (mm_ci != 0) {
|
||||
if (mm_ci->data(bvidTmpItem).toBool()) {
|
||||
mm_ci = 0;
|
||||
break;
|
||||
}
|
||||
//if (mm_ci->data(bvidItemSelection).toBool()) break;
|
||||
}
|
||||
if (me->buttons().testFlag(Qt::LeftButton )) btncnt++;
|
||||
if (me->buttons().testFlag(Qt::RightButton)) btncnt++;
|
||||
@@ -347,14 +323,9 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
}
|
||||
cur_scl = qSqrt(transform().determinant());
|
||||
//return true;
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
//qDebug() << "move" << (mm_ci != 0 ? mm_ci : 0) << mm_mods << mm_cancel << mm_drag;
|
||||
/*if (ghost_) {
|
||||
ghost_->setPos(quantize(me->scenePos(), grid_step));
|
||||
}*/
|
||||
//qDebug() << "move cur_bus" << cur_bus;
|
||||
if (cur_bus) {
|
||||
return false;
|
||||
}
|
||||
@@ -515,7 +486,6 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
if (me->modifiers().testFlag(Qt::ControlModifier) && me->buttons() != 0 && mm_ci == 0)
|
||||
return true;
|
||||
//qDebug() << "scene mouse";
|
||||
//return true;
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) btncnt++;
|
||||
@@ -574,12 +544,15 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
if (match_bus == 0) {
|
||||
BlockBusItem * nb = new BlockBusItem(tmp_bus);
|
||||
addItem(nb, tmp_buses.isEmpty());
|
||||
newBusCreated(nb);
|
||||
foreach (BlockBusItem * b, tmp_buses) {
|
||||
nb = new BlockBusItem(*b);
|
||||
addItem(nb, b == tmp_buses.back());
|
||||
newBusCreated(nb);
|
||||
}
|
||||
} else {
|
||||
if (connectTmpToBus(match_bus)) {
|
||||
newBusCreated(match_bus);
|
||||
emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << match_bus);
|
||||
emit connectionsChanged();
|
||||
}
|
||||
@@ -589,8 +562,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
||||
hideTmpBuses();
|
||||
reconnectAll();
|
||||
BlockItemPin * pin = getPin(scene_->items(me->scenePos()));
|
||||
if (pin)
|
||||
pin->hoverEnterEvent(0);
|
||||
if (pin) pin->hoverEnterEvent(0);
|
||||
m_trace_with_buses = prev_tcb;
|
||||
}
|
||||
clearBusStates();
|
||||
@@ -689,7 +661,6 @@ void BlockView::mousePressEvent(QMouseEvent * event) {
|
||||
press_point = event->pos();
|
||||
if (event->buttons().testFlag(QT_MID_BUTTON) || event->buttons().testFlag(Qt::RightButton)) {
|
||||
setCursor(Qt::ClosedHandCursor);
|
||||
//sel_rect.hide();
|
||||
if (sel_rect.scene())
|
||||
scene_->removeItem(&sel_rect);
|
||||
}
|
||||
@@ -809,12 +780,12 @@ void BlockView::scrollContentsBy(int dx, int dy) {
|
||||
if (isHidden()) return;
|
||||
thumbShow();
|
||||
restartTimer(timer_thumb, thumb_hide_delay);
|
||||
QMetaObject::invokeMethod(&widget_thumb, "update", Qt::QueuedConnection);
|
||||
QWidget * w = &widget_thumb;
|
||||
QMetaObject::invokeMethod(this, [w](){w->update();}, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
void BlockView::drawBackground(QPainter * painter, const QRectF & rect) {
|
||||
// QGraphicsView::drawBackground(painter, rect);
|
||||
if (mm_thumb) return;
|
||||
float rx, ry, sx = grid_step, sy = grid_step;
|
||||
double scl = qRound(1. / qSqrt(transform().determinant()));
|
||||
@@ -889,6 +860,11 @@ void BlockView::clearGhost() {
|
||||
}
|
||||
|
||||
|
||||
void BlockView::getPinMC(bool * v) {
|
||||
if (v) *v = m_pin_mc;
|
||||
}
|
||||
|
||||
|
||||
void BlockView::drawThumb() {
|
||||
if (!minimap) return;
|
||||
QPainter p(&widget_thumb);
|
||||
@@ -945,7 +921,6 @@ void BlockView::thumbHide() {
|
||||
thumb_anim.setEndValue(0.);
|
||||
thumb_anim.start();
|
||||
//qDebug() << "hide" << thumb_anim.startValue() << thumb_anim.endValue();
|
||||
//widget_thumb.hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -953,13 +928,8 @@ void BlockView::thumbShow() {
|
||||
if (!minimap) return;
|
||||
if (widget_thumb.isHidden() || (_talpha < 0.1)) drawSceneThumb();
|
||||
thumb_anim.stop();
|
||||
/*thumb_anim.setDuration(100);
|
||||
thumb_anim.setStartValue(_thumb());
|
||||
thumb_anim.setEndValue(1.);
|
||||
thumb_anim.start();*/
|
||||
_setThumb(1.);
|
||||
//qDebug() << "show" << thumb_anim.startValue() << thumb_anim.endValue();
|
||||
//widget_thumb.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1070,7 +1040,6 @@ bool BlockView::connectPins(BlockItemPin * p0, BlockItemPin * p1) {
|
||||
if (!(QList2QSet(bl0) & QList2QSet(bl1)).isEmpty()) return true;
|
||||
BlockBusItem * nb = new BlockBusItem();
|
||||
nb->setBusType(p0->busType());
|
||||
//nb->setEndpointsNumber(3);
|
||||
loadBus(nb);
|
||||
if (!bl0.isEmpty() && !bl1.isEmpty()) { // connect two existing buses
|
||||
} else {
|
||||
@@ -1122,6 +1091,7 @@ bool BlockView::connectPins(BlockItemPin * p0, BlockItemPin * p1) {
|
||||
}
|
||||
}
|
||||
reconnectAll();
|
||||
newBusCreated(nb);
|
||||
emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << nb);
|
||||
emit connectionsChanged();
|
||||
return true;
|
||||
@@ -1286,7 +1256,6 @@ void BlockView::trace(QPointF scene_pos_from, QPointF scene_pos_to, BlockBusItem
|
||||
}
|
||||
QRect sr = scene_->sceneRect().toRect();
|
||||
int dx = sr.left() / grid_step, dy = sr.top() / grid_step;
|
||||
//qDebug() << dp;
|
||||
QPoint dp(-dx, -dy), qpt = quantize(scene_pos_to, grid_step).toPoint() / grid_step + dp;
|
||||
QElapsedTimer tm;
|
||||
tm.restart();
|
||||
@@ -1359,8 +1328,6 @@ void BlockView::clearBusStates() {
|
||||
if (i->data(bvidType).toInt() == bvitBus) {
|
||||
BlockBusItem * b = qgraphicsitem_cast<BlockBusItem*>(i);
|
||||
b->clearBusState();
|
||||
// if (i != bus_from && i != match_bus)
|
||||
//b->selPoint = b->selSegment = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1436,7 +1403,6 @@ void BlockView::matchBus() {
|
||||
}
|
||||
}
|
||||
}
|
||||
//b->press_point = point;
|
||||
iconnect = true;
|
||||
b->setBusState(true);
|
||||
b->selPoint = sp;
|
||||
@@ -1479,8 +1445,6 @@ void BlockView::markPins(int bus_type) {
|
||||
if (p->busType() == bus_type) {
|
||||
if (p->state() == BlockItemPin::Disconnected)
|
||||
p->setState(BlockItemPin::Accept);
|
||||
// else
|
||||
// p->animAccept();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1550,22 +1514,6 @@ void BlockView::moveBuses(const QList<QGraphicsItem * > & items, QPointF dp) {
|
||||
foreach (BlockItemPin * p, pins) {
|
||||
QList<int> ends = b->connections_.keys(p);
|
||||
for (int i = 0; i < ends.size(); ++i) {
|
||||
/*int isp = b->segmentPointPair(ends[i]);
|
||||
QPointF sdp;
|
||||
if (isp >= 0 && b->pol.size() > 2) {
|
||||
sdp = b->pol[isp] - b->pol[ends[i]];
|
||||
if (!sdp.isNull()) {
|
||||
if (sdp.x() == 0. && dp.x() != 0.)
|
||||
b->movePoint(isp, QPointF(dp.x(), 0.));
|
||||
if (sdp.y() == 0. && dp.y() != 0.)
|
||||
b->movePoint(isp, QPointF(0., dp.y()));
|
||||
} else {
|
||||
if (p->alignment() == Qt::AlignTop || p->alignment() == Qt::AlignBottom)
|
||||
b->movePoint(isp, QPointF(dp.x(), 0.));
|
||||
if (p->alignment() == Qt::AlignLeft || p->alignment() == Qt::AlignRight)
|
||||
b->movePoint(isp, QPointF(0., dp.y()));
|
||||
}
|
||||
}*/
|
||||
QPointF pdp = dp;
|
||||
double ang = 0.;
|
||||
switch (p->alignment()) {
|
||||
@@ -1753,13 +1701,6 @@ void BlockView::startBusPointMove(int bus_type) {
|
||||
}
|
||||
|
||||
|
||||
void BlockView::endBusPointMove() {
|
||||
move_bus_point = false;
|
||||
unmarkPins();
|
||||
reconnectAll();
|
||||
}
|
||||
|
||||
|
||||
void BlockView::pinHoverInOut(BlockItemPin * pin) {
|
||||
//qDebug() << "pinHoverInOut" << pin << pin->state();
|
||||
highlightNearPins(pin, QApplication::keyboardModifiers());
|
||||
@@ -1771,7 +1712,7 @@ void BlockView::checkPaste(bool queued) {
|
||||
bool ret = false;
|
||||
if (mime)
|
||||
ret = mime->hasFormat(_BlockView_Mime_);
|
||||
if (queued) QMetaObject::invokeMethod(this, "pasteEnabledChanged", Qt::QueuedConnection, Q_ARG(bool, ret));
|
||||
if (queued) QMetaObject::invokeMethod(this, [this, ret](){pasteEnabledChanged(ret);}, Qt::QueuedConnection);
|
||||
else emit pasteEnabledChanged(ret);
|
||||
}
|
||||
|
||||
@@ -1833,6 +1774,7 @@ void BlockView::newBranchAccept(BlockBusItem * item) {
|
||||
match_bus = 0;
|
||||
}
|
||||
item->updateGeometry();
|
||||
newBusCreated(item);
|
||||
emitActionEvent(BlockItemBase::BusAdd, QList<QGraphicsItem*>() << item);
|
||||
emit connectionsChanged();
|
||||
tmp_bus.clear();
|
||||
@@ -1886,7 +1828,8 @@ void BlockView::sceneSelectionChanged() {
|
||||
|
||||
void BlockView::_setThumb(double v) {
|
||||
_talpha = v;
|
||||
QMetaObject::invokeMethod(&widget_thumb, "update", Qt::QueuedConnection);
|
||||
QWidget * w = &widget_thumb;
|
||||
QMetaObject::invokeMethod(this, [w](){w->update();}, Qt::QueuedConnection);
|
||||
if (_talpha <= 0.01) widget_thumb.hide();
|
||||
else widget_thumb.show();
|
||||
}
|
||||
@@ -2071,8 +2014,6 @@ void BlockView::removeSelected() {
|
||||
QList<QGraphicsItem*> gi = scene_->selectedItems(), ai;
|
||||
blockSignals(true);
|
||||
QList<BlockBusItem * > sbuses = buses(), dbuses, wbuses = wrongConnectedBuses();
|
||||
//foreach (BlockBusItem * i, wbuses)
|
||||
// sbuses.removeOne(i);
|
||||
foreach (BlockBusItem * i, sbuses)
|
||||
if (i->connectedBlocks().isEmpty())
|
||||
dbuses << i;
|
||||
|
||||
@@ -64,6 +64,7 @@ class QAD_BLOCKVIEW_EXPORT BlockView: public QGraphicsView
|
||||
Q_PROPERTY(QRectF _nav READ _nav WRITE _setNav DESIGNABLE false SCRIPTABLE false)
|
||||
|
||||
friend class BlockBusItem;
|
||||
friend class BlockItemPin;
|
||||
|
||||
public:
|
||||
BlockView(QWidget * parent = 0);
|
||||
@@ -174,6 +175,7 @@ protected:
|
||||
virtual void copyBlocks(QList<BlockItem * > items, QPointF offset) {}
|
||||
virtual void copyBuses(QList<BlockBusItem * > items, QPointF offset) {}
|
||||
virtual void newBusStarted(int bus_type) {}
|
||||
virtual void newBusCreated(BlockBusItem * bus) {}
|
||||
|
||||
QGraphicsScene * scene_;
|
||||
QGraphicsRectItem sel_rect;
|
||||
@@ -205,7 +207,7 @@ protected:
|
||||
double prev_app_scale;
|
||||
|
||||
protected slots:
|
||||
void getPinMC(bool * v) {if (v) *v = m_pin_mc;}
|
||||
void getPinMC(bool * v);
|
||||
void adjustThumb();
|
||||
void newBranch(BlockBusItem * item);
|
||||
void newBranchTrace(BlockBusItem * item, QPointF to);
|
||||
@@ -221,7 +223,6 @@ protected slots:
|
||||
void _setNav(QRectF v);
|
||||
void _navFinished();
|
||||
void startBusPointMove(int bus_type);
|
||||
void endBusPointMove();
|
||||
void pinHoverInOut(BlockItemPin * pin);
|
||||
void checkPaste(bool queued);
|
||||
void checkPaste() {checkPaste(false);}
|
||||
|
||||
@@ -55,7 +55,6 @@ bool BlockViewWavetrace::trace(const QPoint & start, const QPoint & finish) {
|
||||
fn = finish;
|
||||
if (dir_ == NoTrace) return true;
|
||||
//qDebug() << "trace" << start << finish;
|
||||
//return true;
|
||||
short cl = 0;
|
||||
QRect frect(0, 0, wid - 1, hei - 1);
|
||||
QVector<QPoint> cpnts, npnts;
|
||||
@@ -103,7 +102,6 @@ void BlockViewWavetrace::gatherPath() {
|
||||
short cl = field[fn.x()][fn.y()].value;
|
||||
QRect frect(0, 0, wid, hei);
|
||||
QPoint cpnt = fn;
|
||||
//cout << "start from " << cl << endl;
|
||||
auto checkAndStep = [this, &cpnt, &first, &frect] (int dir, short c, int & ca_, int pa_)->bool {
|
||||
int cx = cpnt.x() + dps[dir].x();
|
||||
int cy = cpnt.y() + dps[dir].y();
|
||||
@@ -137,7 +135,6 @@ void BlockViewWavetrace::gatherPath() {
|
||||
|
||||
}
|
||||
path_.push_front(st);
|
||||
//cout << path_.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,9 +156,5 @@ void BlockViewWavetrace::setPreferredDirection(BlockViewWavetrace::Direction dir
|
||||
|
||||
|
||||
const QVector<QPoint> & BlockViewWavetrace::path() const {
|
||||
/*path_.resize(3);
|
||||
path_[0] = st;
|
||||
path_[1] = (st + fn) / 2;
|
||||
path_[2] = fn;*/
|
||||
return path_;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ _DTSizeItem::_DTSizeItem(): QGraphicsObject() {
|
||||
rects[i].setRect(-5, -5, 10, 10);
|
||||
rects[i].setPen(QPen(Qt::darkBlue));
|
||||
rects[i].setBrush(QBrush(QColor(64, 64, 255, 128)));
|
||||
//rects[i].setData(bvidBlockDecor, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +109,10 @@ void _DTSizeItem::doubleClick() {
|
||||
AlignedTextItem * iatext = qgraphicsitem_cast<AlignedTextItem*>(cur_item);
|
||||
QGraphicsPixmapItem * ipixmap = qgraphicsitem_cast<QGraphicsPixmapItem*>(cur_item);
|
||||
if (itext || iatext) {
|
||||
QMetaObject::invokeMethod(this, "textEditRequest", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, [this](){textEditRequest();}, Qt::QueuedConnection);
|
||||
}
|
||||
if (ipixmap) {
|
||||
QMetaObject::invokeMethod(this, "pixmapEditRequest", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, [this](){pixmapEditRequest();}, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,8 +322,6 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
|
||||
|
||||
DrawTools::~DrawTools() {
|
||||
size_item.assignObject(0);
|
||||
//delete ui;
|
||||
//delete widget_props;
|
||||
}
|
||||
|
||||
|
||||
@@ -381,7 +378,6 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
||||
foreach (QAction * a, actions_add)
|
||||
a->setChecked(false);
|
||||
new_type = -1;
|
||||
//view_->setCursor(Qt::ArrowCursor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -420,7 +416,6 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
||||
if (me->buttons().testFlag(Qt::LeftButton)) {
|
||||
if (new_item) {
|
||||
mr = new_item->mapRectFromScene(QRectF(pp, sp).normalized());
|
||||
//mr = QRectF(pp, sp).normalized();
|
||||
switch (new_type) {
|
||||
case 0:
|
||||
((AlignedTextItem*)new_item)->setPos(sp);
|
||||
@@ -458,7 +453,6 @@ bool DrawTools::eventFilter(QObject * o, QEvent * e) {
|
||||
foreach (QAction * a, actions_add)
|
||||
a->setChecked(false);
|
||||
new_type = -1;
|
||||
//view_->setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -485,15 +479,6 @@ QComboBox * DrawTools::textEditCombo() const {
|
||||
return ui->comboText;
|
||||
}
|
||||
|
||||
/*
|
||||
void DrawTools::changeEvent(QEvent * e) {
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
return;
|
||||
}
|
||||
QObject::changeEvent(e);
|
||||
}
|
||||
*/
|
||||
|
||||
QAction * DrawTools::newAction(const QIcon & icon, int type) {
|
||||
QAction * ret = new QAction(icon, QString(), this);
|
||||
|
||||
@@ -342,7 +342,7 @@ void Graphic::procGesture(QGesture * g) {
|
||||
case Qt::TapAndHoldGesture: {
|
||||
QTapAndHoldGesture * pg = (QTapAndHoldGesture*)g;
|
||||
if (pg->state() == Qt::GestureStarted)
|
||||
QMetaObject::invokeMethod(this, "showMenu", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, [this](){showMenu();}, Qt::QueuedConnection);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user