logic: code controller
- Renamed MessageActivateTokenLocation to MessageActivateToken, since it uses the Token id (not the TokenLocation id). - Implemented CodeController to add one snippet for each location where the activated token occurred. - Added Semaphore to QtThreadedFunctor to prevent an evil race-condition. - CodeView dispatches message when a token is clicked.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <QObject>
|
||||
#include <QSemaphore>
|
||||
|
||||
class QtThreadedFunctorHelper: public QObject
|
||||
{
|
||||
@@ -15,22 +16,26 @@ private slots:
|
||||
void execute()
|
||||
{
|
||||
m_callback();
|
||||
m_freeCallbacks.release();
|
||||
}
|
||||
|
||||
public:
|
||||
QtThreadedFunctorHelper()
|
||||
: m_freeCallbacks(1)
|
||||
{
|
||||
QObject::connect(this, SIGNAL(signalExecution()), this, SLOT(execute()));
|
||||
}
|
||||
|
||||
void operator()(std::function<void(void)> callback)
|
||||
{
|
||||
m_freeCallbacks.acquire();
|
||||
m_callback = callback;
|
||||
signalExecution();
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(void)> m_callback;
|
||||
QSemaphore m_freeCallbacks;
|
||||
};
|
||||
|
||||
template <typename T1 = void, typename T2 = void, typename T3 = void>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "qt/QtWidgetWrapper.h"
|
||||
#include "qt/utility/QtHighLighter.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
|
||||
QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||
: CodeView(viewLayout)
|
||||
@@ -52,7 +53,8 @@ void QtCodeView::clearCodeSnippets()
|
||||
|
||||
void QtCodeView::activateToken(Id tokenId) const
|
||||
{
|
||||
std::cout << "TODO: activate Token: " << tokenId << std::endl;
|
||||
MessageActivateToken message(tokenId);
|
||||
message.dispatch();
|
||||
}
|
||||
|
||||
void QtCodeView::doAddCodeSnippet(const std::string& str, const TokenLocationFile& locationFile, int startLineNumber)
|
||||
|
||||
Reference in New Issue
Block a user