ui/data: cleaned up UI and parsing
* HOT FIX: typename not always correctly split to name hierarchy * show node main if available as first active token after parsing * show all contents of namespaces if searched for * added missing enum type and enum value usages * added inheritance for structs * removed MessageActivateToken and replaced it with MessageActivateTokens * activating correct nodes for clicks in GraphView and CodeView * no graph change when clicking an edge, but highlighting the edge instead * only show active nodes without connections when multiple are activated * fixed snippet sorting to put file that contains declarations on top * set sizeHints on CodeView and SearchView to increase their initial size fortune cookie message = Das Leben wird eine positive Wendung nehmen.
This commit is contained in:
@@ -28,6 +28,11 @@ QtCodeFileList::~QtCodeFileList()
|
||||
{
|
||||
}
|
||||
|
||||
QSize QtCodeFileList::sizeHint() const
|
||||
{
|
||||
return QSize(800, 800);
|
||||
}
|
||||
|
||||
void QtCodeFileList::addCodeSnippet(
|
||||
uint startLineNumber,
|
||||
const std::string& code,
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
QtCodeFileList(QWidget* parent = 0);
|
||||
virtual ~QtCodeFileList();
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
void addCodeSnippet(
|
||||
uint startLineNumber,
|
||||
const std::string& code,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "qt/utility/QtHighlighter.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
|
||||
QtCodeSnippet::LineNumberArea::LineNumberArea(QtCodeSnippet *codeSnippet)
|
||||
@@ -226,7 +226,7 @@ void QtCodeSnippet::clickedTokenLocation()
|
||||
{
|
||||
int clickPosition = textCursor().position();
|
||||
int diff = endTextEditPosition() + 1;
|
||||
Id tokenId = 0;
|
||||
Id locationId = 0;
|
||||
|
||||
for (Annotation annotation : m_annotations)
|
||||
{
|
||||
@@ -236,22 +236,20 @@ void QtCodeSnippet::clickedTokenLocation()
|
||||
if (d < diff)
|
||||
{
|
||||
diff = d;
|
||||
tokenId = annotation.tokenId;
|
||||
locationId = annotation.locationId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenId)
|
||||
if (locationId)
|
||||
{
|
||||
MessageActivateToken(tokenId).dispatch();
|
||||
MessageActivateTokenLocation(locationId).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeSnippet::clickedMaximizeButton()
|
||||
{
|
||||
MessageShowFile(
|
||||
m_filePath, m_startLineNumber, m_startLineNumber + document()->blockCount() - 1, m_activeTokenIds
|
||||
).dispatch();
|
||||
MessageShowFile(m_filePath, m_startLineNumber, m_startLineNumber + document()->blockCount() - 1).dispatch();
|
||||
}
|
||||
|
||||
void QtCodeSnippet::clearSelection()
|
||||
@@ -292,6 +290,7 @@ void QtCodeSnippet::createAnnotations(const TokenLocationFile& locationFile)
|
||||
}
|
||||
|
||||
annotation.tokenId = location->getTokenId();
|
||||
annotation.locationId = location->getId();
|
||||
annotation.isScope = location->getType() == TokenLocation::LOCATION_SCOPE;
|
||||
|
||||
m_annotations.push_back(annotation);
|
||||
|
||||
@@ -75,6 +75,7 @@ private:
|
||||
int start;
|
||||
int end;
|
||||
Id tokenId;
|
||||
Id locationId;
|
||||
bool isScope;
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,11 @@ QtSearchBar::~QtSearchBar()
|
||||
{
|
||||
}
|
||||
|
||||
QSize QtSearchBar::sizeHint() const
|
||||
{
|
||||
return QSize(400, 100);
|
||||
}
|
||||
|
||||
void QtSearchBar::setText(const std::string& text)
|
||||
{
|
||||
m_searchBox->setQuery(text);
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
QtSearchBar();
|
||||
virtual ~QtSearchBar();
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
|
||||
void setText(const std::string& text);
|
||||
void setFocus();
|
||||
void setAutocompletionList(const std::vector<SearchMatch>& autocompletionList);
|
||||
|
||||
@@ -11,8 +11,8 @@ QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||
: CodeView(viewLayout)
|
||||
, m_refreshViewFunctor(std::bind(&QtCodeView::doRefreshView, this))
|
||||
, m_clearCodeSnippetsFunctor(std::bind(&QtCodeView::doClearCodeSnippets, this))
|
||||
, m_showCodeSnippetsFunctor(std::bind(&QtCodeView::doShowCodeSnippets, this, std::placeholders::_1))
|
||||
, m_showCodeFileFunctor(std::bind(&QtCodeView::doShowCodeFile, this, std::placeholders::_1))
|
||||
, m_addCodeSnippetFunctor(std::bind(&QtCodeView::doAddCodeSnippet, this, std::placeholders::_1))
|
||||
{
|
||||
m_widget = createQtCodeFileList();
|
||||
}
|
||||
@@ -35,21 +35,26 @@ void QtCodeView::refreshView()
|
||||
m_refreshViewFunctor();
|
||||
}
|
||||
|
||||
void QtCodeView::showCodeFile(const CodeSnippetParams& params)
|
||||
{
|
||||
m_showCodeFileFunctor(params);
|
||||
}
|
||||
|
||||
void QtCodeView::addCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
m_addCodeSnippetFunctor(params);
|
||||
}
|
||||
|
||||
void QtCodeView::clearCodeSnippets()
|
||||
{
|
||||
m_clearCodeSnippetsFunctor();
|
||||
}
|
||||
|
||||
void QtCodeView::setActiveTokenIds(const std::vector<Id>& activeTokenIds)
|
||||
{
|
||||
m_activeTokenIds = activeTokenIds;
|
||||
}
|
||||
|
||||
void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets)
|
||||
{
|
||||
m_showCodeSnippetsFunctor(snippets);
|
||||
}
|
||||
|
||||
void QtCodeView::showCodeFile(const CodeSnippetParams& params)
|
||||
{
|
||||
m_showCodeFileFunctor(params);
|
||||
}
|
||||
|
||||
void QtCodeView::doRefreshView()
|
||||
{
|
||||
setStyleSheet(m_widget.get());
|
||||
@@ -61,6 +66,27 @@ void QtCodeView::doRefreshView()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeView::doClearCodeSnippets()
|
||||
{
|
||||
m_widget->clearCodeSnippets();
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets)
|
||||
{
|
||||
doClearCodeSnippets();
|
||||
|
||||
clearClosedWindows();
|
||||
for (std::shared_ptr<QtCodeFileList> window: m_windows)
|
||||
{
|
||||
window->setActiveTokenIds(m_activeTokenIds);
|
||||
}
|
||||
|
||||
for (const CodeSnippetParams& params : snippets)
|
||||
{
|
||||
m_widget->addCodeSnippet(params.startLineNumber, params.code, params.locationFile, m_activeTokenIds);
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
{
|
||||
std::shared_ptr<QtCodeFileList> ptr = createQtCodeFileList();
|
||||
@@ -79,22 +105,6 @@ void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
ptr->verticalScrollBar()->setValue(min + (max - min) * percent);
|
||||
}
|
||||
|
||||
void QtCodeView::doAddCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
m_widget->addCodeSnippet(params.startLineNumber, params.code, params.locationFile, m_activeTokenIds);
|
||||
|
||||
clearClosedWindows();
|
||||
for (std::shared_ptr<QtCodeFileList> window: m_windows)
|
||||
{
|
||||
window->setActiveTokenIds(m_activeTokenIds);
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeView::doClearCodeSnippets()
|
||||
{
|
||||
m_widget->clearCodeSnippets();
|
||||
}
|
||||
|
||||
std::shared_ptr<QtCodeFileList> QtCodeView::createQtCodeFileList() const
|
||||
{
|
||||
std::shared_ptr<QtCodeFileList> ptr = std::make_shared<QtCodeFileList>();
|
||||
@@ -107,11 +117,6 @@ void QtCodeView::setStyleSheet(QWidget* widget) const
|
||||
widget->setStyleSheet(TextAccess::createFromFile("data/gui/code_view/code_view.css")->getText().c_str());
|
||||
}
|
||||
|
||||
void QtCodeView::setActiveTokenIds(std::vector<Id> ids)
|
||||
{
|
||||
m_activeTokenIds = ids;
|
||||
}
|
||||
|
||||
void QtCodeView::clearClosedWindows()
|
||||
{
|
||||
for (size_t i = 0; i < m_windows.size(); i++)
|
||||
|
||||
@@ -24,26 +24,26 @@ public:
|
||||
virtual void refreshView();
|
||||
|
||||
// CodeView implementation
|
||||
virtual void showCodeFile(const CodeSnippetParams& params);
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params);
|
||||
virtual void clearCodeSnippets();
|
||||
virtual void setActiveTokenIds(const std::vector<Id>& activeTokenIds);
|
||||
virtual void showCodeSnippets(const std::vector<CodeSnippetParams>& snippets);
|
||||
virtual void showCodeFile(const CodeSnippetParams& params);
|
||||
|
||||
private:
|
||||
void doRefreshView();
|
||||
void doShowCodeFile(const CodeSnippetParams& params);
|
||||
void doAddCodeSnippet(const CodeSnippetParams& params);
|
||||
void doClearCodeSnippets();
|
||||
void doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets);
|
||||
void doShowCodeFile(const CodeSnippetParams& params);
|
||||
|
||||
std::shared_ptr<QtCodeFileList> createQtCodeFileList() const;
|
||||
|
||||
void setStyleSheet(QWidget* widget) const;
|
||||
void setActiveTokenIds(std::vector<Id> ids);
|
||||
void clearClosedWindows();
|
||||
|
||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||
QtThreadedFunctor<> m_clearCodeSnippetsFunctor;
|
||||
QtThreadedFunctor<const std::vector<CodeSnippetParams>&> m_showCodeSnippetsFunctor;
|
||||
QtThreadedFunctor<const CodeSnippetParams&> m_showCodeFileFunctor;
|
||||
QtThreadedFunctor<const CodeSnippetParams&> m_addCodeSnippetFunctor;
|
||||
|
||||
std::shared_ptr<QtCodeFileList> m_widget;
|
||||
std::vector<std::shared_ptr<QtCodeFileList>> m_windows;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
|
||||
#include "component/view/graphElements/GraphNode.h"
|
||||
@@ -460,11 +459,15 @@ void QtGraphEdge::onClick()
|
||||
if (isAggregation())
|
||||
{
|
||||
const std::set<Id>& ids = getData()->getComponent<TokenComponentAggregation>()->getAggregationIds();
|
||||
MessageActivateTokens(std::vector<Id>(ids.begin(), ids.end())).dispatch();
|
||||
MessageActivateTokens message(std::vector<Id>(ids.begin(), ids.end()));
|
||||
message.isAggregation = true;
|
||||
message.dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageActivateToken(getData()->getId()).dispatch();
|
||||
MessageActivateTokens message(getData()->getId());
|
||||
message.isEdge = true;
|
||||
message.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QGraphicsSceneEvent>
|
||||
#include <QPen>
|
||||
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageGraphNodeMove.h"
|
||||
|
||||
#include "qt/graphics/QtGraphicsRoundedRectItem.h"
|
||||
@@ -395,7 +395,7 @@ void QtGraphNode::onClick()
|
||||
{
|
||||
if (m_data && !m_data->isType(Node::NODE_UNDEFINED | Node::NODE_NAMESPACE))
|
||||
{
|
||||
MessageActivateToken(m_data->getId()).dispatch();
|
||||
MessageActivateTokens(m_data->getId()).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user