src: use wstring in tooltip and snippet

This commit is contained in:
mlangkabel
2018-02-06 15:54:09 +01:00
parent 3a6a22df2e
commit 6ae9c2eca5
15 changed files with 39 additions and 41 deletions
@@ -40,7 +40,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
}
CodeSnippetParams statsSnippet;
statsSnippet.title = currentProject->getProjectSettingsFilePath().withoutExtension().fileName();
statsSnippet.title = currentProject->getProjectSettingsFilePath().withoutExtension().wFileName();
statsSnippet.startLineNumber = 1;
statsSnippet.endLineNumber = 1;
@@ -660,7 +660,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
{
if (location->getTokenIds().size())
{
params.title = utility::encodeToUtf8(m_storageAccess->getNameHierarchyForNodeId(location->getTokenIds()[0]).getQualifiedName());
params.title = m_storageAccess->getNameHierarchyForNodeId(location->getTokenIds()[0]).getQualifiedName();
params.titleId = location->getLocationId();
}
}
@@ -669,7 +669,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
if (!activeSourceLocations->isWhole() && params.titleId == 0)
{
params.title = activeSourceLocations->getFilePath().str();
params.title = activeSourceLocations->getFilePath().wstr();
}
const SourceLocation* lastSourceLocation =
@@ -682,7 +682,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
{
if (location->getTokenIds().size())
{
params.footer = utility::encodeToUtf8(m_storageAccess->getNameHierarchyForNodeId(location->getTokenIds()[0]).getQualifiedName());
params.footer = m_storageAccess->getNameHierarchyForNodeId(location->getTokenIds()[0]).getQualifiedName();
params.footerId = location->getLocationId();
}
}
@@ -75,7 +75,7 @@ void TooltipController::handleMessage(MessageTooltipHide* message)
void TooltipController::handleMessage(MessageTooltipShow* message)
{
if (message->tooltipInfo.title.size())
if (!message->tooltipInfo.title.empty())
{
requestTooltipShow(std::vector<Id>(), message->tooltipInfo, message->origin);
}
@@ -19,8 +19,8 @@ struct CodeSnippetParams
uint startLineNumber;
uint endLineNumber;
std::string title;
std::string footer;
std::wstring title;
std::wstring footer;
std::string code;
Id titleId;
+9 -9
View File
@@ -25,25 +25,25 @@ int accessKindToInt(AccessKind t)
return t;
}
std::string accessKindToString(AccessKind t)
std::wstring accessKindToString(AccessKind t)
{
switch (t)
{
case ACCESS_NONE:
return "";
return L"";
case ACCESS_PUBLIC:
return "public";
return L"public";
case ACCESS_PROTECTED:
return "protected";
return L"protected";
case ACCESS_PRIVATE:
return "private";
return L"private";
case ACCESS_DEFAULT:
return "default";
return L"default";
case ACCESS_TEMPLATE_PARAMETER:
return "template parameter";
return L"template parameter";
case ACCESS_TYPE_PARAMETER:
return "type parameter";
return L"type parameter";
}
return "";
return L"";
}
+1 -1
View File
@@ -16,6 +16,6 @@ enum AccessKind
AccessKind intToAccessKind(int v);
int accessKindToInt(AccessKind t);
std::string accessKindToString(AccessKind t);
std::wstring accessKindToString(AccessKind t);
#endif // ACCESS_KIND_H
+5 -5
View File
@@ -1703,7 +1703,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
}
const NodeType type = utility::intToType(node.type);
info.title = type.getReadableTypeString();
info.title = type.getReadableTypeWString();
DefinitionKind defKind = DEFINITION_NONE;
const StorageSymbol symbol = m_sqliteIndexStorage.getFirstById<StorageSymbol>(node.id);
@@ -1717,7 +1717,7 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
const StorageComponentAccess access = m_sqliteIndexStorage.getComponentAccessByNodeId(node.id);
if (access.nodeId != 0)
{
info.title = accessKindToString(intToAccessKind(access.type)) + " " + info.title;
info.title = accessKindToString(intToAccessKind(access.type)) + L" " + info.title;
}
}
@@ -1725,16 +1725,16 @@ TooltipInfo PersistentStorage::getTooltipInfoForTokenIds(const std::vector<Id>&
{
if (!getFileNodeComplete(node.id))
{
info.title = "incomplete " + info.title;
info.title = L"incomplete " + info.title;
}
}
else if (defKind == DEFINITION_NONE)
{
info.title = "non-indexed " + info.title;
info.title = L"non-indexed " + info.title;
}
else if (defKind == DEFINITION_IMPLICIT)
{
info.title = "implicit " + info.title;
info.title = L"implicit " + info.title;
}
info.count = 0;
+1 -1
View File
@@ -21,7 +21,7 @@ struct TooltipInfo
return title.size() || snippets.size();
}
std::string title;
std::wstring title;
int count = -1;
std::string countText;
+1 -1
View File
@@ -301,7 +301,7 @@ void QtCodeFileSingle::setFileData(const FileData& file)
m_currentFilePath = file.filePath;
m_titleBar->setMaximized();
if (file.title.size())
if (!file.title.empty())
{
titleButton->setProject(file.title);
titleButton->setIsComplete(true);
+1 -1
View File
@@ -61,7 +61,7 @@ private:
FilePath filePath;
TimeStamp modificationTime;
bool isComplete = false;
std::string title;
std::wstring title;
QtCodeArea* area = nullptr;
};
@@ -82,17 +82,15 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
}
}
void QtCodeFileTitleButton::setProject(const std::string& name)
void QtCodeFileTitleButton::setProject(const std::wstring& name)
{
m_filePath = FilePath();
setText(name.c_str());
setText(QString::fromStdWString(name));
setToolTip("edit project");
std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/edit.png";
setIcon(utility::colorizePixmap(
QPixmap(text.c_str()),
QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr())),
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
));
}
@@ -131,7 +129,7 @@ void QtCodeFileTitleButton::updateFromOther(const QtCodeFileTitleButton* other)
}
else
{
setProject(other->text().toStdString());
setProject(other->text().toStdWString());
}
setModificationTime(other->m_modificationTime);
@@ -18,7 +18,7 @@ public:
void setFilePath(const FilePath& filePath);
void setModificationTime(const TimeStamp modificationTime);
void setIsComplete(bool isComplete);
void setProject(const std::string& name);
void setProject(const std::wstring& name);
void updateTexts();
+4 -4
View File
@@ -78,7 +78,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
if (m_titleString.size() && !params.reduced)
if (!m_titleString.empty() && !params.reduced)
{
m_title = createScopeLine(layout);
if (m_titleId == 0) // title is a file path
@@ -87,7 +87,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
}
else
{
m_title->setText(m_titleString.c_str());
m_title->setText(QString::fromStdWString(m_titleString));
}
connect(m_title, &QPushButton::clicked, this, &QtCodeSnippet::clickedTitle);
}
@@ -95,7 +95,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
m_codeArea = new QtCodeArea(params.startLineNumber, params.code, params.locationFile, navigator, !params.reduced, this);
layout->addWidget(m_codeArea);
if (m_footerString.size())
if (!m_footerString.empty())
{
m_footer = createScopeLine(layout);
if (m_footerId == 0) // footer is a file path
@@ -104,7 +104,7 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* n
}
else
{
m_footer->setText(m_footerString.c_str());
m_footer->setText(QString::fromStdWString(m_footerString));
}
connect(m_footer, &QPushButton::clicked, this, &QtCodeSnippet::clickedFooter);
}
+2 -2
View File
@@ -64,10 +64,10 @@ private:
QtCodeFile* m_file;
Id m_titleId;
std::string m_titleString;
std::wstring m_titleString;
Id m_footerId;
std::string m_footerString;
std::wstring m_footerString;
std::vector<QPushButton*> m_dots;
+1 -1
View File
@@ -34,7 +34,7 @@ void QtTooltip::setTooltipInfo(TooltipInfo info)
{
if (info.title.size())
{
addTitle(info.title.c_str(), info.count, info.countText.c_str());
addTitle(QString::fromStdWString(info.title), info.count, info.countText.c_str());
}
for (TooltipSnippet& snippet : info.snippets)
@@ -302,11 +302,11 @@ void QtGraphEdge::focusIn()
Edge::EdgeType type = (getData() ? getData()->getType() : Edge::EDGE_AGGREGATION);
TooltipInfo info;
info.title = utility::encodeToUtf8(Edge::getReadableTypeString(type));
info.title = Edge::getReadableTypeString(type);
if (type == Edge::EDGE_AGGREGATION && m_direction == TokenComponentAggregation::DIRECTION_NONE)
{
info.title = "bidirectional " + info.title;
info.title = L"bidirectional " + info.title;
}
if (type == Edge::EDGE_AGGREGATION)