ui: added maximize button to CodeSnippets that opens the full file in a separate window
This commit is contained in:
@@ -162,6 +162,7 @@ add_files(
|
||||
utility/messaging/type/MessageLoadProject.h
|
||||
utility/messaging/type/MessageLoadSource.h
|
||||
utility/messaging/type/MessageRefresh.h
|
||||
utility/messaging/type/MessageShowFile.h
|
||||
|
||||
utility/messaging/Message.h
|
||||
utility/messaging/MessageBase.h
|
||||
|
||||
@@ -67,6 +67,19 @@ void CodeController::handleMessage(MessageRefresh* message)
|
||||
getView()->refreshView();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageShowFile* message)
|
||||
{
|
||||
CodeView::CodeSnippetParams params;
|
||||
params.startLineNumber = message->lineNumber;
|
||||
params.activeTokenIds = message->activeTokenIds;
|
||||
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(message->filePath);
|
||||
params.code = textAccess->getText();
|
||||
|
||||
params.locationFile = m_locationAccess->getTokenLocationsForFile(message->filePath);
|
||||
getView()->showCodeFile(params);
|
||||
}
|
||||
|
||||
CodeView* CodeController::getView()
|
||||
{
|
||||
return Controller::getView<CodeView>();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateToken.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageShowFile.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class CodeView;
|
||||
@@ -24,6 +25,7 @@ class CodeController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateToken>
|
||||
, public MessageListener<MessageRefresh>
|
||||
, public MessageListener<MessageShowFile>
|
||||
{
|
||||
public:
|
||||
CodeController(GraphAccess* graphAccess, LocationAccess* locationAccess);
|
||||
@@ -34,6 +36,7 @@ public:
|
||||
private:
|
||||
virtual void handleMessage(MessageActivateToken* message);
|
||||
virtual void handleMessage(MessageRefresh* message);
|
||||
virtual void handleMessage(MessageShowFile* message);
|
||||
|
||||
CodeView* getView();
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ public:
|
||||
|
||||
virtual std::string getName() const;
|
||||
|
||||
virtual void addCodeSnippet(const CodeSnippetParams params) = 0;
|
||||
virtual void showCodeFile(const CodeSnippetParams& params) = 0;
|
||||
virtual void addCodeSnippet(const CodeSnippetParams& params) = 0;
|
||||
virtual void clearCodeSnippets() = 0;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,7 +19,7 @@ void View::setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper)
|
||||
m_widgetWrapper = widgetWrapper;
|
||||
}
|
||||
|
||||
ViewWidgetWrapper* View::getWidgetWrapper()
|
||||
ViewWidgetWrapper* View::getWidgetWrapper() const
|
||||
{
|
||||
return m_widgetWrapper.get();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
void setComponent(Component* component);
|
||||
|
||||
void setWidgetWrapper(std::shared_ptr<ViewWidgetWrapper> widgetWrapper);
|
||||
ViewWidgetWrapper* getWidgetWrapper();
|
||||
ViewWidgetWrapper* getWidgetWrapper() const;
|
||||
|
||||
int getMinWidth() const;
|
||||
int getMinHeight() const;
|
||||
|
||||
@@ -469,19 +469,39 @@ TokenLocationCollection Storage::getTokenLocationsForLocationIds(const std::vect
|
||||
return ret;
|
||||
}
|
||||
|
||||
TokenLocationFile Storage::getTokenLocationsForLinesInFile(
|
||||
const std::string& fileName, unsigned int firstLineNumber, unsigned int lastLineNumber
|
||||
) const
|
||||
TokenLocationFile Storage::getTokenLocationsForFile(const std::string& filePath) const
|
||||
{
|
||||
TokenLocationFile ret(fileName);
|
||||
TokenLocationFile ret(filePath);
|
||||
|
||||
TokenLocationFile* locationFile = m_locationCollection.findTokenLocationFileByPath(fileName);
|
||||
TokenLocationFile* locationFile = m_locationCollection.findTokenLocationFileByPath(filePath);
|
||||
if (!locationFile)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (unsigned int i = firstLineNumber; i <= lastLineNumber; i++)
|
||||
locationFile->forEachTokenLocation(
|
||||
[&](TokenLocation* tokenLocation) -> void
|
||||
{
|
||||
ret.addTokenLocationAsPlainCopy(tokenLocation);
|
||||
}
|
||||
);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TokenLocationFile Storage::getTokenLocationsForLinesInFile(
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const
|
||||
{
|
||||
TokenLocationFile ret(filePath);
|
||||
|
||||
TokenLocationFile* locationFile = m_locationCollection.findTokenLocationFileByPath(filePath);
|
||||
if (!locationFile)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (uint i = firstLineNumber; i <= lastLineNumber; i++)
|
||||
{
|
||||
TokenLocationLine* locationLine = locationFile->findTokenLocationLineByNumber(i);
|
||||
if (!locationLine)
|
||||
|
||||
@@ -86,8 +86,9 @@ public:
|
||||
|
||||
// LocationAccess implementation
|
||||
virtual TokenLocationCollection getTokenLocationsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||
virtual TokenLocationFile getTokenLocationsForFile(const std::string& filePath) const;
|
||||
virtual TokenLocationFile getTokenLocationsForLinesInFile(
|
||||
const std::string& fileName, unsigned int firstLineNumber, unsigned int lastLineNumber
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,8 +14,9 @@ class LocationAccess
|
||||
public:
|
||||
virtual ~LocationAccess();
|
||||
virtual TokenLocationCollection getTokenLocationsForLocationIds(const std::vector<Id>& locationIds) const = 0;
|
||||
virtual TokenLocationFile getTokenLocationsForFile(const std::string& filePath) const = 0;
|
||||
virtual TokenLocationFile getTokenLocationsForLinesInFile(
|
||||
const std::string& fileName, unsigned int firstLineNumber, unsigned int lastLineNumber
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,14 +39,23 @@ TokenLocationCollection LocationAccessProxy::getTokenLocationsForLocationIds(con
|
||||
return TokenLocationCollection();
|
||||
}
|
||||
|
||||
|
||||
TokenLocationFile LocationAccessProxy::getTokenLocationsForLinesInFile(
|
||||
const std::string& fileName, unsigned int firstLineNumber, unsigned int lastLineNumber
|
||||
) const
|
||||
TokenLocationFile LocationAccessProxy::getTokenLocationsForFile(const std::string& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTokenLocationsForLinesInFile(fileName, firstLineNumber, lastLineNumber);
|
||||
return m_subject->getTokenLocationsForFile(filePath);
|
||||
}
|
||||
|
||||
return TokenLocationFile("");
|
||||
}
|
||||
|
||||
TokenLocationFile LocationAccessProxy::getTokenLocationsForLinesInFile(
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTokenLocationsForLinesInFile(filePath, firstLineNumber, lastLineNumber);
|
||||
}
|
||||
|
||||
return TokenLocationFile("");
|
||||
|
||||
@@ -14,8 +14,9 @@ public:
|
||||
|
||||
// LocationAccess implementation
|
||||
virtual TokenLocationCollection getTokenLocationsForLocationIds(const std::vector<Id>& locationIds) const;
|
||||
virtual TokenLocationFile getTokenLocationsForFile(const std::string& filePath) const;
|
||||
virtual TokenLocationFile getTokenLocationsForLinesInFile(
|
||||
const std::string& fileName, unsigned int firstLineNumber, unsigned int lastLineNumber
|
||||
const std::string& filePath, uint firstLineNumber, uint lastLineNumber
|
||||
) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef MESSAGE_SHOW_FILE_H
|
||||
#define MESSAGE_SHOW_FILE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class MessageShowFile: public Message<MessageShowFile>
|
||||
{
|
||||
public:
|
||||
MessageShowFile(const std::string& filePath, uint lineNumber, const std::vector<Id>& activeTokenIds)
|
||||
: filePath(filePath)
|
||||
, lineNumber(lineNumber)
|
||||
, activeTokenIds(activeTokenIds)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageShowFile";
|
||||
}
|
||||
|
||||
const std::string filePath;
|
||||
const uint lineNumber;
|
||||
const std::vector<Id> activeTokenIds;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SHOW_FILE_H
|
||||
Reference in New Issue
Block a user