ui: minimize and maximize buttons for QtCodeFile
This change switches the code view UI to use minimize and maximize buttons within the QtCodeView instead of creating separate windows for each maximized code file. Real icons for the buttons are still missing.
This commit is contained in:
@@ -9,7 +9,7 @@ add_files(
|
||||
data/parser/cxx/name_resolver/CxxTemplateArgumentNameResolver.h
|
||||
data/parser/cxx/name_resolver/CxxTypeNameResolver.cpp
|
||||
data/parser/cxx/name_resolver/CxxTypeNameResolver.h
|
||||
|
||||
|
||||
data/parser/cxx/ASTAction.cpp
|
||||
data/parser/cxx/ASTAction.h
|
||||
data/parser/cxx/ASTActionFactory.cpp
|
||||
@@ -248,6 +248,7 @@ add_files(
|
||||
utility/math/Vector4.h
|
||||
utility/math/VectorBase.h
|
||||
|
||||
utility/messaging/type/MessageActivateFile.h
|
||||
utility/messaging/type/MessageActivateTokenLocation.h
|
||||
utility/messaging/type/MessageActivateTokens.h
|
||||
utility/messaging/type/MessageAutoRefreshChanged.h
|
||||
|
||||
@@ -23,6 +23,11 @@ CodeController::~CodeController()
|
||||
|
||||
const uint CodeController::s_lineRadius = 2;
|
||||
|
||||
void CodeController::handleMessage(MessageActivateFile* message)
|
||||
{
|
||||
MessageActivateTokens(std::vector<Id>(1, m_storageAccess->getTokenIdForFileNode(message->filePath))).dispatch();
|
||||
}
|
||||
|
||||
void CodeController::handleMessage(MessageActivateTokenLocation* message)
|
||||
{
|
||||
if (message->locationId)
|
||||
@@ -140,10 +145,13 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForActiveTok
|
||||
{
|
||||
std::vector<CodeView::CodeSnippetParams> fileSnippets = getSnippetsForFile(file);
|
||||
|
||||
for (CodeView::CodeSnippetParams& params : fileSnippets)
|
||||
if (!file->isWholeCopy)
|
||||
{
|
||||
params.locationFile = m_storageAccess->getTokenLocationsForLinesInFile(
|
||||
file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
|
||||
for (CodeView::CodeSnippetParams& params : fileSnippets)
|
||||
{
|
||||
params.locationFile = m_storageAccess->getTokenLocationsForLinesInFile(
|
||||
file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
if (declarationId != 0)
|
||||
@@ -214,7 +222,8 @@ std::vector<CodeView::CodeSnippetParams> CodeController::getSnippetsForFile(std:
|
||||
params.endLineNumber = std::min<int>(textAccess->getLineCount(), range.end.row + (range.end.strong ? 0 : snippetExpandRange));
|
||||
|
||||
|
||||
std::shared_ptr<TokenLocationFile> tempFile = m_storageAccess->getTokenLocationsForLinesInFile(file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
|
||||
std::shared_ptr<TokenLocationFile> tempFile =
|
||||
m_storageAccess->getTokenLocationsForLinesInFile(file->getFilePath().str(), params.startLineNumber, params.endLineNumber);
|
||||
TokenLocationLine* firstUsedLine = nullptr;
|
||||
for (size_t i = params.startLineNumber; i <= params.endLineNumber && firstUsedLine == nullptr; i++)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageActivateFile.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocation.h"
|
||||
#include "utility/messaging/type/MessageActivateTokens.h"
|
||||
#include "utility/messaging/type/MessageFinishedParsing.h"
|
||||
@@ -24,6 +25,7 @@ class TokenLocationFile;
|
||||
|
||||
class CodeController
|
||||
: public Controller
|
||||
, public MessageListener<MessageActivateFile>
|
||||
, public MessageListener<MessageActivateTokenLocation>
|
||||
, public MessageListener<MessageActivateTokens>
|
||||
, public MessageListener<MessageFinishedParsing>
|
||||
@@ -39,6 +41,7 @@ public:
|
||||
private:
|
||||
static const uint s_lineRadius;
|
||||
|
||||
virtual void handleMessage(MessageActivateFile* message);
|
||||
virtual void handleMessage(MessageActivateTokenLocation* message);
|
||||
virtual void handleMessage(MessageActivateTokens* message);
|
||||
virtual void handleMessage(MessageFinishedParsing* message);
|
||||
|
||||
+31
-12
@@ -109,18 +109,7 @@ std::set<FilePath> Storage::getDependingFilePathsAndRemoveFileNodes(const std::s
|
||||
|
||||
for (const FilePath& filePath : filePaths)
|
||||
{
|
||||
SearchNode* searchNode = m_tokenIndex.getNode(filePath.fileName());
|
||||
if (!searchNode || searchNode->getTokenIds().size() != 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Node* fileNode = m_graph.getNodeById(searchNode->getFirstTokenId());
|
||||
if (!fileNode->isType(Node::NODE_FILE))
|
||||
{
|
||||
LOG_ERROR("Node is not of type file.");
|
||||
continue;
|
||||
}
|
||||
Node* fileNode = findFileNode(filePath);
|
||||
|
||||
if (!fileNode->getComponent<TokenComponentFilePath>() ||
|
||||
fileNode->getComponent<TokenComponentFilePath>()->getFilePath() != filePath)
|
||||
@@ -956,6 +945,17 @@ std::vector<Id> Storage::getTokenIdsForQuery(std::string query) const
|
||||
return outGraph.getTokenIds();
|
||||
}
|
||||
|
||||
Id Storage::getTokenIdForFileNode(const FilePath& filePath) const
|
||||
{
|
||||
Node* fileNode = findFileNode(filePath);
|
||||
if (fileNode)
|
||||
{
|
||||
return fileNode->getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TokenLocationCollection Storage::getTokenLocationsForTokenIds(const std::vector<Id>& tokenIds) const
|
||||
{
|
||||
TokenLocationCollection ret;
|
||||
@@ -1006,6 +1006,7 @@ std::shared_ptr<TokenLocationFile> Storage::getTokenLocationsForFile(const std::
|
||||
ret->addTokenLocationAsPlainCopy(tokenLocation);
|
||||
}
|
||||
);
|
||||
ret->isWholeCopy = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1165,6 +1166,24 @@ Node* Storage::addFileNode(const FilePath& filePath)
|
||||
return fileNode;
|
||||
}
|
||||
|
||||
Node* Storage::findFileNode(const FilePath& filePath) const
|
||||
{
|
||||
SearchNode* searchNode = m_tokenIndex.getNode(filePath.fileName());
|
||||
if (!searchNode || searchNode->getTokenIds().size() != 1)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node* fileNode = m_graph.getNodeById(searchNode->getFirstTokenId());
|
||||
if (!fileNode->isType(Node::NODE_FILE))
|
||||
{
|
||||
LOG_ERROR("Node is not of type file.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fileNode;
|
||||
}
|
||||
|
||||
TokenComponentAccess::AccessType Storage::convertAccessType(ParserClient::AccessType access) const
|
||||
{
|
||||
switch (access)
|
||||
|
||||
@@ -119,6 +119,7 @@ public:
|
||||
virtual std::vector<Id> getActiveTokenIdsForLocationId(Id locationId) const;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForQuery(std::string query) const;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||
|
||||
virtual TokenLocationCollection getTokenLocationsForTokenIds(const std::vector<Id>& tokenIds) const;
|
||||
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForFile(const std::string& filePath) const;
|
||||
@@ -140,6 +141,7 @@ private:
|
||||
Node* addNodeHierarchyWithDistinctSignature(Node::NodeType type, const ParseFunction& function);
|
||||
|
||||
Node* addFileNode(const FilePath& filePath);
|
||||
Node* findFileNode(const FilePath& filePath) const;
|
||||
|
||||
TokenComponentAccess::AccessType convertAccessType(ParserClient::AccessType access) const;
|
||||
TokenComponentAccess* addAccess(Node* node, ParserClient::AccessType access);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "utility/types.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
#include "data/graph/Node.h"
|
||||
#include "data/search/SearchMatch.h"
|
||||
@@ -32,6 +33,7 @@ public:
|
||||
virtual std::vector<Id> getActiveTokenIdsForLocationId(Id locationId) const = 0;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForQuery(std::string query) const = 0;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const = 0;
|
||||
|
||||
virtual TokenLocationCollection getTokenLocationsForTokenIds(const std::vector<Id>& tokenIds) const = 0;
|
||||
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForFile(const std::string& filePath) const = 0;
|
||||
|
||||
@@ -112,6 +112,16 @@ std::vector<Id> StorageAccessProxy::getTokenIdsForQuery(std::string query) const
|
||||
return std::vector<Id>();
|
||||
}
|
||||
|
||||
Id StorageAccessProxy::getTokenIdForFileNode(const FilePath& filePath) const
|
||||
{
|
||||
if (hasSubject())
|
||||
{
|
||||
return m_subject->getTokenIdForFileNode(filePath);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TokenLocationCollection StorageAccessProxy::getTokenLocationsForTokenIds(const std::vector<Id>& tokenIds) const
|
||||
{
|
||||
if (hasSubject())
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
virtual std::vector<Id> getActiveTokenIdsForLocationId(Id locationId) const;
|
||||
|
||||
virtual std::vector<Id> getTokenIdsForQuery(std::string query) const;
|
||||
virtual Id getTokenIdForFileNode(const FilePath& filePath) const;
|
||||
|
||||
virtual TokenLocationCollection getTokenLocationsForTokenIds(const std::vector<Id>& tokenIds) const;
|
||||
virtual std::shared_ptr<TokenLocationFile> getTokenLocationsForFile(const std::string& filePath) const;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_ACTIVATE_FILE_H
|
||||
#define MESSAGE_ACTIVATE_FILE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
class MessageActivateFile: public Message<MessageActivateFile>
|
||||
{
|
||||
public:
|
||||
MessageActivateFile(const FilePath& filePath)
|
||||
: filePath(filePath)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageActivateFile";
|
||||
}
|
||||
|
||||
const FilePath filePath;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ACTIVATE_FILE_H
|
||||
Reference in New Issue
Block a user