logic/ui: added CompositeView for combining Views to one DockWidget
Added CompositView, which implements both View and ViewLayout, for combining Views to one Widget. The layout can be set to either horizontal or vertical. SearchView, RefreshView and UndoRedoView are combined to one DockWidget by the ComponentManager now. fortune cookie message = You'll get more secure and confident with your relationship with your co-workers.
This commit is contained in:
@@ -14,13 +14,17 @@ QPushButton:hover, QPushButton:checked {
|
||||
background: #B2B2B2;
|
||||
}
|
||||
|
||||
QPushButton#refresh_button {
|
||||
QPushButton:pressed {
|
||||
background: #626262;
|
||||
}
|
||||
|
||||
#refresh_button {
|
||||
border-bottom-left-radius: 12px;
|
||||
border-top-left-radius: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
QPushButton#auto_refresh_button {
|
||||
#auto_refresh_button {
|
||||
border-bottom-right-radius: 12px;
|
||||
border-top-right-radius: 12px;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ QPushButton#search_button {
|
||||
background: #B2B2B2;
|
||||
}
|
||||
|
||||
#search_button:pressed {
|
||||
background: #626262;
|
||||
}
|
||||
|
||||
/*QPushButton#case_sensitive_button {
|
||||
border: none;
|
||||
border-image: url(data/gui/search_view/images/button_case_sensitive_inactive.png);
|
||||
|
||||
@@ -13,6 +13,7 @@ QPushButton {
|
||||
#undo_button {
|
||||
border-bottom-left-radius: 12px;
|
||||
border-top-left-radius: 12px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
#redo_button {
|
||||
@@ -20,18 +21,15 @@ QPushButton {
|
||||
border-top-right-radius: 12px;
|
||||
}
|
||||
|
||||
#undo_button:disabled,
|
||||
#redo_button:disabled {
|
||||
QPushButton:disabled {
|
||||
background: #F4F4F4;
|
||||
}
|
||||
|
||||
#undo_button:hover,
|
||||
#redo_button:hover {
|
||||
QPushButton:hover {
|
||||
background: #B2B2B2;
|
||||
}
|
||||
|
||||
#undo_button:pressed,
|
||||
#redo_button:pressed {
|
||||
QPushButton:pressed {
|
||||
background: #626262;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ add_files(
|
||||
|
||||
qt/view/QtCodeView.cpp
|
||||
qt/view/QtCodeView.h
|
||||
qt/view/QtCompositeView.cpp
|
||||
qt/view/QtCompositeView.h
|
||||
qt/view/QtGraphView.cpp
|
||||
qt/view/QtGraphView.h
|
||||
qt/view/QtMainView.cpp
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageFind.h"
|
||||
@@ -270,7 +271,18 @@ QDockWidget* QtMainWindow::getDockWidgetForView(View* view) const
|
||||
{
|
||||
for (size_t i = 0; i < m_dockWidgets.size(); i++)
|
||||
{
|
||||
if (m_dockWidgets[i].first == view)
|
||||
CompositeView* compositeView = dynamic_cast<CompositeView*>(m_dockWidgets[i].first);
|
||||
if (compositeView)
|
||||
{
|
||||
for (View* v : compositeView->getViews())
|
||||
{
|
||||
if (v == view)
|
||||
{
|
||||
return m_dockWidgets[i].second;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_dockWidgets[i].first == view)
|
||||
{
|
||||
return m_dockWidgets[i].second;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
|
||||
QDockWidget* getDockWidgetForView(View* view) const;
|
||||
|
||||
std::vector<std::pair<View*, QDockWidget*> > m_dockWidgets;
|
||||
std::vector<std::pair<View*, QDockWidget*>> m_dockWidgets;
|
||||
};
|
||||
|
||||
#endif // QT_MAIN_WINDOW_H
|
||||
|
||||
@@ -12,6 +12,7 @@ QtRefreshBar::QtRefreshBar()
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
@@ -20,7 +21,6 @@ QtRefreshBar::QtRefreshBar()
|
||||
m_refreshButton->setToolTip("refresh");
|
||||
m_refreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_refreshButton->setIcon(QIcon("data/gui/refresh_view/images/refresh.png"));
|
||||
m_refreshButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
layout->addWidget(m_refreshButton);
|
||||
|
||||
m_autoRefreshButton = new QPushButton(this);
|
||||
@@ -29,7 +29,6 @@ QtRefreshBar::QtRefreshBar()
|
||||
m_autoRefreshButton->setToolTip("automatic refresh on window focus");
|
||||
m_autoRefreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_autoRefreshButton->setIcon(QIcon("data/gui/refresh_view/images/auto_refresh.png"));
|
||||
m_autoRefreshButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
layout->addWidget(m_autoRefreshButton);
|
||||
|
||||
connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(refreshClicked()));
|
||||
@@ -40,11 +39,6 @@ QtRefreshBar::~QtRefreshBar()
|
||||
{
|
||||
}
|
||||
|
||||
QSize QtRefreshBar::sizeHint() const
|
||||
{
|
||||
return QSize(150, 100);
|
||||
}
|
||||
|
||||
void QtRefreshBar::refreshClicked()
|
||||
{
|
||||
MessageRefresh().dispatch();
|
||||
|
||||
@@ -14,8 +14,6 @@ public:
|
||||
QtRefreshBar();
|
||||
virtual ~QtRefreshBar();
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
private slots:
|
||||
void refreshClicked();
|
||||
void autoRefreshClicked();
|
||||
|
||||
@@ -12,6 +12,7 @@ QtSearchBar::QtSearchBar()
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
@@ -29,6 +30,7 @@ QtSearchBar::QtSearchBar()
|
||||
m_searchBox->setObjectName("search_box");
|
||||
m_searchBox->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_searchBox->setAttribute(Qt::WA_MacShowFocusRect, 0); // remove blue focus box on Mac
|
||||
m_searchBox->setMinimumWidth(100);
|
||||
m_searchBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
innerLayout->addWidget(m_searchBox);
|
||||
|
||||
|
||||
@@ -25,12 +25,11 @@ QtUndoRedo::QtUndoRedo()
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
layout->addWidget(m_undoButton);
|
||||
layout->addSpacing(2);
|
||||
layout->addWidget(m_redoButton);
|
||||
layout->addStretch();
|
||||
|
||||
connect(m_undoButton, SIGNAL(clicked()), this, SLOT(undo()));
|
||||
connect(m_redoButton, SIGNAL(clicked()), this, SLOT(redo()));
|
||||
|
||||
@@ -13,7 +13,8 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||
, m_showCodeSnippetsFunctor(std::bind(&QtCodeView::doShowCodeSnippets, this, std::placeholders::_1))
|
||||
, m_showCodeFileFunctor(std::bind(&QtCodeView::doShowCodeFile, this, std::placeholders::_1))
|
||||
{
|
||||
m_widget = createQtCodeFileList();
|
||||
m_widget = new QtCodeFileList();
|
||||
setStyleSheet(m_widget);
|
||||
}
|
||||
|
||||
QtCodeView::~QtCodeView()
|
||||
@@ -56,7 +57,7 @@ void QtCodeView::showCodeFile(const CodeSnippetParams& params)
|
||||
|
||||
void QtCodeView::doRefreshView()
|
||||
{
|
||||
setStyleSheet(m_widget.get());
|
||||
setStyleSheet(m_widget);
|
||||
|
||||
clearClosedWindows();
|
||||
for (std::shared_ptr<QtCodeFileList> window: m_windows)
|
||||
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
QtThreadedFunctor<const std::vector<CodeSnippetParams>&> m_showCodeSnippetsFunctor;
|
||||
QtThreadedFunctor<const CodeSnippetParams&> m_showCodeFileFunctor;
|
||||
|
||||
std::shared_ptr<QtCodeFileList> m_widget;
|
||||
QtCodeFileList* m_widget;
|
||||
std::vector<std::shared_ptr<QtCodeFileList>> m_windows;
|
||||
|
||||
std::vector<Id> m_activeTokenIds;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "qt/view/QtCompositeView.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
|
||||
QtCompositeView::QtCompositeView(ViewLayout* viewLayout, CompositeDirection direction)
|
||||
: CompositeView(viewLayout, direction)
|
||||
{
|
||||
QBoxLayout* layout;
|
||||
if (getDirection() == CompositeView::DIRECTION_HORIZONTAL)
|
||||
{
|
||||
layout = new QHBoxLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
layout = new QVBoxLayout();
|
||||
}
|
||||
|
||||
layout->setSpacing(5);
|
||||
layout->setContentsMargins(5, 5, 5, 5);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_widget = new QWidget();
|
||||
m_widget->setLayout(layout);
|
||||
utility::setWidgetBackgroundColor(m_widget, Colori(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
QtCompositeView::~QtCompositeView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtCompositeView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtCompositeView::initView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtCompositeView::refreshView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtCompositeView::addViewWidget(View* view)
|
||||
{
|
||||
m_widget->layout()->addWidget(QtViewWidgetWrapper::getWidgetOfView(view));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef QT_COMPOSITE_VIEW
|
||||
#define QT_COMPOSITE_VIEW
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "component/view/CompositeView.h"
|
||||
|
||||
class QtCompositeView
|
||||
: public CompositeView
|
||||
{
|
||||
public:
|
||||
QtCompositeView(ViewLayout* viewLayout, CompositeDirection direction);
|
||||
~QtCompositeView();
|
||||
|
||||
// View implementation
|
||||
virtual void createWidgetWrapper();
|
||||
virtual void initView();
|
||||
virtual void refreshView();
|
||||
|
||||
// CompositeView implementation
|
||||
virtual void addViewWidget(View* view);
|
||||
|
||||
private:
|
||||
QWidget* m_widget;
|
||||
};
|
||||
|
||||
#endif // QT_COMPOSITE_VIEW
|
||||
@@ -29,7 +29,7 @@ QtGraphView::~QtGraphView()
|
||||
|
||||
void QtGraphView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(std::make_shared<QFrame>()));
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(new QFrame()));
|
||||
}
|
||||
|
||||
void QtGraphView::initView()
|
||||
|
||||
@@ -8,7 +8,7 @@ QtRefreshView::QtRefreshView(ViewLayout* viewLayout)
|
||||
: RefreshView(viewLayout)
|
||||
, m_refreshViewFunctor(std::bind(&QtRefreshView::doRefreshView, this))
|
||||
{
|
||||
m_widget = std::make_shared<QtRefreshBar>();
|
||||
m_widget = new QtRefreshBar();
|
||||
setStyleSheet();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ private:
|
||||
|
||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||
|
||||
std::shared_ptr<QtRefreshBar> m_widget;
|
||||
QtRefreshBar* m_widget;
|
||||
};
|
||||
|
||||
# endif // QT_REFRESH_VIEW_H
|
||||
|
||||
@@ -11,7 +11,7 @@ QtSearchView::QtSearchView(ViewLayout* viewLayout)
|
||||
, m_setFocusFunctor(std::bind(&QtSearchView::doSetFocus, this))
|
||||
, m_setAutocompletionListFunctor(std::bind(&QtSearchView::doSetAutocompletionList, this, std::placeholders::_1))
|
||||
{
|
||||
m_widget = std::make_shared<QtSearchBar>();
|
||||
m_widget = new QtSearchBar();
|
||||
setStyleSheet();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
QtThreadedFunctor<> m_setFocusFunctor;
|
||||
QtThreadedFunctor<const std::vector<SearchMatch>&> m_setAutocompletionListFunctor;
|
||||
|
||||
std::shared_ptr<QtSearchBar> m_widget;
|
||||
QtSearchBar* m_widget;
|
||||
};
|
||||
|
||||
# endif // QT_SEARCH_VIEW_H
|
||||
|
||||
@@ -9,7 +9,7 @@ QtUndoRedoView::QtUndoRedoView(ViewLayout* viewLayout)
|
||||
, m_setRedoButtonEnabledFunctor(std::bind(&QtUndoRedoView::doSetRedoButtonEnabled, this, std::placeholders::_1))
|
||||
, m_setUndoButtonEnabledFunctor(std::bind(&QtUndoRedoView::doSetUndoButtonEnabled, this, std::placeholders::_1))
|
||||
{
|
||||
m_widget = std::make_shared<QtUndoRedo>();
|
||||
m_widget = new QtUndoRedo();
|
||||
setStyleSheet();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
QtThreadedFunctor<bool> m_setUndoButtonEnabledFunctor;
|
||||
|
||||
void setStyleSheet();
|
||||
std::shared_ptr<QtUndoRedo> m_widget;
|
||||
QtUndoRedo* m_widget;
|
||||
};
|
||||
|
||||
#endif // !QT_UNDO_REDO_VIEW_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "qt/view/QtViewFactory.h"
|
||||
|
||||
#include "qt/view/QtCodeView.h"
|
||||
#include "qt/view/QtCompositeView.h"
|
||||
#include "qt/view/QtGraphView.h"
|
||||
#include "qt/view/QtMainView.h"
|
||||
#include "qt/view/QtRefreshView.h"
|
||||
@@ -21,32 +22,41 @@ std::shared_ptr<MainView> QtViewFactory::createMainView() const
|
||||
return std::make_shared<QtMainView>();
|
||||
}
|
||||
|
||||
std::shared_ptr<CompositeView> QtViewFactory::createCompositeView(
|
||||
ViewLayout* viewLayout, CompositeView::CompositeDirection direction
|
||||
) const {
|
||||
std::shared_ptr<CompositeView> ptr = std::make_shared<QtCompositeView>(viewLayout, direction);
|
||||
ptr->init();
|
||||
ptr->addToLayout();
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<CodeView> QtViewFactory::createCodeView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::create<QtCodeView>(viewLayout);
|
||||
return View::createInitAndAddToLayout<QtCodeView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<GraphView> QtViewFactory::createGraphView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::create<QtGraphView>(viewLayout);
|
||||
return View::createInitAndAddToLayout<QtGraphView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<RefreshView> QtViewFactory::createRefreshView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::create<QtRefreshView>(viewLayout);
|
||||
return View::createInitAndAddToLayout<QtRefreshView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<SearchView> QtViewFactory::createSearchView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::create<QtSearchView>(viewLayout);
|
||||
return View::createInitAndAddToLayout<QtSearchView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<StatusBarView> QtViewFactory::createStatusBarView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createAndDontAddToLayout<QtStatusBarView>(viewLayout);
|
||||
return View::createAndInit<QtStatusBarView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<UndoRedoView> QtViewFactory::createUndoRedoView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::create<QtUndoRedoView>(viewLayout);
|
||||
return View::createInitAndAddToLayout<QtUndoRedoView>(viewLayout);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ public:
|
||||
virtual ~QtViewFactory();
|
||||
|
||||
virtual std::shared_ptr<MainView> createMainView() const;
|
||||
virtual std::shared_ptr<CompositeView> createCompositeView(
|
||||
ViewLayout* viewLayout, CompositeView::CompositeDirection direction) const;
|
||||
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const;
|
||||
|
||||
@@ -22,7 +22,7 @@ QWidget* QtViewWidgetWrapper::getWidgetOfView(const View* view)
|
||||
return widgetWrapper->getWidget();
|
||||
}
|
||||
|
||||
QtViewWidgetWrapper::QtViewWidgetWrapper(std::shared_ptr<QWidget> widget)
|
||||
QtViewWidgetWrapper::QtViewWidgetWrapper(QWidget* widget)
|
||||
: m_widget(widget)
|
||||
{
|
||||
}
|
||||
@@ -33,5 +33,5 @@ QtViewWidgetWrapper::~QtViewWidgetWrapper()
|
||||
|
||||
QWidget* QtViewWidgetWrapper::getWidget()
|
||||
{
|
||||
return m_widget.get();
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef QT_VIEW_WIDGET_WRAPPER_H
|
||||
#define QT_VIEW_WIDGET_WRAPPER_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "component/view/ViewWidgetWrapper.h"
|
||||
@@ -14,13 +12,13 @@ class QtViewWidgetWrapper: public ViewWidgetWrapper
|
||||
public:
|
||||
static QWidget* getWidgetOfView(const View* view);
|
||||
|
||||
QtViewWidgetWrapper(std::shared_ptr<QWidget> widget);
|
||||
QtViewWidgetWrapper(QWidget* widget);
|
||||
virtual ~QtViewWidgetWrapper();
|
||||
|
||||
QWidget* getWidget();
|
||||
|
||||
private:
|
||||
std::shared_ptr<QWidget> m_widget;
|
||||
QWidget* m_widget;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_WIDGET_WRAPPER_H
|
||||
|
||||
@@ -18,11 +18,11 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
|
||||
ptr->m_graphAccessProxy = std::make_shared<GraphAccessProxy>();
|
||||
ptr->m_locationAccessProxy = std::make_shared<LocationAccessProxy>();
|
||||
|
||||
ptr->m_mainView = viewFactory->createMainView();
|
||||
ptr->m_componentManager = ComponentManager::create(
|
||||
viewFactory, ptr->m_mainView.get(), ptr->m_graphAccessProxy.get(), ptr->m_locationAccessProxy.get());
|
||||
viewFactory, ptr->m_graphAccessProxy.get(), ptr->m_locationAccessProxy.get());
|
||||
|
||||
ptr->m_componentManager->setup();
|
||||
ptr->m_mainView = viewFactory->createMainView();
|
||||
ptr->m_componentManager->setup(ptr->m_mainView.get());
|
||||
ptr->m_mainView->loadLayout();
|
||||
|
||||
MessageLoadProject("data/ProjectSettings.xml").dispatch();
|
||||
|
||||
@@ -48,6 +48,8 @@ add_files(
|
||||
|
||||
component/view/CodeView.cpp
|
||||
component/view/CodeView.h
|
||||
component/view/CompositeView.cpp
|
||||
component/view/CompositeView.h
|
||||
component/view/GraphView.cpp
|
||||
component/view/GraphView.h
|
||||
component/view/MainView.cpp
|
||||
|
||||
@@ -36,5 +36,4 @@ ViewType* Component::getView() const
|
||||
return dynamic_cast<ViewType*>(m_view.get());
|
||||
}
|
||||
|
||||
|
||||
#endif // COMPONENT_H
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#include "component/view/StatusBarView.h"
|
||||
#include "component/view/UndoRedoView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
std::shared_ptr<ComponentFactory> ComponentFactory::create(
|
||||
ViewFactory* viewFactory, ViewLayout* viewLayout, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
ViewFactory* viewFactory, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
){
|
||||
std::shared_ptr<ComponentFactory> ptr(new ComponentFactory());
|
||||
|
||||
ptr->m_viewFactory = viewFactory;
|
||||
ptr->m_viewLayout = viewLayout;
|
||||
ptr->m_graphAccess = graphAccess;
|
||||
ptr->m_locationAccess = locationAccess;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -31,61 +31,59 @@ ComponentFactory::~ComponentFactory()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createCodeComponent()
|
||||
ViewFactory* ComponentFactory::getViewFactory() const
|
||||
{
|
||||
std::shared_ptr<CodeView> view = m_viewFactory->createCodeView(m_viewLayout);
|
||||
return m_viewFactory;
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createCodeComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<CodeView> view = m_viewFactory->createCodeView(viewLayout);
|
||||
std::shared_ptr<CodeController> controller = std::make_shared<CodeController>(m_graphAccess, m_locationAccess);
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createGraphComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createGraphComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<View> view = m_viewFactory->createGraphView(m_viewLayout);
|
||||
std::shared_ptr<View> view = m_viewFactory->createGraphView(viewLayout);
|
||||
std::shared_ptr<GraphController> controller = std::make_shared<GraphController>(m_graphAccess);
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createRefreshComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createRefreshComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<View> view = m_viewFactory->createRefreshView(m_viewLayout);
|
||||
std::shared_ptr<View> view = m_viewFactory->createRefreshView(viewLayout);
|
||||
std::shared_ptr<RefreshController> controller = std::make_shared<RefreshController>();
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createSearchComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createSearchComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<SearchView> view = m_viewFactory->createSearchView(m_viewLayout);
|
||||
std::shared_ptr<SearchView> view = m_viewFactory->createSearchView(viewLayout);
|
||||
std::shared_ptr<SearchController> controller = std::make_shared<SearchController>(m_graphAccess);
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createUndoRedoComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createUndoRedoComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<UndoRedoView> view = m_viewFactory->createUndoRedoView(m_viewLayout);
|
||||
std::shared_ptr<UndoRedoView> view = m_viewFactory->createUndoRedoView(viewLayout);
|
||||
std::shared_ptr<UndoRedoController> controller = std::make_shared<UndoRedoController>();
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createStatusBarComponent()
|
||||
std::shared_ptr<Component> ComponentFactory::createStatusBarComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<StatusBarView> view = m_viewFactory->createStatusBarView(m_viewLayout);
|
||||
std::shared_ptr<StatusBarView> view = m_viewFactory->createStatusBarView(viewLayout);
|
||||
std::shared_ptr<StatusBarController> controller = std::make_shared<StatusBarController>();
|
||||
|
||||
std::shared_ptr<Component> component = std::make_shared<Component>(view,controller);
|
||||
return component;
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
ComponentFactory::ComponentFactory()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,28 +14,28 @@ class ComponentFactory
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ComponentFactory> create(
|
||||
ViewFactory* viewFactory, ViewLayout* viewLayout, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
ViewFactory* viewFactory, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
);
|
||||
|
||||
~ComponentFactory();
|
||||
|
||||
std::shared_ptr<Component> createCodeComponent();
|
||||
std::shared_ptr<Component> createGraphComponent();
|
||||
std::shared_ptr<Component> createRefreshComponent();
|
||||
std::shared_ptr<Component> createSearchComponent();
|
||||
std::shared_ptr<Component> createStatusBarComponent();
|
||||
std::shared_ptr<Component> createUndoRedoComponent();
|
||||
ViewFactory* getViewFactory() const;
|
||||
|
||||
std::shared_ptr<Component> createCodeComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createGraphComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createRefreshComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createSearchComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createStatusBarComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createUndoRedoComponent(ViewLayout* viewLayout);
|
||||
|
||||
private:
|
||||
ComponentFactory();
|
||||
ComponentFactory(const ComponentFactory&);
|
||||
|
||||
ViewFactory* m_viewFactory;
|
||||
ViewLayout* m_viewLayout;
|
||||
|
||||
GraphAccess* m_graphAccess;
|
||||
LocationAccess* m_locationAccess;
|
||||
};
|
||||
|
||||
|
||||
#endif // COMPONENT_FACTORY_H
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
#include "component/ComponentManager.h"
|
||||
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/RefreshView.h"
|
||||
#include "component/view/SearchView.h"
|
||||
#include "component/view/UndoRedoView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
|
||||
std::shared_ptr<ComponentManager> ComponentManager::create(
|
||||
ViewFactory* viewFactory, ViewLayout* viewLayout, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
ViewFactory* viewFactory, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
){
|
||||
std::shared_ptr<ComponentManager> ptr(new ComponentManager());
|
||||
ptr->m_componentFactory = ComponentFactory::create(viewFactory, viewLayout, graphAccess, locationAccess);
|
||||
|
||||
ptr->m_componentFactory = ComponentFactory::create(viewFactory, graphAccess, locationAccess);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -16,24 +22,28 @@ ComponentManager::~ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ComponentManager::setup()
|
||||
void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent();
|
||||
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent(viewLayout);
|
||||
m_components.push_back(graphComponent);
|
||||
|
||||
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent();
|
||||
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent(viewLayout);
|
||||
m_components.push_back(codeComponent);
|
||||
|
||||
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent();
|
||||
std::shared_ptr<CompositeView> compositeView =
|
||||
m_componentFactory->getViewFactory()->createCompositeView(viewLayout, CompositeView::DIRECTION_HORIZONTAL);
|
||||
m_views.push_back(compositeView);
|
||||
|
||||
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent(compositeView.get());
|
||||
m_components.push_back(undoRedoComponent);
|
||||
|
||||
std::shared_ptr<Component> refreshComponent = m_componentFactory->createRefreshComponent();
|
||||
std::shared_ptr<Component> refreshComponent = m_componentFactory->createRefreshComponent(compositeView.get());
|
||||
m_components.push_back(refreshComponent);
|
||||
|
||||
std::shared_ptr<Component> searchComponent = m_componentFactory->createSearchComponent();
|
||||
std::shared_ptr<Component> searchComponent = m_componentFactory->createSearchComponent(compositeView.get());
|
||||
m_components.push_back(searchComponent);
|
||||
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory->createStatusBarComponent();
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory->createStatusBarComponent(viewLayout);
|
||||
m_components.push_back(statusBarComponent);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "data/access/LocationAccess.h"
|
||||
#include "data/access/GraphAccess.h"
|
||||
|
||||
class View;
|
||||
class ViewFactory;
|
||||
class ViewLayout;
|
||||
|
||||
@@ -16,12 +17,12 @@ class ComponentManager
|
||||
{
|
||||
public:
|
||||
static std::shared_ptr<ComponentManager> create(
|
||||
ViewFactory* viewFactory, ViewLayout* viewLayout, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
ViewFactory* viewFactory, GraphAccess* graphAccess, LocationAccess* locationAccess
|
||||
);
|
||||
|
||||
~ComponentManager();
|
||||
|
||||
void setup();
|
||||
void setup(ViewLayout* viewLayout);
|
||||
|
||||
private:
|
||||
ComponentManager();
|
||||
@@ -29,7 +30,8 @@ private:
|
||||
|
||||
std::shared_ptr<ComponentFactory> m_componentFactory;
|
||||
|
||||
std::vector<std::shared_ptr<Component> > m_components;
|
||||
std::vector<std::shared_ptr<Component>> m_components;
|
||||
std::vector<std::shared_ptr<View>> m_views;
|
||||
};
|
||||
|
||||
#endif // COMPONENT_MANAGER_H
|
||||
|
||||
@@ -62,7 +62,7 @@ bool CodeView::CodeSnippetParams::sort(const CodeSnippetParams& a, const CodeSni
|
||||
}
|
||||
|
||||
CodeView::CodeView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "component/view/CompositeView.h"
|
||||
|
||||
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction)
|
||||
: View(viewLayout)
|
||||
, m_direction(direction)
|
||||
{
|
||||
}
|
||||
|
||||
CompositeView::~CompositeView()
|
||||
{
|
||||
}
|
||||
|
||||
CompositeView::CompositeDirection CompositeView::getDirection() const
|
||||
{
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
const std::vector<View*>& CompositeView::getViews() const
|
||||
{
|
||||
return m_views;
|
||||
}
|
||||
|
||||
std::string CompositeView::getName() const
|
||||
{
|
||||
return "CompositeView";
|
||||
}
|
||||
|
||||
void CompositeView::addView(View* view)
|
||||
{
|
||||
m_views.push_back(view);
|
||||
|
||||
addViewWidget(view);
|
||||
}
|
||||
|
||||
void CompositeView::removeView(View* view)
|
||||
{
|
||||
std::vector<View*>::iterator it = std::find(m_views.begin(), m_views.end(), view);
|
||||
if (it == m_views.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_views.erase(it);
|
||||
}
|
||||
|
||||
void CompositeView::showView(View* view)
|
||||
{
|
||||
getViewLayout()->showView(view);
|
||||
}
|
||||
|
||||
void CompositeView::hideView(View* view)
|
||||
{
|
||||
getViewLayout()->hideView(view);
|
||||
}
|
||||
|
||||
void CompositeView::loadLayout()
|
||||
{
|
||||
getViewLayout()->loadLayout();
|
||||
}
|
||||
|
||||
void CompositeView::saveLayout()
|
||||
{
|
||||
getViewLayout()->saveLayout();
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef COMPOSITE_VIEW_H
|
||||
#define COMPOSITE_VIEW_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
class CompositeView
|
||||
: public View
|
||||
, public ViewLayout
|
||||
{
|
||||
public:
|
||||
enum CompositeDirection
|
||||
{
|
||||
DIRECTION_HORIZONTAL,
|
||||
DIRECTION_VERTICAL
|
||||
};
|
||||
|
||||
CompositeView(ViewLayout* viewLayout, CompositeDirection direction);
|
||||
virtual ~CompositeView();
|
||||
|
||||
CompositeDirection getDirection() const;
|
||||
const std::vector<View*>& getViews() const;
|
||||
|
||||
virtual void addViewWidget(View* view) = 0;
|
||||
|
||||
// View implementation
|
||||
virtual std::string getName() const;
|
||||
|
||||
// ViewLayout implementation
|
||||
virtual void addView(View* view);
|
||||
virtual void removeView(View* view);
|
||||
|
||||
virtual void showView(View* view);
|
||||
virtual void hideView(View* view);
|
||||
|
||||
virtual void loadLayout();
|
||||
virtual void saveLayout();
|
||||
|
||||
private:
|
||||
std::vector<View*> m_views;
|
||||
CompositeDirection m_direction;
|
||||
};
|
||||
|
||||
#endif // COMPOSITE_VIEW_H
|
||||
@@ -10,7 +10,7 @@ GraphView::Metrics::Metrics()
|
||||
}
|
||||
|
||||
GraphView::GraphView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "component/controller/RefreshController.h"
|
||||
|
||||
RefreshView::RefreshView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "component/controller/SearchController.h"
|
||||
|
||||
SearchView::SearchView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100, 100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "component/controller/StatusBarController.h"
|
||||
|
||||
StatusBarView::StatusBarView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100,100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "component/controller/UndoRedoController.h"
|
||||
|
||||
UndoRedoView::UndoRedoView(ViewLayout* viewLayout)
|
||||
: View(viewLayout, Vec2i(100,100))
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
#include "component/view/ViewWidgetWrapper.h"
|
||||
|
||||
View::View(ViewLayout* viewLayout, const Vec2i& minSize)
|
||||
View::View(ViewLayout* viewLayout)
|
||||
: m_viewLayout(viewLayout)
|
||||
, m_widgetWrapper(nullptr)
|
||||
, m_minSize(minSize)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,9 +13,16 @@ View::~View()
|
||||
m_viewLayout->removeView(this);
|
||||
}
|
||||
|
||||
void View::setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper)
|
||||
void View::init()
|
||||
{
|
||||
m_widgetWrapper = widgetWrapper;
|
||||
createWidgetWrapper();
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
void View::addToLayout()
|
||||
{
|
||||
m_viewLayout->addView(this);
|
||||
}
|
||||
|
||||
ViewWidgetWrapper* View::getWidgetWrapper() const
|
||||
@@ -29,22 +35,12 @@ void View::setComponent(Component* component)
|
||||
m_component = component;
|
||||
}
|
||||
|
||||
int View::getMinWidth() const
|
||||
{
|
||||
return m_minSize.x;
|
||||
}
|
||||
|
||||
int View::getMinHeight() const
|
||||
{
|
||||
return m_minSize.y;
|
||||
}
|
||||
|
||||
Vec2i View::getMinSize() const
|
||||
{
|
||||
return m_minSize;
|
||||
}
|
||||
|
||||
ViewLayout* View::getViewLayout() const
|
||||
{
|
||||
return m_viewLayout;
|
||||
}
|
||||
|
||||
void View::setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper)
|
||||
{
|
||||
m_widgetWrapper = widgetWrapper;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ class View
|
||||
{
|
||||
public:
|
||||
template<typename T>
|
||||
static std::shared_ptr<T> create(ViewLayout* viewLayout);
|
||||
static std::shared_ptr<T> createInitAndAddToLayout(ViewLayout* viewLayout);
|
||||
|
||||
template<typename T>
|
||||
static std::shared_ptr<T> createAndDontAddToLayout(ViewLayout* viewLayout);
|
||||
static std::shared_ptr<T> createAndInit(ViewLayout* viewLayout);
|
||||
|
||||
View(ViewLayout* viewLayout, const Vec2i& minSize);
|
||||
View(ViewLayout* viewLayout);
|
||||
virtual ~View();
|
||||
|
||||
virtual std::string getName() const = 0;
|
||||
@@ -28,48 +28,43 @@ public:
|
||||
virtual void initView() = 0;
|
||||
virtual void refreshView() = 0;
|
||||
|
||||
void init();
|
||||
void addToLayout();
|
||||
|
||||
void setComponent(Component* component);
|
||||
|
||||
void setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper);
|
||||
ViewWidgetWrapper* getWidgetWrapper() const;
|
||||
|
||||
int getMinWidth() const;
|
||||
int getMinHeight() const;
|
||||
Vec2i getMinSize() const;
|
||||
|
||||
protected:
|
||||
template <typename ControllerType>
|
||||
ControllerType* getController();
|
||||
|
||||
ViewLayout* getViewLayout() const;
|
||||
|
||||
void setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper);
|
||||
|
||||
private:
|
||||
Component* m_component;
|
||||
ViewLayout* const m_viewLayout;
|
||||
std::shared_ptr<ViewWidgetWrapper> m_widgetWrapper;
|
||||
Vec2i m_minSize;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<T> View::create(ViewLayout* viewLayout)
|
||||
std::shared_ptr<T> View::createInitAndAddToLayout(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<T> ptr = std::make_shared<T>(viewLayout);
|
||||
std::shared_ptr<T> ptr = View::createAndInit<T>(viewLayout);
|
||||
|
||||
ptr->createWidgetWrapper();
|
||||
ptr->initView();
|
||||
|
||||
viewLayout->addView(ptr.get());
|
||||
ptr->addToLayout();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<T> View::createAndDontAddToLayout(ViewLayout* viewLayout)
|
||||
std::shared_ptr<T> View::createAndInit(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<T> ptr = std::make_shared<T>(viewLayout);
|
||||
|
||||
ptr->createWidgetWrapper();
|
||||
ptr->initView();
|
||||
ptr->init();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "component/view/CompositeView.h"
|
||||
|
||||
class CodeView;
|
||||
class GraphView;
|
||||
class MainView;
|
||||
@@ -19,6 +21,9 @@ public:
|
||||
virtual ~ViewFactory();
|
||||
|
||||
virtual std::shared_ptr<MainView> createMainView() const = 0;
|
||||
virtual std::shared_ptr<CompositeView> createCompositeView(
|
||||
ViewLayout* viewLayout, CompositeView::CompositeDirection direction) const = 0;
|
||||
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const = 0;
|
||||
|
||||
Reference in New Issue
Block a user