ui: improved file nodes

* added colors for file nodes and dependency edges
* use TokenComponentFilePath on file nodes to store FilePath
This commit is contained in:
Eberhard Graether
2015-03-09 14:07:58 +01:00
parent 3893868386
commit ca9dfe7f75
15 changed files with 114 additions and 48 deletions
+1 -8
View File
@@ -52,14 +52,7 @@ void FilterableGraph::printBasic(std::ostream& ostream) const
forEachNode(
[&ostream](Node* n)
{
if (n->isType(Node::NODE_FILE))
{
ostream << ' ' << n->getTypeString() << ':' << n->getName();
}
else
{
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
}
ostream << ' ' << n->getTypeString() << ':' << n->getFullName();
}
);
ostream << '\n';
+18 -8
View File
@@ -10,6 +10,7 @@
#include "data/graph/token_component/TokenComponentName.h"
#include "data/graph/token_component/TokenComponentStatic.h"
#include "data/graph/token_component/TokenComponentSignature.h"
#include "data/graph/token_component/TokenComponentFilePath.h"
Node::Node(NodeType type, std::shared_ptr<TokenComponentName> nameComponent)
: m_type(type)
@@ -52,14 +53,7 @@ bool Node::isType(NodeTypeMask mask) const
std::string Node::getName() const
{
if (isType(NODE_FILE))
{
return FileSystem::fileName(m_nameComponent->getName());
}
else
{
return m_nameComponent->getName();
}
return m_nameComponent->getName();
}
std::string Node::getFullName() const
@@ -317,6 +311,22 @@ void Node::addComponentSignature(std::shared_ptr<TokenComponentSignature> compon
}
}
void Node::addComponentFilePath(std::shared_ptr<TokenComponentFilePath> component)
{
if (getComponent<TokenComponentFilePath>())
{
LOG_ERROR("TokenComponentFilePath has been set before!");
}
else if (!isType(NODE_FILE))
{
LOG_ERROR("TokenComponentSignature can't be set on node of type: " + getTypeString());
}
else
{
addComponent(component);
}
}
std::string Node::getTypeString(NodeType type)
{
switch (type)
+2
View File
@@ -14,6 +14,7 @@ class TokenComponentConst;
class TokenComponentName;
class TokenComponentStatic;
class TokenComponentSignature;
class TokenComponentFilePath;
class Node: public Token
{
@@ -85,6 +86,7 @@ public:
void addComponentConst(std::shared_ptr<TokenComponentConst> component);
void addComponentStatic(std::shared_ptr<TokenComponentStatic> component);
void addComponentSignature(std::shared_ptr<TokenComponentSignature> component);
void addComponentFilePath(std::shared_ptr<TokenComponentFilePath> component);
// Logging.
virtual std::string getTypeString() const;
@@ -0,0 +1,20 @@
#include "data/graph/token_component/TokenComponentFilePath.h"
TokenComponentFilePath::TokenComponentFilePath(const FilePath& path)
: m_path(path)
{
}
TokenComponentFilePath::~TokenComponentFilePath()
{
}
std::shared_ptr<TokenComponent> TokenComponentFilePath::copy() const
{
return std::make_shared<TokenComponentFilePath>(*this);
}
const FilePath& TokenComponentFilePath::getFilePath() const
{
return m_path;
}
@@ -0,0 +1,23 @@
#ifndef TOKEN_COMPONENT_FILE_PATH_H
#define TOKEN_COMPONENT_FILE_PATH_H
#include "utility/file/FilePath.h"
#include "data/graph/token_component/TokenComponent.h"
class TokenComponentFilePath
: public TokenComponent
{
public:
TokenComponentFilePath(const FilePath& path);
virtual ~TokenComponentFilePath();
virtual std::shared_ptr<TokenComponent> copy() const;
const FilePath& getFilePath() const;
private:
const FilePath m_path;
};
#endif // TOKEN_COMPONENT_FILE_PATH_H