ui: integrated autocompletion and filtering into SearchView
- QtSearchView was split into QtSearchView and QtSearchBox. - QtSearchBox contains all Qt elements and can use them purely - QtSearchView forwards calls from the SearchController to QtSearchBox - Searching is initiated with MessageSearch to the SearchController - Autocompletion is initiated with MessageSearchAutocomplete to the SearchController - The search field is able to create filter queries by only giving autocompletions for the last token in the query - For named tokens the search field adds their token ids to the query in the form of "A,25" for faster lookup bug id = #21
This commit is contained in:
@@ -11,6 +11,16 @@ FilterableGraph::~FilterableGraph()
|
||||
{
|
||||
}
|
||||
|
||||
Token* FilterableGraph::getTokenById(Id id) const
|
||||
{
|
||||
Token* token = getNodeById(id);
|
||||
if (!token)
|
||||
{
|
||||
token = getEdgeById(id);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
void FilterableGraph::print(std::ostream& ostream) const
|
||||
{
|
||||
ostream << "Graph:\n";
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class Edge;
|
||||
class Node;
|
||||
class Token;
|
||||
@@ -29,6 +31,11 @@ public:
|
||||
virtual size_t getNodeCount() const = 0;
|
||||
virtual size_t getEdgeCount() const = 0;
|
||||
|
||||
virtual Node* getNodeById(Id id) const = 0;
|
||||
virtual Edge* getEdgeById(Id id) const = 0;
|
||||
|
||||
Token* getTokenById(Id id) const;
|
||||
|
||||
void print(std::ostream& ostream) const;
|
||||
void printBasic(std::ostream& ostream) const;
|
||||
};
|
||||
|
||||
@@ -75,16 +75,6 @@ size_t Graph::getEdgeCount() const
|
||||
return m_edges.size();
|
||||
}
|
||||
|
||||
const std::map<Id, std::shared_ptr<Node>>& Graph::getNodes() const
|
||||
{
|
||||
return m_nodes;
|
||||
}
|
||||
|
||||
const std::map<Id, std::shared_ptr<Edge>>& Graph::getEdges() const
|
||||
{
|
||||
return m_edges;
|
||||
}
|
||||
|
||||
Node* Graph::getNodeById(Id id) const
|
||||
{
|
||||
std::map<Id, std::shared_ptr<Node>>::const_iterator it = m_nodes.find(id);
|
||||
@@ -105,14 +95,14 @@ Edge* Graph::getEdgeById(Id id) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Token* Graph::getTokenById(Id id) const
|
||||
const std::map<Id, std::shared_ptr<Node>>& Graph::getNodes() const
|
||||
{
|
||||
Token* token = getNodeById(id);
|
||||
if (!token)
|
||||
{
|
||||
token = getEdgeById(id);
|
||||
}
|
||||
return token;
|
||||
return m_nodes;
|
||||
}
|
||||
|
||||
const std::map<Id, std::shared_ptr<Edge>>& Graph::getEdges() const
|
||||
{
|
||||
return m_edges;
|
||||
}
|
||||
|
||||
void Graph::removeNode(Node* node)
|
||||
|
||||
@@ -32,13 +32,12 @@ public:
|
||||
virtual size_t getNodeCount() const;
|
||||
virtual size_t getEdgeCount() const;
|
||||
|
||||
virtual Node* getNodeById(Id id) const;
|
||||
virtual Edge* getEdgeById(Id id) const;
|
||||
|
||||
const std::map<Id, std::shared_ptr<Node>>& getNodes() const;
|
||||
const std::map<Id, std::shared_ptr<Edge>>& getEdges() const;
|
||||
|
||||
Node* getNodeById(Id id) const;
|
||||
Edge* getEdgeById(Id id) const;
|
||||
Token* getTokenById(Id id) const;
|
||||
|
||||
void removeNode(Node* node);
|
||||
void removeEdge(Edge* edge);
|
||||
|
||||
|
||||
@@ -71,6 +71,26 @@ size_t SubGraph::getEdgeCount() const
|
||||
return m_edges.size();
|
||||
}
|
||||
|
||||
Node* SubGraph::getNodeById(Id id) const
|
||||
{
|
||||
std::map<Id, Node*>::const_iterator it = m_nodes.find(id);
|
||||
if (it != m_nodes.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Edge* SubGraph::getEdgeById(Id id) const
|
||||
{
|
||||
std::map<Id, Edge*>::const_iterator it = m_edges.find(id);
|
||||
if (it != m_edges.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<Id> SubGraph::getTokenIds() const
|
||||
{
|
||||
std::vector<Id> ids;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "data/graph/FilterableGraph.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class Edge;
|
||||
class Node;
|
||||
@@ -35,6 +34,9 @@ public:
|
||||
virtual size_t getNodeCount() const;
|
||||
virtual size_t getEdgeCount() const;
|
||||
|
||||
virtual Node* getNodeById(Id id) const;
|
||||
virtual Edge* getEdgeById(Id id) const;
|
||||
|
||||
std::vector<Id> getTokenIds() const;
|
||||
|
||||
void subtract(const SubGraph& other);
|
||||
|
||||
@@ -174,5 +174,5 @@ void GraphFilterConductor::filterCommandNode(const QueryCommand* node, const Fil
|
||||
|
||||
void GraphFilterConductor::filterTokenNode(const QueryToken* node, const FilterableGraph* in, FilterableGraph* out) const
|
||||
{
|
||||
GraphFilterToken(node->getName()).apply(in, out);
|
||||
GraphFilterToken(node->getTokenName(), node->getTokenIds()).apply(in, out);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#ifndef GRAPH_FILTER_IMPLEMENTATIONS_H
|
||||
#define GRAPH_FILTER_IMPLEMENTATIONS_H
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "data/graph/Edge.h"
|
||||
#include "data/graph/filter/GraphFilter.h"
|
||||
#include "data/graph/FilterableGraph.h"
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/graph/token_component/TokenComponentAbstraction.h"
|
||||
#include "data/graph/token_component/TokenComponentAccess.h"
|
||||
@@ -258,22 +261,43 @@ class GraphFilterToken
|
||||
: public GraphFilter
|
||||
{
|
||||
public:
|
||||
GraphFilterToken(const std::string& name)
|
||||
: m_name(name)
|
||||
GraphFilterToken(const std::string& tokenName, const std::set<Id>& tokenIds)
|
||||
: m_tokenName(tokenName)
|
||||
, m_tokenIds(tokenIds)
|
||||
{
|
||||
}
|
||||
|
||||
void apply(const FilterableGraph* in, FilterableGraph* out)
|
||||
{
|
||||
if (m_tokenIds.size())
|
||||
{
|
||||
for (Id tokenId : m_tokenIds)
|
||||
{
|
||||
Node* node = in->getNodeById(tokenId);
|
||||
if (node)
|
||||
{
|
||||
out->addNode(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GraphFilter::apply(in, out);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void visitNode(Node* node)
|
||||
{
|
||||
if (node->getName() == m_name)
|
||||
if (node->getFullName() == m_tokenName)
|
||||
{
|
||||
addNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string& m_name;
|
||||
const std::string& m_tokenName;
|
||||
const std::set<Id>& m_tokenIds;
|
||||
};
|
||||
|
||||
#endif // GRAPH_FILTER_IMPLEMENTATIONS_H
|
||||
|
||||
Reference in New Issue
Block a user