ui: Added custom tooltipping to code and graph (issue #195)
* Tooltips show node type with access specifier, reference count and fully qualified name * Fields and global variables include the type name * Methods and functinos show whole signature. Gets broken into multiple lines if too long. Included changes: * Upgraded to C++14 * fixed clang warnings * Pass location of .srctrlprj file to build.sh script to load on launch * Split off QtCodeField for showing highlighted and annotated code fom QtCodeArea * removed TokenComponentSignature * added TaskDecoratorDelay bug id = 195
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
#include "data/tooltip/TooltipOrigin.h"
|
||||
|
||||
class MessageFocusIn
|
||||
: public Message<MessageFocusIn>
|
||||
{
|
||||
public:
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds)
|
||||
MessageFocusIn(const std::vector<Id>& tokenIds, TooltipOrigin origin)
|
||||
: tokenIds(tokenIds)
|
||||
, origin(origin)
|
||||
{
|
||||
setIsLogged(false);
|
||||
}
|
||||
@@ -30,6 +33,7 @@ public:
|
||||
}
|
||||
|
||||
const std::vector<Id> tokenIds;
|
||||
const TooltipOrigin origin;
|
||||
};
|
||||
|
||||
#endif //MESSAGE_FOCUS_IN_H
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MESSAGE_TOOLTIP_HIDE_H
|
||||
#define MESSAGE_TOOLTIP_HIDE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageTooltipHide
|
||||
: public Message<MessageTooltipHide>
|
||||
{
|
||||
public:
|
||||
MessageTooltipHide()
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageTooltipHide";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TOOLTIP_HIDE_H
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef MESSAGE_TOOLTIP_SHOW_H
|
||||
#define MESSAGE_TOOLTIP_SHOW_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
#include "data/tooltip/TooltipOrigin.h"
|
||||
#include "data/tooltip/TooltipInfo.h"
|
||||
|
||||
class MessageTooltipShow
|
||||
: public Message<MessageTooltipShow>
|
||||
{
|
||||
public:
|
||||
MessageTooltipShow(TooltipInfo info, TooltipOrigin origin)
|
||||
: tooltipInfo(info)
|
||||
, origin(origin)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageTooltipShow";
|
||||
}
|
||||
|
||||
const TooltipInfo tooltipInfo;
|
||||
const TooltipOrigin origin;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_TOOLTIP_SHOW_H
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageWindowFocus: public Message<MessageWindowFocus>
|
||||
class MessageWindowFocus
|
||||
: public Message<MessageWindowFocus>
|
||||
{
|
||||
public:
|
||||
MessageWindowFocus()
|
||||
MessageWindowFocus(bool focusIn)
|
||||
: focusIn(focusIn)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -14,6 +16,8 @@ public:
|
||||
{
|
||||
return "MessageWindowFocus";
|
||||
}
|
||||
|
||||
const bool focusIn;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_WINDOW_FOCUS_H
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
enum TaskState
|
||||
{
|
||||
STATE_RUNNING,
|
||||
STATE_HOLD,
|
||||
STATE_SUCCESS,
|
||||
STATE_FAILURE
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
|
||||
#include "utility/scheduling/TaskRunner.h"
|
||||
|
||||
TaskDecorator::TaskDecorator()
|
||||
{
|
||||
}
|
||||
@@ -14,7 +16,20 @@ std::shared_ptr<TaskDecorator> TaskDecorator::addChildTask(std::shared_ptr<Task>
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
void TaskDecorator::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecorator::terminate()
|
||||
{
|
||||
doTerminate();
|
||||
}
|
||||
|
||||
void TaskDecorator::doTerminate()
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class TaskRunner;
|
||||
|
||||
class TaskDecorator
|
||||
: public Task
|
||||
, public std::enable_shared_from_this<TaskDecorator>
|
||||
@@ -14,11 +16,14 @@ public:
|
||||
virtual ~TaskDecorator();
|
||||
std::shared_ptr<TaskDecorator> addChildTask(std::shared_ptr<Task> child);
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task) = 0;
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
virtual void terminate();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
|
||||
private:
|
||||
virtual void doTerminate() = 0;
|
||||
virtual void doTerminate();
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_H
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "utility/scheduling/TaskDecoratorDelay.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
TaskDecoratorDelay::TaskDecoratorDelay(size_t delayMS)
|
||||
: m_delayMS(delayMS)
|
||||
, m_delayComplete(delayMS == 0)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_start = TimePoint::now();
|
||||
}
|
||||
|
||||
Task::TaskState TaskDecoratorDelay::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
return m_taskRunner->update(blackboard);
|
||||
}
|
||||
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(SLEEP_TIME_MS));
|
||||
|
||||
m_delayComplete = (TimePoint::now().deltaMS(m_start) >= m_delayMS);
|
||||
|
||||
return Task::STATE_HOLD;
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecoratorDelay::doTerminate()
|
||||
{
|
||||
if (m_delayComplete)
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef TASK_DECORATOR_DELAY_H
|
||||
#define TASK_DECORATOR_DELAY_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "utility/scheduling/TaskDecorator.h"
|
||||
#include "utility/scheduling/TaskRunner.h"
|
||||
#include "utility/TimePoint.h"
|
||||
|
||||
class TaskDecoratorDelay
|
||||
: public TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskDecoratorDelay(size_t delayMS);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doTerminate();
|
||||
|
||||
const size_t m_delayMS;
|
||||
|
||||
TimePoint m_start;
|
||||
bool m_delayComplete;
|
||||
};
|
||||
|
||||
#endif // TASK_DECORATOR_DELAY_H
|
||||
@@ -6,14 +6,6 @@ TaskDecoratorRepeat::TaskDecoratorRepeat(ConditionType condition, TaskState exit
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::setTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
if (task)
|
||||
{
|
||||
m_taskRunner = std::make_shared<TaskRunner>(task);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -48,8 +40,3 @@ void TaskDecoratorRepeat::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_taskRunner->reset();
|
||||
}
|
||||
|
||||
void TaskDecoratorRepeat::doTerminate()
|
||||
{
|
||||
m_taskRunner->terminate();
|
||||
}
|
||||
|
||||
@@ -17,16 +17,12 @@ public:
|
||||
|
||||
TaskDecoratorRepeat(ConditionType condition, TaskState exitState);
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doTerminate();
|
||||
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
const ConditionType m_condition;
|
||||
const TaskState m_exitState;
|
||||
};
|
||||
|
||||
@@ -105,7 +105,7 @@ void TaskGroupParallel::processTaskThreaded(
|
||||
{
|
||||
TaskState state = taskInfo->taskRunner->update(blackboard);
|
||||
|
||||
if (state != STATE_RUNNING)
|
||||
if (state == STATE_SUCCESS || state == STATE_FAILURE)
|
||||
{
|
||||
if (state == STATE_FAILURE)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,10 @@ Task::TaskState TaskGroupSelector::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
m_taskIndex = -1;
|
||||
}
|
||||
else if (state == STATE_HOLD)
|
||||
{
|
||||
return STATE_HOLD;
|
||||
}
|
||||
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ Task::TaskState TaskGroupSequence::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
{
|
||||
m_taskIndex = -1;
|
||||
}
|
||||
else if (state == STATE_HOLD)
|
||||
{
|
||||
return STATE_HOLD;
|
||||
}
|
||||
|
||||
return STATE_RUNNING;
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ void TaskScheduler::processTasks()
|
||||
while (m_taskRunners.size())
|
||||
{
|
||||
std::shared_ptr<TaskRunner> runner = m_taskRunners.front();
|
||||
Task::TaskState state = Task::STATE_RUNNING;
|
||||
|
||||
{
|
||||
m_tasksMutex.unlock();
|
||||
@@ -166,7 +167,8 @@ void TaskScheduler::processTasks()
|
||||
}
|
||||
}
|
||||
|
||||
if (runner->update(blackboard) != Task::STATE_RUNNING)
|
||||
state = runner->update(blackboard);
|
||||
if (state != Task::STATE_RUNNING)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -174,6 +176,11 @@ void TaskScheduler::processTasks()
|
||||
}
|
||||
|
||||
m_taskRunners.pop_front();
|
||||
|
||||
if (state == Task::STATE_HOLD)
|
||||
{
|
||||
m_taskRunners.push_back(runner);
|
||||
}
|
||||
}
|
||||
|
||||
m_terminateRunningTasks = false;
|
||||
|
||||
@@ -256,6 +256,112 @@ namespace utility
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string breakSignature(
|
||||
std::string returnPart, std::string namePart, std::string paramPart,
|
||||
size_t maxLineLength, size_t tabWidth)
|
||||
{
|
||||
namePart = ' ' + namePart;
|
||||
|
||||
size_t totalSize = returnPart.size() + namePart.size() + paramPart.size();
|
||||
if (totalSize <= maxLineLength)
|
||||
{
|
||||
return returnPart + namePart + paramPart;
|
||||
}
|
||||
|
||||
if (paramPart.size())
|
||||
{
|
||||
namePart += paramPart[0];
|
||||
paramPart.erase(0, 1);
|
||||
}
|
||||
|
||||
size_t parenPos = paramPart.rfind(')');
|
||||
std::string endPart;
|
||||
if (parenPos == 0)
|
||||
{
|
||||
namePart += paramPart;
|
||||
paramPart = "";
|
||||
}
|
||||
else if (parenPos != std::string::npos)
|
||||
{
|
||||
endPart = paramPart.substr(parenPos);
|
||||
paramPart = paramPart.substr(0, parenPos);
|
||||
}
|
||||
|
||||
if (paramPart.size() && paramPart.size() + tabWidth - endPart.size() > maxLineLength)
|
||||
{
|
||||
std::vector<std::string> paramLines;
|
||||
while (true)
|
||||
{
|
||||
size_t parenCount = 0;
|
||||
bool split = false;
|
||||
for (size_t i = 0; i < paramPart.size(); i++)
|
||||
{
|
||||
char c = paramPart[i];
|
||||
if (parenCount == 0 && c == ',')
|
||||
{
|
||||
paramLines.push_back(paramPart.substr(0, i + 1));
|
||||
paramPart = paramPart.substr(i + 2);
|
||||
split = true;
|
||||
break;
|
||||
}
|
||||
else if (c == '<' || c == '(')
|
||||
{
|
||||
parenCount++;
|
||||
}
|
||||
else if (c == '>' || c == ')')
|
||||
{
|
||||
parenCount--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!split)
|
||||
{
|
||||
paramLines.push_back(paramPart);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
paramPart = "";
|
||||
for (std::string str : paramLines)
|
||||
{
|
||||
paramPart += "\n\t" + str;
|
||||
size_t length = tabWidth + str.size();
|
||||
maxLineLength = std::max(length, maxLineLength);
|
||||
}
|
||||
}
|
||||
else if (paramPart.size())
|
||||
{
|
||||
paramPart = "\n\t" + paramPart;
|
||||
}
|
||||
|
||||
if (returnPart.size() + namePart.size() <= maxLineLength)
|
||||
{
|
||||
namePart = returnPart + namePart;
|
||||
returnPart = "";
|
||||
}
|
||||
|
||||
std::string sig;
|
||||
|
||||
if (returnPart.size())
|
||||
{
|
||||
sig += returnPart + '\n';
|
||||
}
|
||||
|
||||
sig += namePart;
|
||||
|
||||
if (paramPart.size())
|
||||
{
|
||||
sig += paramPart;
|
||||
}
|
||||
|
||||
if (endPart.size())
|
||||
{
|
||||
sig += '\n' + endPart;
|
||||
}
|
||||
|
||||
return sig;
|
||||
}
|
||||
|
||||
std::string trim(const std::string &str)
|
||||
{
|
||||
auto wsfront = std::find_if_not(str.begin(), str.end(), [](int c){ return std::isspace(c); });
|
||||
|
||||
@@ -47,6 +47,9 @@ namespace utility
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to);
|
||||
|
||||
std::string insertLineBreaksAtBlankSpaces(const std::string& s, size_t maxLineLength);
|
||||
std::string breakSignature(
|
||||
std::string returnPart, std::string namePart, std::string paramPart,
|
||||
size_t maxLineLength, size_t tabWidth);
|
||||
|
||||
std::string trim(const std::string &str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user