Skip to content
Snippets Groups Projects
Commit 1e5fe1b1 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

rm obsolete code

parent 7ce5363e
No related branches found
No related tags found
1 merge request!462simplify code; remove test code
......@@ -15,48 +15,22 @@
#include "GUI/View/PropertyEditor/ComponentEditor.h"
#include "GUI/View/PropertyEditor/ComponentFlatView.h"
#include "GUI/View/PropertyEditor/ComponentTreeView.h"
#include "GUI/View/PropertyEditor/GroupInfoBox.h"
#include <QBoxLayout>
#include <QGroupBox>
namespace {
template <typename T> T* createGroupBox(ComponentView* componentView, QString title)
ComponentEditor::ComponentEditor(EditorType editorType) : m_componentView(nullptr), m_item(nullptr)
{
auto* box = new T(title);
auto* boxlayout = new QVBoxLayout;
boxlayout->setContentsMargins(0, 0, 0, 0);
boxlayout->addWidget(componentView);
box->setLayout(boxlayout);
return box;
}
} // namespace
ComponentEditor::ComponentEditor(EditorType editorType, const QString& title)
: m_type(editorType), m_componentView(nullptr), m_item(nullptr), m_title(title)
{
m_componentView = createComponentView();
if (editorType.testFlag(Tree)) {
auto* view = new ComponentTreeView;
view->setShowHeader(editorType.testFlag(T_Header));
view->setShowRootItem(editorType.testFlag(T_Root));
m_componentView = view;
} else
m_componentView = new ComponentFlatView;
auto* mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setMargin(0);
if (m_type.testFlag(GroupLayout)) {
auto* box = createGroupBox<QGroupBox>(m_componentView, title);
mainLayout->addWidget(box);
mainLayout->setMargin(4);
mainLayout->addStretch();
} else if (m_type.testFlag(InfoLayout)) {
auto* box = createGroupBox<GroupInfoBox>(m_componentView, title);
connect(box, &GroupInfoBox::clicked, this, &ComponentEditor::onDialogRequest);
mainLayout->addWidget(box);
mainLayout->setMargin(4);
mainLayout->addStretch();
} else {
mainLayout->addWidget(m_componentView);
}
mainLayout->addWidget(m_componentView);
setLayout(mainLayout);
}
......@@ -79,26 +53,3 @@ void ComponentEditor::addItem(SessionItem* item)
m_item = item;
m_componentView->addItem(item);
}
void ComponentEditor::onDialogRequest()
{
emit dialogRequest(m_item, m_title);
}
ComponentView* ComponentEditor::createComponentView()
{
ComponentView* result(nullptr);
if (m_type.testFlag(Tree)) {
auto* view = new ComponentTreeView;
view->setShowHeader(m_type.testFlag(T_Header));
view->setShowRootItem(m_type.testFlag(T_Root));
result = view;
} else {
auto* view = new ComponentFlatView;
view->setShowChildren(!m_type.testFlag(W_NoChildren));
result = view;
}
return result;
}
......@@ -29,44 +29,27 @@ class ComponentEditor : public QWidget {
public:
enum EditorFlags {
Tree = 0x1000,
Widget = 0x2000,
PlainLayout = 0x0010, // editor embedded in standard box layout
GroupLayout = 0x0020, // editor embedded in QGroupBox
InfoLayout = 0x0040, // editor embedded in GroupInfoBox
T_Header = 0x0100, // to show QTreeView header (Tree mode only)
T_Root = 0x0200, // to show root item (Tree mode only)
W_NoChildren = 0x0400, // show no children (Widget mode only)
T_Header = 0x0100, // to show QTreeView header (Tree mode only)
T_Root = 0x0200, // to show root item (Tree mode only)
FullTree = Tree | PlainLayout | T_Header | T_Root,
HeaderTree = Tree | PlainLayout | T_Header,
MiniTree = Tree | PlainLayout,
PlainWidget = Widget | PlainLayout,
GroupWidget = Widget | GroupLayout,
InfoWidget = Widget | InfoLayout,
};
Q_DECLARE_FLAGS(EditorType, EditorFlags)
ComponentEditor(EditorType editorType = HeaderTree, const QString& title = "");
ComponentEditor(EditorType editorType = HeaderTree);
void setItem(SessionItem* item);
void clearEditor();
void addItem(SessionItem* item);
signals:
void dialogRequest(SessionItem* item, const QString& names);
private slots:
void onDialogRequest();
private:
ComponentView* createComponentView();
EditorType m_type;
ComponentView* m_componentView;
SessionItem* m_item;
QString m_title;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ComponentEditor::EditorType)
......
......@@ -29,11 +29,7 @@
#include <QVBoxLayout>
ComponentFlatView::ComponentFlatView(QWidget* parent)
: ComponentView(parent)
, m_mainLayout(nullptr)
, m_gridLayout(nullptr)
, m_model(nullptr)
, m_show_children(true)
: ComponentView(parent), m_mainLayout(nullptr), m_gridLayout(nullptr), m_model(nullptr)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
......@@ -88,11 +84,6 @@ void ComponentFlatView::clearLayout()
m_widgetItems.clear();
}
void ComponentFlatView::setShowChildren(bool show)
{
m_show_children = show;
}
void ComponentFlatView::onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight,
const QVector<int>& roles)
{
......@@ -127,8 +118,6 @@ void ComponentFlatView::updateItemProperties()
continue;
widget->addToGrid(m_gridLayout, nrow++);
m_widgetItems.push_back(widget);
if (!m_show_children)
break;
}
}
......
......@@ -41,8 +41,6 @@ public:
void clearEditor() override;
void setShowChildren(bool show);
public slots:
void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight,
const QVector<int>& roles);
......@@ -58,7 +56,6 @@ private:
QGridLayout* m_gridLayout;
QVector<PropertyWidgetItem*> m_widgetItems;
SessionModel* m_model;
bool m_show_children;
QVector<const SessionItem*> m_topItems;
};
......
......@@ -35,8 +35,6 @@ class SessionModelView : public QWidget {
public:
SessionModelView(QWidget* parent, ProjectDocument* document);
void setViewActive(bool is_active);
private slots:
void onExpandCollapseTree();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment