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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user