修复了本视图拖动bug,修复了视图分割比例bug,修复了兄弟视图颠倒bug
This commit is contained in:
parent
cd6ff24d0e
commit
8458a1a0f3
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.15.0, 2023-08-21T11:28:09. -->
|
<!-- Written by QtCreator 4.15.0, 2023-08-21T22:09:20. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
|
|
@ -78,7 +78,7 @@ void BaseView::setParentRect(SplitRect *pinst) {
|
||||||
|
|
||||||
std::pair<SplitRect *, SplitRect *> BaseView::child() const { return std::make_pair<SplitRect *, SplitRect *>(nullptr, nullptr); }
|
std::pair<SplitRect *, SplitRect *> BaseView::child() const { return std::make_pair<SplitRect *, SplitRect *>(nullptr, nullptr); }
|
||||||
|
|
||||||
void BaseView::replace(SplitRect *view, SplitRect *old) { throw new SimpleException<QString>("异常调用", "不能对ViewBase调用replace函数"); }
|
void BaseView::replaceComp(SplitRect *view, SplitRect *old) { throw new SimpleException<QString>("异常调用", "不能对ViewBase调用replace函数"); }
|
||||||
|
|
||||||
float BaseView::splitterWidth() const { return 0; }
|
float BaseView::splitterWidth() const { return 0; }
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ void BaseView::installPerceptionHandle(ViewPresent *obj) {
|
||||||
|
|
||||||
void BaseView::paintEvent(QPaintEvent *ev) { QWidget::paintEvent(ev); }
|
void BaseView::paintEvent(QPaintEvent *ev) { QWidget::paintEvent(ev); }
|
||||||
|
|
||||||
void BaseView::remove(SplitRect *child_inst) { throw new SimpleException<QString>("非法操作", "BaseView不支持retrieveComp操作"); }
|
void BaseView::removeComp(SplitRect *child_inst) { throw new SimpleException<QString>("非法操作", "BaseView不支持retrieveComp操作"); }
|
||||||
|
|
||||||
AttachPanel::AttachPanel(ViewPresent *host) : QWidget(), size_host(host) {
|
AttachPanel::AttachPanel(ViewPresent *host) : QWidget(), size_host(host) {
|
||||||
setWindowOpacity(50);
|
setWindowOpacity(50);
|
||||||
|
@ -188,41 +188,52 @@ void AttachPanel::dragEnterEvent(QDragEnterEvent *event) {
|
||||||
|
|
||||||
void AttachPanel::dropEvent(QDropEvent *event) {
|
void AttachPanel::dropEvent(QDropEvent *event) {
|
||||||
QWidget::dropEvent(event);
|
QWidget::dropEvent(event);
|
||||||
|
event->acceptProposedAction();
|
||||||
|
|
||||||
auto xsource = size_host->adjustView();
|
auto xsource = size_host->adjustView();
|
||||||
xsource->parentRect()->remove(xsource);
|
|
||||||
auto target = this->attachTarget();
|
auto target = this->attachTarget();
|
||||||
auto ptarget = target->parentRect();
|
|
||||||
|
|
||||||
SplitRect *newsplit = nullptr;
|
if (target != xsource) {
|
||||||
switch (this->active_comp) {
|
SplitRect *newsplit = nullptr;
|
||||||
case ActiveArea::LEFT: {
|
|
||||||
newsplit = new SplitView(xsource, target, size_host);
|
if (xsource->parentRect())
|
||||||
newsplit->setSplitInfo(SplitType::SPLIT_H, target->outline().width() / 2, size_host->splitterWidth());
|
xsource->parentRect()->removeComp(xsource);
|
||||||
} break;
|
|
||||||
case ActiveArea::RIGHT: {
|
auto ptarget = target->parentRect();
|
||||||
newsplit = new SplitView(target, xsource, size_host);
|
auto target_rect = target->outline();
|
||||||
newsplit->setSplitInfo(SplitType::SPLIT_H, target->outline().width() / 2, size_host->splitterWidth());
|
|
||||||
} break;
|
switch (this->active_comp) {
|
||||||
case ActiveArea::TOP: {
|
case ActiveArea::LEFT: {
|
||||||
newsplit = new SplitView(xsource, target, size_host);
|
newsplit = new SplitView(xsource, target, size_host);
|
||||||
newsplit->setSplitInfo(SplitType::SPLIT_V, target->outline().height() / 2, size_host->splitterWidth());
|
newsplit->relayout(target_rect);
|
||||||
} break;
|
newsplit->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, size_host->splitterWidth());
|
||||||
case ActiveArea::BOTTOM: {
|
} break;
|
||||||
newsplit = new SplitView(target, xsource, size_host);
|
case ActiveArea::RIGHT: {
|
||||||
newsplit->setSplitInfo(SplitType::SPLIT_V, target->outline().height() / 2, size_host->splitterWidth());
|
newsplit = new SplitView(target, xsource, size_host);
|
||||||
} break;
|
newsplit->relayout(target_rect);
|
||||||
case ActiveArea::CENTER: {
|
newsplit->setSplitInfo(SplitType::SPLIT_H, target_rect.width() / 2, size_host->splitterWidth());
|
||||||
newsplit = xsource;
|
} break;
|
||||||
} break;
|
case ActiveArea::TOP: {
|
||||||
default:
|
newsplit = new SplitView(xsource, target, size_host);
|
||||||
return;
|
newsplit->relayout(target_rect);
|
||||||
|
newsplit->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, size_host->splitterWidth());
|
||||||
|
} break;
|
||||||
|
case ActiveArea::BOTTOM: {
|
||||||
|
newsplit = new SplitView(target, xsource, size_host);
|
||||||
|
newsplit->relayout(target_rect);
|
||||||
|
newsplit->setSplitInfo(SplitType::SPLIT_V, target_rect.height() / 2, size_host->splitterWidth());
|
||||||
|
} break;
|
||||||
|
case ActiveArea::CENTER: {
|
||||||
|
newsplit = xsource;
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptarget->replaceComp(newsplit, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
ptarget->replace(newsplit, target);
|
|
||||||
this->setVisible(false);
|
this->setVisible(false);
|
||||||
|
|
||||||
event->acceptProposedAction();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<QRectF, QRectF, QRectF, QRectF, QRectF> AttachPanel::view_rects() const {
|
std::tuple<QRectF, QRectF, QRectF, QRectF, QRectF> AttachPanel::view_rects() const {
|
||||||
|
@ -334,7 +345,7 @@ std::pair<SplitRect *, SplitRect *> ViewPresent::child() const {
|
||||||
return std::make_pair(inst0, inst1);
|
return std::make_pair(inst0, inst1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewPresent::replace(SplitRect *view, SplitRect *old) {
|
void ViewPresent::replaceComp(SplitRect *view, SplitRect *old) {
|
||||||
if (!view_anchors.contains(old))
|
if (!view_anchors.contains(old))
|
||||||
throw new SimpleException<QString>("参数错误", "指定替换的界面不属于此界面");
|
throw new SimpleException<QString>("参数错误", "指定替换的界面不属于此界面");
|
||||||
|
|
||||||
|
@ -375,7 +386,7 @@ void ViewPresent::paintEvent(QPaintEvent *ev) {
|
||||||
it->bind()->update();
|
it->bind()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewPresent::remove(SplitRect *child_inst) {
|
void ViewPresent::removeComp(SplitRect *child_inst) {
|
||||||
if (!view_anchors.contains(child_inst))
|
if (!view_anchors.contains(child_inst))
|
||||||
throw new SimpleException<QString>("参数非法", "回收的指定视图不属于本ViewPresent");
|
throw new SimpleException<QString>("参数非法", "回收的指定视图不属于本ViewPresent");
|
||||||
|
|
||||||
|
@ -544,7 +555,7 @@ void SplitView::setSplitInfo(SplitType type, float pos, float width, bool relayo
|
||||||
this->relayout();
|
this->relayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitView::replace(SplitRect *view, SplitRect *old) {
|
void SplitView::replaceComp(SplitRect *view, SplitRect *old) {
|
||||||
if (child_store.contains(old) && !child_store.contains(view)) {
|
if (child_store.contains(old) && !child_store.contains(view)) {
|
||||||
auto index = child_store.indexOf(old);
|
auto index = child_store.indexOf(old);
|
||||||
child_store.replace(index, view);
|
child_store.replace(index, view);
|
||||||
|
@ -560,7 +571,7 @@ void SplitView::relayout(const QRectF &outlinex) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitView::remove(SplitRect *child_inst) {
|
void SplitView::removeComp(SplitRect *child_inst) {
|
||||||
auto pinst = parentRect();
|
auto pinst = parentRect();
|
||||||
|
|
||||||
auto sib = this->child().first;
|
auto sib = this->child().first;
|
||||||
|
@ -568,7 +579,7 @@ void SplitView::remove(SplitRect *child_inst) {
|
||||||
sib = this->child().second;
|
sib = this->child().second;
|
||||||
|
|
||||||
child_inst->bind()->setVisible(false);
|
child_inst->bind()->setVisible(false);
|
||||||
pinst->replace(sib, this);
|
pinst->replaceComp(sib, this);
|
||||||
|
|
||||||
child_inst->setParentRect(nullptr);
|
child_inst->setParentRect(nullptr);
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -731,7 +742,7 @@ DragHeader::DragHeader(BaseView *bind) : QFrame(bind->bind()), icon_store(new QL
|
||||||
|
|
||||||
connect(hide, &QPushButton::clicked, [=]() {
|
connect(hide, &QPushButton::clicked, [=]() {
|
||||||
auto con = this->view_core->parentRect();
|
auto con = this->view_core->parentRect();
|
||||||
con->remove(view_core);
|
con->removeComp(view_core);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(close, &QPushButton::clicked, [=]() {
|
connect(close, &QPushButton::clicked, [=]() {
|
||||||
|
|
|
@ -54,7 +54,8 @@ namespace SplitFrame {
|
||||||
virtual void setParentRect(SplitRect *pinst) = 0;
|
virtual void setParentRect(SplitRect *pinst) = 0;
|
||||||
|
|
||||||
virtual std::pair<SplitRect *, SplitRect *> child() const = 0;
|
virtual std::pair<SplitRect *, SplitRect *> child() const = 0;
|
||||||
virtual void replace(SplitRect *view, SplitRect *old) = 0;
|
virtual void removeComp(SplitRect *child) = 0;
|
||||||
|
virtual void replaceComp(SplitRect *view, SplitRect *old) = 0;
|
||||||
virtual float splitterWidth() const = 0;
|
virtual float splitterWidth() const = 0;
|
||||||
virtual float splitterPos() const = 0;
|
virtual float splitterPos() const = 0;
|
||||||
virtual SplitType splitType() const = 0;
|
virtual SplitType splitType() const = 0;
|
||||||
|
@ -62,7 +63,6 @@ namespace SplitFrame {
|
||||||
|
|
||||||
virtual QRectF outline() const = 0;
|
virtual QRectF outline() const = 0;
|
||||||
virtual void relayout(const QRectF &outline) = 0;
|
virtual void relayout(const QRectF &outline) = 0;
|
||||||
virtual void remove(SplitRect *child) = 0;
|
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent *ev) = 0;
|
virtual void paintEvent(QPaintEvent *ev) = 0;
|
||||||
};
|
};
|
||||||
|
@ -84,11 +84,11 @@ namespace SplitFrame {
|
||||||
virtual float splitterPos() const override;
|
virtual float splitterPos() const override;
|
||||||
virtual SplitType splitType() const override;
|
virtual SplitType splitType() const override;
|
||||||
virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override;
|
virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override;
|
||||||
virtual void replace(SplitRect *view, SplitRect *old) override;
|
virtual void replaceComp(SplitRect *view, SplitRect *old) override;
|
||||||
|
|
||||||
virtual QRectF outline() const override;
|
virtual QRectF outline() const override;
|
||||||
virtual void relayout(const QRectF &outline) override;
|
virtual void relayout(const QRectF &outline) override;
|
||||||
virtual void remove(SplitRect *child_inst) override;
|
virtual void removeComp(SplitRect *child_inst) override;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
|
@ -161,7 +161,7 @@ namespace SplitFrame {
|
||||||
virtual SplitRect *parentRect() const override;
|
virtual SplitRect *parentRect() const override;
|
||||||
virtual void setParentRect(SplitRect *pinst) override;
|
virtual void setParentRect(SplitRect *pinst) override;
|
||||||
virtual std::pair<SplitRect *, SplitRect *> child() const override;
|
virtual std::pair<SplitRect *, SplitRect *> child() const override;
|
||||||
virtual void replace(SplitRect *view, SplitRect *old) override;
|
virtual void replaceComp(SplitRect *view, SplitRect *old) override;
|
||||||
virtual float splitterWidth() const override;
|
virtual float splitterWidth() const override;
|
||||||
virtual float splitterPos() const override;
|
virtual float splitterPos() const override;
|
||||||
virtual SplitType splitType() const override;
|
virtual SplitType splitType() const override;
|
||||||
|
@ -170,7 +170,7 @@ namespace SplitFrame {
|
||||||
virtual void relayout(const QRectF &outline) override;
|
virtual void relayout(const QRectF &outline) override;
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent *ev) override;
|
virtual void paintEvent(QPaintEvent *ev) override;
|
||||||
virtual void remove(SplitRect *child_inst) override;
|
virtual void removeComp(SplitRect *child_inst) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DragHeader *title_header;
|
DragHeader *title_header;
|
||||||
|
@ -214,14 +214,14 @@ namespace SplitFrame {
|
||||||
virtual void setParentRect(SplitRect *pinst) override;
|
virtual void setParentRect(SplitRect *pinst) override;
|
||||||
|
|
||||||
virtual std::pair<SplitRect *, SplitRect *> child() const override;
|
virtual std::pair<SplitRect *, SplitRect *> child() const override;
|
||||||
virtual void replace(SplitRect *view, SplitRect *old) override;
|
virtual void replaceComp(SplitRect *view, SplitRect *old) override;
|
||||||
virtual float splitterWidth() const override;
|
virtual float splitterWidth() const override;
|
||||||
virtual float splitterPos() const override;
|
virtual float splitterPos() const override;
|
||||||
virtual SplitType splitType() const override;
|
virtual SplitType splitType() const override;
|
||||||
virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override;
|
virtual void setSplitInfo(SplitType type, float pos, float width, bool relayout) override;
|
||||||
virtual QRectF outline() const override;
|
virtual QRectF outline() const override;
|
||||||
virtual void relayout(const QRectF &outline) override;
|
virtual void relayout(const QRectF &outline) override;
|
||||||
virtual void remove(SplitRect *child_inst) override;
|
virtual void removeComp(SplitRect *child_inst) override;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue