ui: Errorview
Tabbed view with errorview as tab
This commit is contained in:
@@ -2,14 +2,18 @@
|
||||
|
||||
#include "component/Component.h"
|
||||
#include "component/controller/CodeController.h"
|
||||
#include "component/controller/ErrorController.h"
|
||||
#include "component/controller/FeatureController.h"
|
||||
#include "component/controller/GraphController.h"
|
||||
#include "component/controller/LogController.h"
|
||||
#include "component/controller/RefreshController.h"
|
||||
#include "component/controller/SearchController.h"
|
||||
#include "component/controller/StatusBarController.h"
|
||||
#include "component/controller/UndoRedoController.h"
|
||||
#include "component/view/CodeView.h"
|
||||
#include "component/view/ErrorView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/LogView.h"
|
||||
#include "component/view/RefreshView.h"
|
||||
#include "component/view/SearchView.h"
|
||||
#include "component/view/StatusBarView.h"
|
||||
@@ -43,6 +47,22 @@ std::shared_ptr<Component> ComponentFactory::createCodeComponent(ViewLayout* vie
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createErrorComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<ErrorView> view = m_viewFactory->createErrorView(viewLayout);
|
||||
std::shared_ptr<ErrorController> controller = std::make_shared<ErrorController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createLogComponent(ViewLayout* viewLayout)
|
||||
{
|
||||
std::shared_ptr<LogView> view = m_viewFactory->createLogView(viewLayout);
|
||||
std::shared_ptr<LogController> controller = std::make_shared<LogController>(m_storageAccess);
|
||||
|
||||
return std::make_shared<Component>(view, controller);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> ComponentFactory::createFeatureComponent()
|
||||
{
|
||||
std::shared_ptr<Controller> controller = std::make_shared<FeatureController>(m_storageAccess);
|
||||
|
||||
@@ -19,8 +19,10 @@ public:
|
||||
ViewFactory* getViewFactory() const;
|
||||
|
||||
std::shared_ptr<Component> createCodeComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createErrorComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createFeatureComponent();
|
||||
std::shared_ptr<Component> createGraphComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createLogComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createRefreshComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createSearchComponent(ViewLayout* viewLayout);
|
||||
std::shared_ptr<Component> createStatusBarComponent(ViewLayout* viewLayout);
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "component/view/DialogView.h"
|
||||
#include "component/view/GraphView.h"
|
||||
#include "component/view/LogView.h"
|
||||
#include "component/view/RefreshView.h"
|
||||
#include "component/view/SearchView.h"
|
||||
#include "component/view/TabbedView.h"
|
||||
#include "component/view/UndoRedoView.h"
|
||||
#include "component/view/ViewFactory.h"
|
||||
|
||||
@@ -53,6 +55,16 @@ void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
m_components.push_back(featureComponent);
|
||||
|
||||
m_dialogView = m_componentFactory->getViewFactory()->createDialogView(viewLayout);
|
||||
|
||||
std::shared_ptr<TabbedView> tabbedView =
|
||||
m_componentFactory->getViewFactory()->createTabbedView(viewLayout, "Log");
|
||||
m_tabbedViews.push_back(tabbedView);
|
||||
|
||||
std::shared_ptr<Component> errorComponent = m_componentFactory->createErrorComponent(tabbedView.get());
|
||||
m_components.push_back(errorComponent);
|
||||
|
||||
//std::shared_ptr<Component> logComponent = m_componentFactory->createLogComponent(tabbedView.get());
|
||||
//m_components.push_back(logComponent);
|
||||
}
|
||||
|
||||
void ComponentManager::clearComponents()
|
||||
@@ -84,6 +96,11 @@ void ComponentManager::refreshViews()
|
||||
{
|
||||
view->refreshView();
|
||||
}
|
||||
|
||||
for (std::shared_ptr<TabbedView> view : m_tabbedViews)
|
||||
{
|
||||
view->refreshView();
|
||||
}
|
||||
}
|
||||
|
||||
DialogView* ComponentManager::getDialogView() const
|
||||
|
||||
@@ -11,6 +11,7 @@ class CompositeView;
|
||||
class DialogView;
|
||||
class NetworkFactory;
|
||||
class StorageAccess;
|
||||
class TabbedView;
|
||||
class View;
|
||||
class ViewFactory;
|
||||
class ViewLayout;
|
||||
@@ -36,6 +37,7 @@ private:
|
||||
std::shared_ptr<ComponentFactory> m_componentFactory;
|
||||
|
||||
std::vector<std::shared_ptr<CompositeView>> m_compositeViews;
|
||||
std::vector<std::shared_ptr<TabbedView>> m_tabbedViews;
|
||||
std::vector<std::shared_ptr<Component>> m_components;
|
||||
|
||||
std::shared_ptr<DialogView> m_dialogView;
|
||||
|
||||
@@ -272,16 +272,24 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
TRACE("code errors");
|
||||
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
CodeView* view = getView();
|
||||
view->clear();
|
||||
view->setErrorInfos(errors);
|
||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||
if (!view->showsErrors() || !message->errorId)
|
||||
{
|
||||
std::vector<ErrorInfo> errors;
|
||||
m_collection = m_storageAccess->getErrorTokenLocations(&errors);
|
||||
std::vector<CodeSnippetParams> snippets = getSnippetsForCollection(m_collection);
|
||||
|
||||
showContents(message);
|
||||
view->clear();
|
||||
view->setErrorInfos(errors);
|
||||
view->showCodeSnippets(snippets, std::vector<Id>());
|
||||
|
||||
showContents(message);
|
||||
}
|
||||
|
||||
if (message->errorId)
|
||||
{
|
||||
view->showActiveSnippet(std::vector<Id>(1, message->errorId), m_collection, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageSearchFullText* message)
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "component/controller/ErrorController.h"
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
|
||||
ErrorController::ErrorController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorController::~ErrorController()
|
||||
{
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageClearErrorCount* message)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
clear();
|
||||
|
||||
auto errors = m_storageAccess->getAllErrors();
|
||||
|
||||
for (const StorageError& error : errors)
|
||||
{
|
||||
getView()->addError(error);
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageNewErrors* message)
|
||||
{
|
||||
for (const StorageError& error : message->errors)
|
||||
{
|
||||
getView()->addError(error);
|
||||
}
|
||||
|
||||
getView()->showDockWidget();
|
||||
}
|
||||
|
||||
void ErrorController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->errorId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
clear();
|
||||
|
||||
auto errors = m_storageAccess->getAllErrors();
|
||||
|
||||
for (const StorageError& error : errors)
|
||||
{
|
||||
getView()->addError(error);
|
||||
}
|
||||
|
||||
getView()->showDockWidget();
|
||||
}
|
||||
|
||||
ErrorView* ErrorController::getView() const
|
||||
{
|
||||
return Controller::getView<ErrorView>();
|
||||
}
|
||||
|
||||
void ErrorController::clear()
|
||||
{
|
||||
getView()->clear();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef ERROR_CONTROLLER_H
|
||||
#define ERROR_CONTROLLER_H
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageClearErrorCount.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
#include "utility/messaging/type/MessageNewErrors.h"
|
||||
#include "utility/messaging/type/MessageShowErrors.h"
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/ErrorView.h"
|
||||
|
||||
class StorageAccess;
|
||||
|
||||
class ErrorController
|
||||
: public Controller
|
||||
, public MessageListener<MessageClearErrorCount>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
, public MessageListener<MessageNewErrors>
|
||||
, public MessageListener<MessageShowErrors>
|
||||
{
|
||||
public:
|
||||
ErrorController(StorageAccess* storageAccess);
|
||||
~ErrorController();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageClearErrorCount* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
virtual void handleMessage(MessageNewErrors* message);
|
||||
virtual void handleMessage(MessageShowErrors* message);
|
||||
|
||||
ErrorView* getView() const;
|
||||
|
||||
virtual void clear();
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // ERROR_CONTROLLER_H
|
||||
@@ -137,7 +137,7 @@ void FeatureController::handleMessage(MessageSearch* message)
|
||||
|
||||
case SearchMatch::COMMAND_ERROR:
|
||||
{
|
||||
MessageShowErrors msg(m_storageAccess->getErrorCount());
|
||||
MessageShowErrors msg(m_storageAccess->getFilteredErrorCount());
|
||||
msg.setIsReplayed(message->isReplayed());
|
||||
msg.dispatchImmediately();
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "component/controller/LogController.h"
|
||||
|
||||
#include "data/access/StorageAccess.h"
|
||||
|
||||
LogController::LogController(StorageAccess* storageAccess)
|
||||
: m_storageAccess(storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
LogController::~LogController()
|
||||
{
|
||||
}
|
||||
|
||||
LogView* LogController::getView() const
|
||||
{
|
||||
return Controller::getView<LogView>();
|
||||
}
|
||||
|
||||
void LogController::clear()
|
||||
{
|
||||
getView()->clear();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef LOG_CONTROLLER_H
|
||||
#define LOG_CONTROLLER_H
|
||||
|
||||
#include "component/controller/Controller.h"
|
||||
#include "component/view/LogView.h"
|
||||
|
||||
class StorageAccess;
|
||||
|
||||
class LogController
|
||||
: public Controller
|
||||
{
|
||||
public:
|
||||
LogController(StorageAccess* storageAccess);
|
||||
~LogController();
|
||||
|
||||
private:
|
||||
LogView* getView() const;
|
||||
|
||||
virtual void clear();
|
||||
|
||||
StorageAccess* m_storageAccess;
|
||||
};
|
||||
|
||||
#endif // LOG_CONTROLLER_H
|
||||
@@ -31,17 +31,22 @@ void StatusBarController::handleMessage(MessageClearErrorCount* message)
|
||||
|
||||
void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
ErrorCountInfo errorCount = m_storageAccess->getErrorCount();
|
||||
ErrorCountInfo errorCount = m_storageAccess->getFilteredErrorCount();
|
||||
getView()->setErrorCount(errorCount);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
getView()->setErrorCount(m_storageAccess->getErrorCount());
|
||||
getView()->setErrorCount(m_storageAccess->getFilteredErrorCount());
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageShowErrors* message)
|
||||
{
|
||||
if (message->errorId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
getView()->setErrorCount(message->errorCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void setErrorInfos(const std::vector<ErrorInfo>& errorInfos) = 0;
|
||||
virtual bool showsErrors() const = 0;
|
||||
|
||||
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets, const std::vector<Id>& activeTokenIds) = 0;
|
||||
virtual void addCodeSnippets(const std::vector<CodeSnippetParams>& snippets, bool insert) = 0;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "component/view/CompositeView.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
CompositeView::CompositeView(ViewLayout* viewLayout, CompositeDirection direction, const std::string& name)
|
||||
: View(viewLayout)
|
||||
, m_direction(direction)
|
||||
@@ -46,20 +48,8 @@ void CompositeView::removeView(View* view)
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -35,9 +35,6 @@ public:
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "component/view/ErrorView.h"
|
||||
|
||||
ErrorView::ErrorView(ViewLayout* viewLayout)
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
ErrorView::~ErrorView()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ErrorView::getName() const
|
||||
{
|
||||
return "Errors";
|
||||
}
|
||||
|
||||
void ErrorView::showDockWidget()
|
||||
{
|
||||
getViewLayout()->showView(this);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef ERROR_VIEW_H
|
||||
#define ERROR_VIEW_H
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "data/StorageTypes.h"
|
||||
|
||||
class ErrorView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
ErrorView(ViewLayout* viewLayout);
|
||||
virtual ~ErrorView();
|
||||
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void showDockWidget();
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual void addError(const StorageError& error) = 0;
|
||||
};
|
||||
|
||||
#endif // ERROR_VIEW_H
|
||||
@@ -1,6 +1,9 @@
|
||||
#ifndef GRAPH_VIEW_H
|
||||
#define GRAPH_VIEW_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "utility/math/Vector2.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "component/view/View.h"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "component/view/LogView.h"
|
||||
|
||||
LogView::LogView(ViewLayout* viewLayout)
|
||||
: View(viewLayout)
|
||||
{
|
||||
}
|
||||
|
||||
LogView::~LogView()
|
||||
{
|
||||
}
|
||||
|
||||
std::string LogView::getName() const
|
||||
{
|
||||
return "Logs";
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef LOG_VIEW_H
|
||||
#define LOG_VIEW_H
|
||||
|
||||
#include "component/view/View.h"
|
||||
|
||||
class LogView
|
||||
: public View
|
||||
{
|
||||
public:
|
||||
LogView(ViewLayout* viewLayout);
|
||||
virtual ~LogView();
|
||||
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void clear() = 0;
|
||||
};
|
||||
|
||||
#endif // LOG_VIEW_H
|
||||
@@ -13,6 +13,9 @@ public:
|
||||
MainView();
|
||||
virtual ~MainView();
|
||||
|
||||
virtual void loadLayout() = 0;
|
||||
virtual void saveLayout() = 0;
|
||||
|
||||
virtual void hideStartScreen() = 0;
|
||||
virtual void setTitle(const std::string& title) = 0;
|
||||
virtual void activateWindow() = 0;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "component/view/TabbedView.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
TabbedView::TabbedView(ViewLayout* viewLayout, const std::string& name)
|
||||
: View(viewLayout)
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
TabbedView::~TabbedView()
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<View*>& TabbedView::getViews() const
|
||||
{
|
||||
return m_views;
|
||||
}
|
||||
|
||||
std::string TabbedView::getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void TabbedView::addView(View* view)
|
||||
{
|
||||
m_views.push_back(view);
|
||||
|
||||
addViewWidget(view);
|
||||
}
|
||||
|
||||
void TabbedView::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 TabbedView::showView(View* view)
|
||||
{
|
||||
getViewLayout()->showView(view);
|
||||
}
|
||||
|
||||
void TabbedView::hideView(View* view)
|
||||
{
|
||||
getViewLayout()->hideView(view);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef TABBED_VIEW_H
|
||||
#define TABBED_VIEW_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "component/view/View.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
class TabbedView
|
||||
: public View
|
||||
, public ViewLayout
|
||||
{
|
||||
public:
|
||||
|
||||
TabbedView(ViewLayout* viewLayout, const std::string& name);
|
||||
virtual ~TabbedView();
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
std::vector<View*> m_views;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
#endif // TABBED_VIEW_H
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "component/Component.h"
|
||||
#include "component/view/ViewLayout.h"
|
||||
#include "utility/math/Vector2.h"
|
||||
|
||||
class ViewWidgetWrapper;
|
||||
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
|
||||
class CodeView;
|
||||
class DialogView;
|
||||
class ErrorView;
|
||||
class GraphView;
|
||||
class MainView;
|
||||
class LogView;
|
||||
class RefreshView;
|
||||
class SearchView;
|
||||
class StatusBarView;
|
||||
class TabbedView;
|
||||
class UndoRedoView;
|
||||
class ViewLayout;
|
||||
|
||||
@@ -24,9 +27,12 @@ public:
|
||||
virtual std::shared_ptr<MainView> createMainView() const = 0;
|
||||
virtual std::shared_ptr<CompositeView> createCompositeView(
|
||||
ViewLayout* viewLayout, CompositeView::CompositeDirection direction, const std::string& name) const = 0;
|
||||
virtual std::shared_ptr<TabbedView> createTabbedView(ViewLayout* viewLayout, const std::string& name) const = 0;
|
||||
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<LogView> createLogView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const = 0;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const = 0;
|
||||
|
||||
@@ -14,9 +14,6 @@ public:
|
||||
|
||||
virtual void showView(View* view) = 0;
|
||||
virtual void hideView(View* view) = 0;
|
||||
|
||||
virtual void loadLayout() = 0;
|
||||
virtual void saveLayout() = 0;
|
||||
};
|
||||
|
||||
#endif // VIEW_LAYOUT_H
|
||||
|
||||
Reference in New Issue
Block a user