data: fixes and improvements

* save forward declarations of classes and structs as NODE_UNDEFINED_TYPE
* put whole files on top in snippet sorting
* uses aggregation count as weight in graph layouting instead of adding all edges to graph
* refreshing all views of components on MessageRefresh in ComponentManager
* reloading ApplikatinoSettings on MessageRefresh
This commit is contained in:
Eberhard Graether
2015-05-25 04:12:52 +02:00
parent f15f0de414
commit 149bb52c4c
13 changed files with 53 additions and 51 deletions
+1
View File
@@ -63,6 +63,7 @@ void QtGraphView::initView()
void QtGraphView::refreshView()
{
resizeView();
}
void QtGraphView::rebuildGraph(
+8 -3
View File
@@ -13,8 +13,7 @@
std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
settings->load("data/ApplicationSettings.xml");
loadSettings();
std::shared_ptr<Application> ptr(new Application());
@@ -26,7 +25,7 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
ptr->m_componentManager->setup(ptr->m_mainView.get());
ptr->m_mainView->loadLayout();
std::string startupProjectFilePath = settings->getStartupProjectFilePath();
std::string startupProjectFilePath = ApplicationSettings::getInstance()->getStartupProjectFilePath();
if (startupProjectFilePath.size())
{
MessageLoadProject(startupProjectFilePath).dispatch();
@@ -40,6 +39,11 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
return ptr;
}
void Application::loadSettings()
{
ApplicationSettings::getInstance()->load("data/ApplicationSettings.xml");
}
Application::Application()
{
TaskScheduler::getInstance()->startSchedulerLoopThreaded();
@@ -124,6 +128,7 @@ void Application::handleMessage(MessageLoadSource* message)
void Application::handleMessage(MessageRefresh* message)
{
loadSettings();
reloadProject();
}
+1
View File
@@ -25,6 +25,7 @@ class Application
{
public:
static std::shared_ptr<Application> create(ViewFactory* viewFactory);
static void loadSettings();
~Application();
+8
View File
@@ -49,3 +49,11 @@ void ComponentManager::setup(ViewLayout* viewLayout)
ComponentManager::ComponentManager()
{
}
void ComponentManager::handleMessage(MessageRefresh* message)
{
for (std::shared_ptr<Component> component : m_components)
{
component->getView<View>()->refreshView();
}
}
+6
View File
@@ -4,6 +4,9 @@
#include <memory>
#include <vector>
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "component/Component.h"
#include "component/ComponentFactory.h"
@@ -14,6 +17,7 @@ class ViewFactory;
class ViewLayout;
class ComponentManager
: public MessageListener<MessageRefresh>
{
public:
static std::shared_ptr<ComponentManager> create(ViewFactory* viewFactory, StorageAccess* graphAccess);
@@ -26,6 +30,8 @@ private:
ComponentManager();
ComponentManager(const ComponentManager&);
void handleMessage(MessageRefresh* message);
std::shared_ptr<ComponentFactory> m_componentFactory;
std::vector<std::shared_ptr<CompositeView>> m_compositeViews;
@@ -110,11 +110,6 @@ void CodeController::handleMessage(MessageFocusOut* message)
getView()->defocusToken();
}
void CodeController::handleMessage(MessageRefresh* message)
{
getView()->refreshView();
}
void CodeController::handleMessage(MessageShowFile* message)
{
CodeView::CodeSnippetParams params;
@@ -11,7 +11,6 @@
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageFocusIn.h"
#include "utility/messaging/type/MessageFocusOut.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageShowFile.h"
#include "utility/types.h"
@@ -31,7 +30,6 @@ class CodeController
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageFocusIn>
, public MessageListener<MessageFocusOut>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageShowFile>
{
public:
@@ -47,7 +45,6 @@ private:
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageFocusIn* message);
virtual void handleMessage(MessageFocusOut* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageShowFile* message);
CodeView* getView();
@@ -181,12 +181,13 @@ MatrixDynamicBase<int> GraphLayouter::buildLaplacianMatrix(const std::vector<Dum
std::map<std::pair<Id, Id>, int> weightsMap;
for(unsigned int i = 0; i < edges.size(); i++)
{
DummyNode ownerNode = nodesMap[edges[i].ownerId];
DummyNode targetNode = nodesMap[edges[i].targetId];
const DummyEdge& edge = edges[i];
DummyNode ownerNode = nodesMap[edge.ownerId];
DummyNode targetNode = nodesMap[edge.targetId];
if(ownerNode.topLevelAncestorId != targetNode.topLevelAncestorId)
{
int weightIncrement = 1;
int weightIncrement = edge.getWeight();
Id ownerId = ownerNode.topLevelAncestorId;
Id targetId = targetNode.topLevelAncestorId;
@@ -40,11 +40,6 @@ void SearchController::handleMessage(MessageFinishedParsing* message)
getView()->setText("");
}
void SearchController::handleMessage(MessageRefresh* message)
{
getView()->refreshView();
}
void SearchController::handleMessage(MessageSearch* message)
{
const std::string& query = message->query;
@@ -8,7 +8,6 @@
#include "utility/messaging/type/MessageActivateTokens.h"
#include "utility/messaging/type/MessageFind.h"
#include "utility/messaging/type/MessageFinishedParsing.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageSearch.h"
#include "utility/messaging/type/MessageSearchAutocomplete.h"
@@ -20,7 +19,6 @@ class SearchController
, public MessageListener<MessageActivateTokens>
, public MessageListener<MessageFind>
, public MessageListener<MessageFinishedParsing>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageSearch>
, public MessageListener<MessageSearchAutocomplete>
{
@@ -32,7 +30,6 @@ private:
virtual void handleMessage(MessageActivateTokens* message);
virtual void handleMessage(MessageFind* message);
virtual void handleMessage(MessageFinishedParsing* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSearch* message);
virtual void handleMessage(MessageSearchAutocomplete* message);
@@ -3,6 +3,9 @@
#include "utility/types.h"
#include "data/graph/Edge.h"
#include "data/graph/token_component/TokenComponentAggregation.h"
class Edge;
// temporary data structure for (visual) graph creation process
@@ -17,6 +20,16 @@ struct DummyEdge
{
}
int getWeight() const
{
if (data->isType(Edge::EDGE_AGGREGATION))
{
return data->getComponent<TokenComponentAggregation>()->getAggregationCount();
}
return 1;
}
Id ownerId;
Id targetId;
+10 -5
View File
@@ -15,11 +15,6 @@ CodeView::CodeSnippetParams::CodeSnippetParams()
bool CodeView::CodeSnippetParams::sort(const CodeSnippetParams& a, const CodeSnippetParams& b)
{
if(a.isActive && b.isActive)
{
return false;
}
// sort active snippet first
if (a.isActive && !b.isActive)
{
@@ -40,6 +35,16 @@ bool CodeView::CodeSnippetParams::sort(const CodeSnippetParams& a, const CodeSni
return false;
}
// sort whole files
if (a.locationFile->isWholeCopy && !b.locationFile->isWholeCopy)
{
return true;
}
else if (!a.locationFile->isWholeCopy && b.locationFile->isWholeCopy)
{
return false;
}
const FilePath& aFilePath = a.locationFile->getFilePath();
const FilePath& bFilePath = b.locationFile->getFilePath();
+2 -24
View File
@@ -212,7 +212,7 @@ Id Storage::onClassParsed(
){
log("class", nameHierarchy.getFullName(), location);
Node* node = addNodeHierarchy(Node::NODE_CLASS, nameHierarchy);
Node* node = addNodeHierarchy(scopeLocation.isValid() ? Node::NODE_CLASS : Node::NODE_UNDEFINED_TYPE, nameHierarchy);
addAccess(node, access);
addTokenLocation(node, location);
addTokenLocation(node, scopeLocation, true);
@@ -226,7 +226,7 @@ Id Storage::onStructParsed(
){
log("struct", nameHierarchy.getFullName(), location);
Node* node = addNodeHierarchy(Node::NODE_STRUCT, nameHierarchy);
Node* node = addNodeHierarchy(scopeLocation.isValid() ? Node::NODE_STRUCT : Node::NODE_UNDEFINED_TYPE, nameHierarchy);
addAccess(node, access);
addTokenLocation(node, location);
addTokenLocation(node, scopeLocation, true);
@@ -818,28 +818,6 @@ std::shared_ptr<Graph> Storage::getGraphForActiveTokenIds(const std::vector<Id>&
Edge* edge = dynamic_cast<Edge*>(token);
graph->addEdgeAndAllChildrenAsPlainCopy(edge);
}
for (const std::pair<Id, std::shared_ptr<Node>> nodePair : graph->getNodes())
{
Node* node = m_graph.getNodeById(nodePair.first);
node->forEachEdge(
[graph](Edge* edge)
{
if (edge->getType() != Edge::EdgeType::EDGE_MEMBER)
{
Node* from = edge->getFrom();
Node* to = edge->getTo();
if (graph->findNode([from](Node* node){ return from->getId() == node->getId(); }) != NULL &&
graph->findNode([to](Node* node){ return to->getId() == node->getId(); }) != NULL)
{
graph->addEdge(edge);
}
}
}
);
}
}
if (ApplicationSettings::getInstance()->filterUndefinedNodesFromGraph())