ui: Colors in SearchView

Show the right colors in SearchView for the different NodeTypes or QueryNodeTyps

Note: add colors to your Applcationsettings like in the template

fortune cookie message = recognition will come from unexpected sources
This commit is contained in:
Andreas Stallinger
2015-03-04 11:55:25 +01:00
parent 284fb336a6
commit da1a6d69c4
32 changed files with 455 additions and 100 deletions
+2 -1
View File
@@ -54,7 +54,8 @@ std::map<std::string, QueryCommand::CommandType> QueryCommand::getCommandTypeMap
}
QueryCommand::QueryCommand(std::string name)
: m_type(COMMAND_INVALID)
: QueryNode(QueryNode::QUERYNODETYPE_COMMAND)
, m_type(COMMAND_INVALID)
{
name.erase(std::remove(name.begin(), name.end(), BOUNDARY), name.end());
m_name = name;
+28 -2
View File
@@ -1,7 +1,8 @@
#include "data/query/QueryNode.h"
QueryNode::QueryNode()
: m_isGroup(false)
QueryNode::QueryNode(QueryNodeType queryNodeType)
: m_nodeType(queryNodeType)
, m_isGroup(false)
, m_isComplete(true)
{
}
@@ -56,3 +57,28 @@ void QueryNode::setIsComplete(bool isComplete)
{
m_isComplete = isComplete;
}
QueryNode::QueryNodeType QueryNode::getQueryNodeType() const
{
return m_nodeType;
}
std::string QueryNode::queryNodeTypeToString(const QueryNodeType& type)
{
switch(type)
{
case QUERYNODETYPE_NONE:
return "none";
case QUERYNODETYPE_COMMAND:
return "command";
case QUERYNODETYPE_TOKEN:
return "token";
case QUERYNODETYPE_OPERATOR:
return "operator";
}
}
std::string QueryNode::getQueryNodeTypeAsString() const
{
return queryNodeTypeToString(m_nodeType);
}
+16 -1
View File
@@ -7,7 +7,17 @@
class QueryNode
{
public:
QueryNode();
enum QueryNodeType
{
QUERYNODETYPE_NONE,
QUERYNODETYPE_TOKEN,
QUERYNODETYPE_COMMAND,
QUERYNODETYPE_OPERATOR
};
static std::string queryNodeTypeToString(const QueryNodeType& type);
QueryNode(QueryNodeType queryNodeType = QUERYNODETYPE_NONE);
virtual ~QueryNode();
virtual bool isCommand() const = 0;
@@ -16,6 +26,7 @@ public:
virtual bool derivedIsComplete() const = 0;
virtual std::string getName() const = 0;
virtual void print(std::ostream& ostream) const = 0;
@@ -27,7 +38,11 @@ public:
bool isComplete() const;
void setIsComplete(bool isComplete);
QueryNodeType getQueryNodeType() const;
std::string getQueryNodeTypeAsString() const;
private:
QueryNodeType m_nodeType;
bool m_isGroup;
bool m_isComplete;
};
+2 -1
View File
@@ -56,7 +56,8 @@ char QueryOperator::getOperator(OperatorType t)
}
QueryOperator::QueryOperator(OperatorType type, bool isImplicit)
: m_type(type)
: QueryNode(QueryNode::QUERYNODETYPE_OPERATOR)
, m_type(type)
, m_isImplicit(isImplicit)
{
}
+1
View File
@@ -6,6 +6,7 @@
#include "utility/utilityString.h"
QueryToken::QueryToken(std::string name)
: QueryNode(QueryNode::QUERYNODETYPE_TOKEN)
{
name.erase(std::remove(name.begin(), name.end(), BOUNDARY), name.end());
std::deque<std::string> names = utility::split(name, DELIMITER);
+10 -5
View File
@@ -67,22 +67,27 @@ std::string QueryTree::getTokenName(const std::string& token)
return token;
}
std::string QueryTree::getTokenTypeName(const std::string& token)
std::string QueryTree::getTokenTypeName(const QueryNode::QueryNodeType& type)
{
return QueryNode::queryNodeTypeToString(type);
}
QueryNode::QueryNodeType QueryTree::getTokenType(const std::string& token)
{
if (token.size() > 2 && token.front() == QueryToken::BOUNDARY && token.back() == QueryToken::BOUNDARY)
{
return "token";
return QueryNode::QUERYNODETYPE_TOKEN;
}
else if (token.size() > 2 && token.front() == QueryCommand::BOUNDARY && token.back() == QueryCommand::BOUNDARY)
{
return "command";
return QueryNode::QUERYNODETYPE_COMMAND;
}
else if (token.size() == 1 && QueryOperator::getOperatorType(token.front()) != QueryOperator::OPERATOR_NONE)
{
return "operator";
return QueryNode::QUERYNODETYPE_OPERATOR;
}
return "none";
return QueryNode::QUERYNODETYPE_NONE;
}
QueryTree::QueryTree()
+3 -1
View File
@@ -6,6 +6,7 @@
#include <ostream>
#include <string>
#include "data/query/QueryNode.h"
#include "data/query/QueryOperator.h"
class QueryTree
@@ -13,7 +14,8 @@ class QueryTree
public:
static std::deque<std::string> tokenizeQuery(const std::string& query);
static std::string getTokenName(const std::string& token);
static std::string getTokenTypeName(const std::string& token);
static QueryNode::QueryNodeType getTokenType(const std::string& token);
static std::string getTokenTypeName(const QueryNode::QueryNodeType& token);
QueryTree();
QueryTree(const std::string& query);