save
This commit is contained in:
parent
a97829ddd2
commit
3fbef9cd4e
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.15.0, 2023-12-29T18:05:56. -->
|
||||
<!-- Written by QtCreator 4.15.0, 2024-01-21T09:38:32. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#include "baseview.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDrag>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace base_view;
|
||||
|
||||
BaseView::BaseView(bool replace, bool retrieve, bool close) : QWidget(nullptr), m_replace(replace), m_retrieve(retrieve), m_close(close) {}
|
||||
|
||||
void BaseView::setParent(ViewRes *pinst) { this->parent_res = pinst; }
|
||||
|
||||
split_frame::ResManager *BaseView::splitManager() const {
|
||||
if(this->parent_res)
|
||||
return this->parent_res->splitManager();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
split_frame::ViewRes *BaseView::parentRes() const { return this->parent_res; }
|
||||
|
||||
QWidget *BaseView::widget() const { return const_cast<BaseView *>(this); }
|
||||
|
||||
bool BaseView::canRetrieve() const { return m_retrieve; }
|
||||
|
||||
bool BaseView::canClose() const { return m_close; }
|
||||
|
||||
bool BaseView::canReplace() const { return m_replace; }
|
||||
|
||||
QIcon BaseView::icon() const { return QWidget::windowIcon(); }
|
||||
|
||||
QString BaseView::title() const { return QWidget::windowTitle(); }
|
||||
|
||||
QSizeF BaseView::viewSize() const { return this->size(); }
|
||||
|
||||
void BaseView::resizeView(const QSizeF &outline) { QWidget::resize(outline.toSize()); }
|
||||
|
||||
DragHeader::DragHeader(BaseView *bind) : QLabel(bind->widget()), view_core(bind) {}
|
|
@ -0,0 +1,40 @@
|
|||
#include "dockpanel.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDrag>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace base_view;
|
||||
|
||||
split_frame::ResManager *DockPanel::splitManager() const {
|
||||
if(this->parent_res)
|
||||
return this->parent_res->splitManager();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
split_frame::ViewRes *DockPanel::parentRes() const { return this->parent_res; }
|
||||
|
||||
QWidget *DockPanel::widget() const { return const_cast<DockPanel *>(this); }
|
||||
|
||||
bool DockPanel::canRetrieve() const { return m_retrieve; }
|
||||
|
||||
bool DockPanel::canClose() const { return m_close; }
|
||||
|
||||
bool DockPanel::canReplace() const { return m_replace; }
|
||||
|
||||
QIcon DockPanel::icon() const { return QWidget::windowIcon(); }
|
||||
|
||||
QString DockPanel::title() const { return QWidget::windowTitle(); }
|
||||
|
||||
QSizeF DockPanel::viewSize() const { return this->size(); }
|
||||
|
||||
void DockPanel::resizeView(const QSizeF &outline) { QWidget::resize(outline.toSize()); }
|
||||
|
||||
DragHeader::DragHeader(const QString &title, DockPanel *bind_core) : QFrame(bind_core->widget()) {
|
||||
setWindowTitle(title);
|
||||
|
||||
}
|
|
@ -8,17 +8,18 @@
|
|||
#include <QString>
|
||||
|
||||
namespace base_view {
|
||||
class BaseView;
|
||||
class DockPanel;
|
||||
|
||||
/**
|
||||
* @brief 视图拖拽标题栏
|
||||
*/
|
||||
class SPLITVIEW_EXPORT DragHeader : public QLabel {
|
||||
class SPLITVIEW_EXPORT DragHeader : public QFrame {
|
||||
public:
|
||||
DragHeader(BaseView *bind);
|
||||
DragHeader(const QString &title, DockPanel *bind_core);
|
||||
DragHeader(const QString &title, const QIcon &icon, DockPanel *bind_core);
|
||||
|
||||
private:
|
||||
BaseView *view_core;
|
||||
DockPanel *bind_core;
|
||||
std::tuple<bool, QPointF> press_flag = std::make_tuple(false, QPointF());
|
||||
|
||||
// QWidget interface
|
||||
|
@ -31,17 +32,26 @@ namespace base_view {
|
|||
/**
|
||||
* @brief 基础内容视图组件
|
||||
*/
|
||||
class SPLITVIEW_EXPORT BaseView : public QWidget, public split_frame::ViewBase {
|
||||
class SPLITVIEW_EXPORT DockPanel : public QWidget, public split_frame::ViewBase {
|
||||
signals:
|
||||
void close_request(QWidget*);
|
||||
void adjust_request(QWidget*);
|
||||
void retrieve_request(QWidget*);
|
||||
|
||||
public:
|
||||
BaseView(bool replace, bool retrieve, bool close);
|
||||
DockPanel(const QString &title, QWidget *present, bool custom_header = false);
|
||||
|
||||
void setParent(ViewRes *pinst);
|
||||
void setModify(bool replace, bool close, bool retrieve);
|
||||
|
||||
private:
|
||||
ViewRes *parent_res = nullptr;
|
||||
bool m_replace = false, m_retrieve = false, m_close = false;
|
||||
|
||||
// ViewRes interface
|
||||
public:
|
||||
virtual split_frame::ResManager *splitManager() const override;
|
||||
virtual split_frame::ViewRes *parentRes() const override;
|
||||
virtual void setParentRes(ViewRes *inst) override;
|
||||
virtual QWidget *widget() const override;
|
||||
virtual bool canRetrieve() const override;
|
||||
virtual bool canClose() const override;
|
||||
|
@ -53,10 +63,6 @@ namespace base_view {
|
|||
virtual QString title() const override;
|
||||
virtual QSizeF viewSize() const override;
|
||||
virtual void resizeView(const QSizeF &outline) override;
|
||||
|
||||
private:
|
||||
ViewRes *parent_res = nullptr;
|
||||
bool m_replace = false, m_retrieve = false, m_close = false;
|
||||
};
|
||||
} // namespace SplitFrame
|
||||
|
|
@ -15,12 +15,12 @@ msvc{
|
|||
}
|
||||
|
||||
SOURCES += \
|
||||
baseview.cpp \
|
||||
dockpanel.cpp \
|
||||
splitpanel.cpp \
|
||||
splitwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
baseview.h \
|
||||
dockpanel.h \
|
||||
splitpanel.h \
|
||||
splitview_interface.h \
|
||||
splitwindow.h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "splitpanel.h"
|
||||
#include "baseview.h"
|
||||
#include "dockpanel.h"
|
||||
#include <QPainter>
|
||||
#include <libConfig.h>
|
||||
|
||||
|
@ -10,7 +10,8 @@ using namespace Config;
|
|||
SplitPanel::SplitPanel(ViewBase *first, ViewBase *next, ViewRes *parent)
|
||||
: QWidget(parent->widget()), parent_inst(parent)
|
||||
{
|
||||
this->split_member = std::make_tuple(first, next, SplitType::SPLIT_H);
|
||||
this->split_member = std::make_tuple(first, next);
|
||||
this->split_info_value = std::make_tuple(SplitType::SPLIT_H, 0.5, 8);
|
||||
}
|
||||
|
||||
SplitPanel::~SplitPanel()
|
||||
|
@ -96,7 +97,7 @@ void SplitPanel::resizeView(const QSizeF &outline)
|
|||
|
||||
std::tuple<ViewBase *, ViewBase *, SplitType> SplitPanel::child() const
|
||||
{
|
||||
return this->split_member;
|
||||
return std::make_tuple(std::get<0>(split_member), std::get<1>(split_member), std::get<0>(split_info_value));
|
||||
}
|
||||
|
||||
void SplitPanel::replaceComp(ViewBase *view, ViewBase *old)
|
||||
|
@ -105,14 +106,15 @@ void SplitPanel::replaceComp(ViewBase *view, ViewBase *old)
|
|||
|
||||
if(!mbrs.contains(view) && mbrs.contains(old)){
|
||||
if(std::get<1>(split_member) == old){
|
||||
this->split_member = std::make_tuple(std::get<0>(split_member), view, std::get<2>(split_member));
|
||||
this->split_member = std::make_tuple(std::get<0>(split_member), view);
|
||||
}
|
||||
else if(std::get<0>(split_member) == old){
|
||||
this->split_member = std::make_tuple(view, std::get<1>(split_member), std::get<2>(split_member));
|
||||
this->split_member = std::make_tuple(view, std::get<1>(split_member));
|
||||
}
|
||||
|
||||
old->widget()->setParent(nullptr);
|
||||
view->setParentRes(this);
|
||||
view->widget()->setParent(this);
|
||||
old->widget()->setParent(nullptr);
|
||||
this->resizeView(this->viewSize());
|
||||
}
|
||||
}
|
||||
|
@ -124,13 +126,12 @@ float SplitPanel::splitterWidth() const
|
|||
|
||||
float SplitPanel::splitterPos() const
|
||||
{
|
||||
return std::get<0>(split_info_value);
|
||||
return std::get<1>(split_info_value);
|
||||
}
|
||||
|
||||
void SplitPanel::setSplitInfo(split_frame::SplitType type, float pos, float width)
|
||||
{
|
||||
this->split_member = std::make_tuple(std::get<0>(split_member), std::get<1>(split_member), type);
|
||||
this->split_info_value = std::make_tuple(pos, width);
|
||||
this->split_info_value = std::make_tuple(type, pos, width);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ namespace split_panel {
|
|||
|
||||
private:
|
||||
ViewRes *parent_inst;
|
||||
std::tuple<split_frame::ViewBase*, split_frame::ViewBase*, split_frame::SplitType> split_member;
|
||||
std::tuple<split_frame::ViewBase*, split_frame::ViewBase*> split_member;
|
||||
// type, pos, width
|
||||
std::tuple<split_pos, split_width> split_info_value;
|
||||
std::tuple<split_frame::SplitType, split_pos, split_width> split_info_value;
|
||||
|
||||
QList<split_frame::ViewBase*> view_list() const;
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace split_frame {
|
|||
* @return
|
||||
*/
|
||||
virtual ViewRes *parentRes() const = 0;
|
||||
virtual void setParentRes(ViewRes *inst) = 0;
|
||||
|
||||
/**
|
||||
* @brief 视图组件
|
||||
|
@ -102,17 +103,26 @@ namespace split_frame {
|
|||
public:
|
||||
virtual ~SplitView() = default;
|
||||
|
||||
/**
|
||||
* @brief 获取子视图列表和分割方式
|
||||
* @return
|
||||
*/
|
||||
virtual std::tuple<ViewBase *, ViewBase *, SplitType> child() const = 0;
|
||||
/**
|
||||
* @brief 替换子视图
|
||||
* @param view
|
||||
* @param old
|
||||
*/
|
||||
virtual void replaceComp(ViewBase *view, ViewBase *old) = 0;
|
||||
|
||||
/**
|
||||
* @brief 设置分割信息
|
||||
* @param type
|
||||
* @param pos
|
||||
* @param width
|
||||
*/
|
||||
virtual void setSplitInfo(SplitType type, float pos, float width) = 0;
|
||||
|
||||
/**
|
||||
* @brief 获取子视图列表和分割方式
|
||||
* @return
|
||||
*/
|
||||
virtual std::tuple<ViewBase *, ViewBase *, SplitType> child() const = 0;
|
||||
/**
|
||||
* @brief 分隔符的宽度
|
||||
* @return
|
||||
|
@ -123,14 +133,6 @@ namespace split_frame {
|
|||
* @return
|
||||
*/
|
||||
virtual float splitterPos() const = 0;
|
||||
|
||||
/**
|
||||
* @brief 设置分割信息
|
||||
* @param type
|
||||
* @param pos
|
||||
* @param width
|
||||
*/
|
||||
virtual void setSplitInfo(SplitType type, float pos, float width) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -161,8 +163,16 @@ namespace split_frame {
|
|||
virtual void addListener(FreedomViewsListener *lsn) = 0;
|
||||
virtual void removeListener(FreedomViewsListener *lsn) = 0;
|
||||
|
||||
virtual void setAdjustView(ViewBase *inst) = 0;
|
||||
virtual ViewBase* adjustView() const = 0;
|
||||
/**
|
||||
* @brief 在系统中移除指定视图
|
||||
* @param inst
|
||||
*/
|
||||
virtual void removePresentView(ViewBase *inst) = 0;
|
||||
/**
|
||||
* @brief 在系统中添加指定视图
|
||||
* @param inst
|
||||
*/
|
||||
virtual void appendPresentView(ViewBase *inst) = 0;
|
||||
|
||||
/**
|
||||
* @brief 回收视图显示,转换视图为自由(闲置)状态
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "splitwindow.h"
|
||||
#include "baseview.h"
|
||||
#include "dockpanel.h"
|
||||
#include "splitpanel.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <QStackedWidget>
|
||||
#include <QStyle>
|
||||
#include <QToolBar>
|
||||
#include <baseview.h>
|
||||
#include <dockpanel.h>
|
||||
#include <splitwindow.h>
|
||||
#include <splitpanel.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue