build: Treat warnings as errors (#923)

* squash and rebase andronov-alexey:treat_warnings_as_errors from pull request #850
* fix remaining warnings in java lib
This commit is contained in:
Malte Langkabel
2020-02-14 16:34:04 +01:00
committed by GitHub
parent e5c1a118d7
commit a30f47e27f
112 changed files with 634 additions and 430 deletions
+26
View File
@@ -7,6 +7,7 @@ set(BUILD_CXX_LANGUAGE_PACKAGE OFF CACHE BOOL "Add C and C++ support to the Sour
set(BUILD_JAVA_LANGUAGE_PACKAGE OFF CACHE BOOL "Add Java support to the Sourcetrail indexer.")
set(BUILD_PYTHON_LANGUAGE_PACKAGE OFF CACHE BOOL "Add Python support to the Sourcetrail indexer.")
set(DOCKER_BUILD OFF CACHE BOOL "Build runs in Docker")
set(TREAT_WARNINGS_AS_ERRORS ON CACHE BOOL "Treat compiler warnings as errors")
#set (CMAKE_VERBOSE_MAKEFILE ON)
@@ -88,6 +89,31 @@ if (DOCKER_BUILD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
endif()
if (TREAT_WARNINGS_AS_ERRORS)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Visual Studio 2017 version 15.9 <= Version <= Visual Studio 2019 Version 16.4
if ((MSVC_VERSION GREATER_EQUAL 1916) AND (MSVC_VERSION LESS_EQUAL 1924))
# Warning 4003: not enough actual parameters for macro 'identifier'
# Warning 4250: 'class1' inherits 'class2::member' via dominance
set(WARNINGS_LIST "/wd4003 /wd4250")
set(CMAKE_CXX_WARNINGS_FLAGS "/experimental:external /external:anglebrackets /external:W0 /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNINGS_FLAGS} ${WARNINGS_LIST}")
# Treat linker warnings as errors
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WX")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /WX")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WX")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /WX")
message(STATUS "'Treat warnings as errors' policy is enabled")
else()
message(STATUS "'Treat warnings as errors' policy is disabled")
endif()
else()
message(STATUS "'Treat warnings as errors' policy is disabled")
endif()
endif()
# For debugging the release build on linux
#if (UNIX AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
#add_definitions(-fno-omit-frame-pointer)
+3
View File
@@ -95,10 +95,13 @@ int main(int argc, char *argv[])
{
QCoreApplication::addLibraryPath(QStringLiteral("."));
#pragma warning(push)
#pragma warning(disable : 4996)
if (utility::getOsType() == OS_LINUX && std::getenv("SOURCETRAIL_VIA_SCRIPT") == nullptr)
{
std::cout << "ERROR: Please run Sourcetrail via the Sourcetrail.sh script!" << std::endl;
}
#pragma warning(pop)
QApplication::setApplicationName(QStringLiteral("Sourcetrail"));
+1 -1
View File
@@ -450,7 +450,7 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
}
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
while (recentProjects.size() > appSettings->getMaxRecentProjectsCount())
while (static_cast<int>(recentProjects.size()) > appSettings->getMaxRecentProjectsCount())
{
recentProjects.pop_back();
}
+22 -17
View File
@@ -381,7 +381,9 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
if (message->inIDE)
{
MessageMoveIDECursor(filePath, lineNumber, columnNumber).dispatch();
MessageMoveIDECursor(
filePath, static_cast<unsigned int>(lineNumber), static_cast<unsigned int>(columnNumber))
.dispatch();
return;
}
@@ -471,10 +473,10 @@ void CodeController::handleMessage(MessageShowError* message)
void CodeController::handleMessage(MessageShowReference* message)
{
m_referenceIndex = message->refIndex;
m_referenceIndex = static_cast<int>(message->refIndex);
bool replayed = message->isReplayed();
if (m_referenceIndex >= 0 && m_referenceIndex < m_references.size())
if (m_referenceIndex >= 0 && m_referenceIndex < static_cast<int>(m_references.size()))
{
const Reference& ref = m_references[m_referenceIndex];
m_codeParams.activeLocationIds = {ref.locationId};
@@ -641,7 +643,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
activeSourceLocations->getFilePath(), showsErrors);
size_t lineCount = textAccess->getLineCount();
SnippetMerger fileScopedMerger(1, lineCount);
SnippetMerger fileScopedMerger(1, static_cast<int>(lineCount));
std::map<int, std::shared_ptr<SnippetMerger>> mergers;
std::shared_ptr<SourceLocationFile> scopeLocations =
@@ -657,8 +659,9 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
activeSourceLocations->getFilePath(), LOCATION_COMMENT);
commentLocations->forEachStartSourceLocation([&](SourceLocation* location) {
atomicRanges.push_back(SnippetMerger::Range(
SnippetMerger::Border(location->getLineNumber(), false),
SnippetMerger::Border(location->getOtherLocation()->getLineNumber(), false)));
SnippetMerger::Border(static_cast<int>(location->getLineNumber()), false),
SnippetMerger::Border(
static_cast<int>(location->getOtherLocation()->getLineNumber()), false)));
});
atomicRanges = SnippetMerger::Range::mergeAdjacent(atomicRanges);
@@ -673,7 +676,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
params.startLineNumber = std::max<int>(
1, range.start.row - (range.start.strong ? 0 : snippetExpandRange));
params.endLineNumber = std::min<int>(
lineCount, range.end.row + (range.end.strong ? 0 : snippetExpandRange));
static_cast<int>(lineCount), range.end.row + (range.end.strong ? 0 : snippetExpandRange));
params.locationFile = activeSourceLocations->getFilteredByLines(
params.startLineNumber, params.endLineNumber);
@@ -712,8 +715,9 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
params.footer = activeSourceLocations->getFilePath().wstr();
}
for (const std::string& line:
textAccess->getLines(params.startLineNumber, params.endLineNumber))
for (const std::string& line: textAccess->getLines(
static_cast<unsigned int>(params.startLineNumber),
static_cast<unsigned int>(params.endLineNumber)))
{
params.code += line;
}
@@ -731,7 +735,8 @@ std::shared_ptr<SnippetMerger> CodeController::buildMergerHierarchy(
std::map<int, std::shared_ptr<SnippetMerger>>& mergers) const
{
std::shared_ptr<SnippetMerger> currentMerger = std::make_shared<SnippetMerger>(
location->getStartLocation()->getLineNumber(), location->getEndLocation()->getLineNumber());
static_cast<int>(location->getStartLocation()->getLineNumber()),
static_cast<int>(location->getEndLocation()->getLineNumber()));
const SourceLocation* scopeLocation = getSourceLocationOfParentScope(
location->getLineNumber(), scopeLocations);
@@ -743,11 +748,11 @@ std::shared_ptr<SnippetMerger> CodeController::buildMergerHierarchy(
std::shared_ptr<SnippetMerger> nextMerger;
std::map<int, std::shared_ptr<SnippetMerger>>::iterator it = mergers.find(
scopeLocation->getLocationId());
static_cast<int>(scopeLocation->getLocationId()));
if (it == mergers.end())
{
nextMerger = buildMergerHierarchy(scopeLocation, scopeLocations, fileScopedMerger, mergers);
mergers[scopeLocation->getLocationId()] = nextMerger;
mergers[static_cast<int>(scopeLocation->getLocationId())] = nextMerger;
}
else
{
@@ -986,7 +991,7 @@ void CodeController::iterateReference(bool next)
{
if (m_referenceIndex < 1)
{
m_referenceIndex = m_references.size() - 1;
m_referenceIndex = static_cast<int>(m_references.size()) - 1;
}
else
{
@@ -1009,7 +1014,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
m_localReferenceIndex++;
if (m_localReferenceIndex == m_localReferences.size())
if (m_localReferenceIndex == static_cast<int>(m_localReferences.size()))
{
m_localReferenceIndex = 0;
}
@@ -1018,7 +1023,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
if (m_localReferenceIndex < 1)
{
m_localReferenceIndex = m_localReferences.size() - 1;
m_localReferenceIndex = static_cast<int>(m_localReferences.size()) - 1;
}
else
{
@@ -1036,7 +1041,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
if (m_references[i].locationId == ref.locationId)
{
m_referenceIndex = i;
m_referenceIndex = static_cast<int>(i);
}
}
}
@@ -1382,7 +1387,7 @@ void CodeController::showFirstActiveReference(Id tokenId, bool updateView)
if (!firstReference.tokenId)
{
firstReference = ref;
referenceIndex = i;
referenceIndex = static_cast<int>(i);
}
}
@@ -73,7 +73,7 @@ void ErrorController::handleMessage(MessageErrorCountUpdate* message)
ErrorFilter filter = getView()->getErrorFilter();
int room = filter.limit - m_errorCount;
int room = static_cast<int>(filter.limit) - static_cast<int>(m_errorCount);
if (room > 0)
{
filter.limit = 0;
@@ -1269,7 +1269,7 @@ void GraphController::bundleNodesAndEdgesMatching(
bundleNode->name = name;
bundleNode->visible = true;
for (int i = matchedNodeIndices.size() - 1; i >= 0; i--)
for (int i = static_cast<int>(matchedNodeIndices.size()) - 1; i >= 0; i--)
{
std::shared_ptr<DummyNode> node = m_dummyNodes[matchedNodeIndices[i]];
node->visible = false;
@@ -1366,7 +1366,7 @@ std::shared_ptr<DummyNode> GraphController::bundleNodesMatching(
bundleNode->name = name;
bundleNode->visible = true;
for (int i = matchedNodes.size() - 1; i >= 0; i--)
for (int i = static_cast<int>(matchedNodes.size()) - 1; i >= 0; i--)
{
std::shared_ptr<DummyNode> node = *matchedNodes[i];
node->visible = false;
@@ -1484,7 +1484,7 @@ void GraphController::addCharacterIndex()
m_dummyNodes.insert(m_dummyNodes.end(), newNodes.begin(), newNodes.end());
// Add index characters
char character = 0;
wchar_t character = 0;
for (size_t i = 0; i < m_dummyNodes.size(); i++)
{
if (!m_dummyNodes[i]->visible || !m_dummyNodes[i]->name.size())
@@ -1950,7 +1950,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
if (node->isGraphNode())
{
node->name = utility::elide(node->name, utility::ELIDE_RIGHT, node->active ? 100 : 50);
width = margins.charWidth * node->name.size();
width = static_cast<int>(margins.charWidth * node->name.size());
if (node->data->getType().isCollapsible() && node->data->getChildCount() > 0)
{
@@ -1959,11 +1959,11 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
else if (node->isBundleNode() || node->isTextNode())
{
width = margins.charWidth * node->name.size();
width = static_cast<int>(margins.charWidth * node->name.size());
}
else if (node->isGroupNode())
{
width = margins.charWidth * node->name.size() + 5;
width = static_cast<int>(margins.charWidth * node->name.size() + 5);
}
width += margins.iconWidth;
@@ -1982,7 +1982,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
else if (subNode->isQualifierNode())
{
subNode->position.y = margins.top + margins.charHeight / 2;
subNode->position.y = static_cast<int>(margins.top + margins.charHeight / 2);
width += 5;
continue;
}
@@ -2027,7 +2027,10 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
case GroupLayout::SKEWED:
ListLayouter::layoutSkewed(
&node->subNodes, margins.spacingX, margins.spacingY, viewSize.x() * 1.5);
&node->subNodes,
margins.spacingX,
margins.spacingY,
static_cast<int>(viewSize.x() * 1.5));
break;
case GroupLayout::BUCKET:
@@ -2060,13 +2063,16 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
Vec2i size = ListLayouter::offsetNodes(
node->subNodes, margins.top + margins.charHeight + margins.spacingA, margins.left);
node->subNodes,
static_cast<int>(margins.top + margins.charHeight + margins.spacingA),
margins.left);
width = std::max(size.x(), width);
height = size.y();
node->size.x = margins.left + width + margins.right;
node->size.y = margins.top + margins.charHeight + margins.spacingA + height + margins.bottom;
node->size.y = static_cast<int>(
margins.top + margins.charHeight + margins.spacingA + height + margins.bottom);
for (const std::shared_ptr<DummyNode>& subNode: node->subNodes)
{
@@ -2158,7 +2164,7 @@ void GraphController::layoutToGrid(DummyNode* node) const
if (subNode->isAccessNode())
{
subNode->size.x = subNode->size.x + incX;
subNode->size.x = static_cast<int>(subNode->size.x + incX);
lastAccessNode = subNode.get();
}
else if (subNode->isExpandToggleNode())
@@ -2169,15 +2175,15 @@ void GraphController::layoutToGrid(DummyNode* node) const
if (lastAccessNode)
{
lastAccessNode->size.y = lastAccessNode->size.y + incY;
lastAccessNode->size.y = static_cast<int>(lastAccessNode->size.y + incY);
if (expandToggleNode)
{
expandToggleNode->position.x = expandToggleNode->position.x + incX;
expandToggleNode->position.x = static_cast<int>(expandToggleNode->position.x + incX);
}
node->size.x = width;
node->size.y = height;
node->size.x = static_cast<int>(width);
node->size.y = static_cast<int>(height);
}
}
@@ -2409,8 +2415,8 @@ void GraphController::createLegendGraph()
addText(L"Legend", 6, Vec2i(0, 0));
size_t y = 50;
size_t x = 0;
int y = 50;
int x = 0;
// Layout
{
@@ -2474,12 +2480,12 @@ void GraphController::createLegendGraph()
x = 0;
y = 610;
size_t dx = 200;
size_t dy = 50;
int dx = 200;
int dy = 50;
// Nodes
{
size_t i = 0;
int i = 0;
addText(L"Nodes", 3, Vec2i(x, y));
addNode(NodeType::NODE_FILE, L"File", Vec2i(x, y + dy * ++i));
@@ -2581,7 +2587,7 @@ void GraphController::createLegendGraph()
// Edges
{
addText(L"Edges", 3, Vec2i(x, y));
size_t i = 0;
int i = 0;
{
addText(L"file include", 0, Vec2i(x, y + dy * ++i));
@@ -628,7 +628,7 @@ void UndoRedoController::updateHistory()
const size_t historyListSize = 50;
std::vector<SearchMatch> historyListMatches;
size_t index = 0;
int index = 0;
int currentIndex = -1;
m_historyOffset = 0;
@@ -36,8 +36,9 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector<std::shared_ptr
{
std::vector<int> maxWidths = std::vector<int>(cols, 0);
size_t nodesPerCol =
(cols == 1 ? visibleNodes.size()
: std::ceil((visibleNodes.size() + cols - 1) / double(cols)));
(cols == 1
? visibleNodes.size()
: static_cast<size_t>(std::ceil((visibleNodes.size() + cols - 1) / double(cols))));
int maxHeight = 0;
int height = -gapY;
@@ -86,7 +87,8 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector<std::shared_ptr
size_t nodesPerCol =
(colsFinal == 1 ? visibleNodes.size()
: std::ceil((visibleNodes.size() + colsFinal - 1) / double(colsFinal)));
: static_cast<size_t>(
std::ceil((visibleNodes.size() + colsFinal - 1) / double(colsFinal))));
std::shared_ptr<DummyNode> lastTextNode;
for (size_t i = 0; i < visibleNodes.size(); i++)
@@ -151,9 +153,9 @@ void ListLayouter::layoutSquare(std::vector<std::shared_ptr<DummyNode>>* nodes,
}
int diff = -1;
size_t cols = 1;
int cols = 1;
for (size_t i = cols; i < 100; i++)
for (int i = cols; i < 100; i++)
{
if (layoutSquareInternal(
visibleNodes, Vec2i(maxWidth, totalHeight * i / 100), Vec2i(gapX, gapY)))
@@ -134,7 +134,7 @@ NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreat
}
else
{
const int subMessageCount = subMessages.size();
const size_t subMessageCount = subMessages.size();
const std::wstring cdbPath = subMessages[1];
if (!cdbPath.empty())
@@ -309,8 +309,8 @@ void TrailLayouter::buildColumns()
{
for (const std::shared_ptr<TrailNode>& node: m_allNodes)
{
int level = node->level + 1;
for (int i = m_nodesPerCol.size(); i <= level; i++)
const int level = node->level + 1;
for (int i = static_cast<int>(m_nodesPerCol.size()); i <= level; i++)
{
m_nodesPerCol.push_back(std::vector<TrailNode*>());
}
@@ -365,7 +365,7 @@ void TrailLayouter::reduceEdgeCrossings()
}
}
float value = j;
float value = float(j);
if (count)
{
value = float(sum) / count;
@@ -508,7 +508,7 @@ void TrailLayouter::moveNodesToAveragePosition(std::vector<TrailNode*> nodes, bo
{
averagePosition += p.first;
}
averagePosition /= averagePositions.size();
averagePosition /= static_cast<int>(averagePositions.size());
std::multimap<int, int> distanceFromAveragePosition;
+15 -10
View File
@@ -145,7 +145,7 @@ void GraphViewStyle::loadStyleSettings()
s_edgeColors.clear();
s_screenMatchColors.clear();
s_gridCellPadding = getCharHeight(NodeType::STYLE_BIG_NODE) - 8;
s_gridCellPadding = static_cast<int>(getCharHeight(NodeType::STYLE_BIG_NODE) - 8);
s_gridCellSize = s_gridCellPadding / 2;
}
@@ -316,7 +316,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode()
NodeMargins margins;
margins.left = margins.right = margins.top = margins.bottom = 6;
margins.minWidth = margins.charHeight = getFontSizeOfExpandToggleNode();
margins.charHeight = static_cast<float>(getFontSizeOfExpandToggleNode());
margins.minWidth = static_cast<int>(margins.charHeight);
return margins;
}
@@ -332,7 +333,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfTextNode(int fontSizeDif
margins.left = margins.right = 0;
margins.top = margins.bottom = 6;
margins.minWidth = margins.charHeight = getFontSizeOfTextNode(fontSizeDiff);
margins.charHeight = static_cast<float>(getFontSizeOfTextNode(fontSizeDiff));
margins.minWidth = static_cast<int>(margins.charHeight);
margins.charWidth = getCharWidth(getFontNameOfTextNode(), getFontSizeOfTextNode(fontSizeDiff));
@@ -357,7 +359,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
if (hasName)
{
margins.minWidth = margins.charHeight = getFontSizeOfGroupNode();
margins.charHeight = static_cast<float>(getFontSizeOfGroupNode());
margins.minWidth = static_cast<int>(margins.charHeight);
}
margins.charWidth = getCharWidth(NodeType::STYLE_GROUP);
@@ -618,7 +621,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
{
EdgeStyle style;
style.width = isActive ? 4 : 2;
style.width = isActive ? 4.0f : 2.0f;
style.zValue = isActive ? 5 : 2;
if (isTrailEdge)
@@ -688,7 +691,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
style.verticalOffset = 0;
style.cornerRadius = 7;
style.zValue = isActive ? 2 : -3;
style.width = isActive ? 3 : 2;
style.width = isActive ? 3.0f : 2.0f;
if (isTrailEdge)
{
@@ -725,13 +728,15 @@ int GraphViewStyle::toGridOffset(int x)
{
if (x > 0)
{
return std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize);
return static_cast<int>(
std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize));
}
else
{
return std::floor(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize);
return static_cast<int>(
std::floor(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize));
}
}
@@ -26,7 +26,7 @@ CodeSnippetParams CodeSnippetParams::merge(const CodeSnippetParams& a, const Cod
std::string code = first->code;
std::string secondCode = second->code;
int secondCodeStartIndex = 0;
size_t secondCodeStartIndex = 0;
for (size_t i = second->startLineNumber; i <= first->endLineNumber; i++)
{
secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1;
+1 -1
View File
@@ -162,7 +162,7 @@ NodeTypeSet::NodeTypeSet(NodeTypeSet::MaskType typeMask): m_nodeTypeMask(typeMas
NodeTypeSet::MaskType NodeTypeSet::nodeTypeToMask(const NodeType& nodeType)
{
// todo: convert to mask if ids are not power of two anymore
return nodeType.getId();
return static_cast<MaskType>(nodeType.getId());
}
const std::vector<NodeType> NodeTypeSet::s_allNodeTypes = {
+2 -2
View File
@@ -36,7 +36,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
m_storage->optimizeMemory();
m_dialogView->hideUnknownProgressDialog();
float time = TimeStamp::durationSeconds(start);
double time = TimeStamp::durationSeconds(start);
if (blackboard->exists("clear_time"))
{
@@ -85,7 +85,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
sourceFileCount,
stats.completedFileCount,
stats.fileCount,
time,
static_cast<float>(time),
errorInfo,
interruptedIndexing,
shallowIndexing);
@@ -11,7 +11,7 @@ void FullTextSearchIndex::addFile(Id fileId, const std::wstring& fileContent)
LOG_ERROR("empty file not added to fulltextsearch index");
}
if (fileContent.size() >= std::numeric_limits<int>::max())
if (static_cast<int>(fileContent.size()) >= std::numeric_limits<int>::max())
{
LOG_ERROR("file too big not added to fulltextsearch index");
}
+4 -4
View File
@@ -46,7 +46,7 @@ void SuffixArray::printLCP() const
std::vector<int> SuffixArray::buildLCP()
{
const int n = m_array.size();
const int n = static_cast<int>(m_array.size());
std::vector<int> lcp(n, 0);
std::vector<int> invSuff(n, 0);
@@ -89,8 +89,8 @@ std::vector<int> SuffixArray::searchForTerm(const std::wstring& searchTerm) cons
std::wstring term = searchTerm;
std::transform(term.begin(), term.end(), term.begin(), ::towlower);
const int termLength = term.length();
const int textLength = m_text.length();
const int termLength = static_cast<int>(term.length());
const int textLength = static_cast<int>(m_text.length());
int l = -1;
int r = textLength;
int m;
@@ -131,7 +131,7 @@ std::vector<int> SuffixArray::searchForTerm(const std::wstring& searchTerm) cons
std::vector<int> SuffixArray::buildSuffixArray()
{
const int n = m_text.length();
const int n = static_cast<int>(m_text.length());
std::vector<suffix> suffixes;
suffixes.reserve(n);
@@ -25,7 +25,7 @@ std::shared_ptr<TokenComponent> TokenComponentAggregation::copy() const
int TokenComponentAggregation::getAggregationCount() const
{
return m_ids.size();
return static_cast<int>(m_ids.size());
}
std::set<Id> TokenComponentAggregation::getAggregationIds() const
+1 -1
View File
@@ -268,7 +268,7 @@ bool TaskBuildIndex::fetchIntermediateStorages(std::shared_ptr<Blackboard> black
std::shared_ptr<InterprocessIntermediateStorageManager> storageManager =
m_interprocessIntermediateStorageManagers[finishedProcessId - 1];
int storageCount = storageManager->getIntermediateStorageCount();
const size_t storageCount = storageManager->getIntermediateStorageCount();
if (!storageCount)
{
break;
@@ -89,7 +89,10 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
for (size_t i = 1 /*this method is counting as the first thread*/; i < m_indexerThreadCount; i++)
{
indexerThreads.push_back(std::make_shared<std::thread>(
&TaskExecuteCustomCommands::executeParallelIndexerCommands, this, i, blackboard));
&TaskExecuteCustomCommands::executeParallelIndexerCommands,
this,
static_cast<int>(i),
blackboard));
}
while (!m_interrupted && !m_serialCommands.empty())
@@ -138,7 +141,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
void TaskExecuteCustomCommands::doExit(std::shared_ptr<Blackboard> blackboard)
{
m_storage.reset();
const float duration = TimeStamp::durationSeconds(m_start);
const float duration = static_cast<float>(TimeStamp::durationSeconds(m_start));
blackboard->update<float>(
"index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
@@ -336,7 +339,7 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora
}
const std::wstring token = utility::decodeFromUtf8(
textAccess->getLine(startLoc->getLineNumber())
textAccess->getLine(static_cast<unsigned int>(startLoc->getLineNumber()))
.substr(
startLoc->getColumnNumber() - 1,
endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1));
@@ -64,6 +64,13 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
indexerCommand.getLanguageStandard(),
indexerCommand.getClassPaths());
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
case PYTHON:
LOG_ERROR(
L"Cannot convert shared IndexerCommand for file: " +
indexerCommand.getSourceFilePath().wstr() + L". The type is unknown.");
break;
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
default:
LOG_ERROR(
L"Cannot convert shared IndexerCommand for file: " +
@@ -59,8 +59,11 @@ private:
CXX,
#endif // BUILD_CXX_LANGUAGE_PACKAGE
#if BUILD_JAVA_LANGUAGE_PACKAGE
JAVA
JAVA,
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
PYTHON,
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
};
Type getType() const;
@@ -230,5 +230,5 @@ Id SharedIntermediateStorage::getNextId() const
void SharedIntermediateStorage::setNextId(const Id nextId)
{
m_nextId = nextId;
m_nextId = static_cast<int>(nextId);
}
+2 -2
View File
@@ -229,7 +229,7 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByTypes(
size_t typeMask = 0;
for (LocationType type: types)
{
typeMask |= 1 << type;
typeMask |= static_cast<size_t>(1) << type;
}
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(
@@ -237,7 +237,7 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByTypes(
for (const std::shared_ptr<SourceLocation>& location: m_locations)
{
if ((1 << location->getType()) & typeMask)
if ((static_cast<size_t>(1) << location->getType()) & typeMask)
{
ret->addSourceLocationCopy(location.get());
}
+1 -1
View File
@@ -36,7 +36,7 @@ Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskParseWrapper::doExit(std::shared_ptr<Blackboard> blackboard)
{
float duration = TimeStamp::durationSeconds(m_start);
float duration = static_cast<float>(TimeStamp::durationSeconds(m_start));
blackboard->update<float>(
"index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
+4 -3
View File
@@ -439,12 +439,13 @@ int SearchIndex::scoreText(const std::wstring& text, const std::vector<size_t>&
int noLetterScore = 0;
int firstLetterScore = 0;
for (size_t i = 0; i < indices.size(); i++)
for (int i = 0; i < static_cast<int>(indices.size()); i++)
{
// unmatched and consecutive
if (i > 0)
{
unmatchedLetterScore += (indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus;
unmatchedLetterScore += static_cast<int>(
(indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus);
consecutiveLetterScore += (indices[i] - indices[i - 1] == 1) ? consecutiveLetterBonus : 0;
}
@@ -497,7 +498,7 @@ SearchResult SearchIndex::rescoreText(
std::vector<size_t> textIndices;
// match is already within text
int newIdx = indices[0] - (fulltext.size() - text.size());
const int newIdx = static_cast<int>(indices[0] - (fulltext.size() - text.size()));
if (newIdx >= 0)
{
for (size_t idx: indices)
+1 -1
View File
@@ -33,7 +33,7 @@ void IntermediateStorage::clear()
size_t IntermediateStorage::getByteSize(size_t stringSize) const
{
unsigned int byteSize = 0;
size_t byteSize = 0;
for (const StorageFile& storageFile: getStorageFiles())
{
+7 -5
View File
@@ -625,7 +625,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
/*no ref here!*/ fileResults,
&collection,
&collectionMutex]() {
const int termLength = searchTerm.length();
const int termLength = static_cast<int>(searchTerm.length());
for (const FullTextSearchResult& fileResult: fileResults)
{
const FilePath filePath = getFileNodePath(fileResult.fileId);
@@ -639,7 +639,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
{
while (charsTotal + (int)line.length() <= pos)
{
charsTotal += line.length();
charsTotal += static_cast<int>(line.length());
lineNumber++;
line = codec.decode(fileContent->getLine(lineNumber));
}
@@ -655,7 +655,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
}
while ((charsTotal + (int)line.length()) < pos + termLength)
{
charsTotal += line.length();
charsTotal += static_cast<int>(line.length());
lineNumber++;
line = codec.decode(fileContent->getLine(lineNumber));
}
@@ -709,7 +709,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(
TRACE();
// search in indices
const size_t maxResultsCount = std::pow(3, query.size() + 3);
const size_t maxResultsCount = static_cast<size_t>(std::pow(3, query.size() + 3));
const size_t maxBestScoredResultsLength = 100;
const size_t maxMatchesReturned = 1000;
@@ -2280,7 +2280,9 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no
std::vector<Annotation> annotations;
std::vector<std::string> lines =
getFileContent(sigLoc->getFilePath(), false)
->getLines(sigLoc->getLineNumber(), sigLoc->getEndLocation()->getLineNumber());
->getLines(
static_cast<unsigned int>(sigLoc->getLineNumber()),
static_cast<unsigned int>(sigLoc->getEndLocation()->getLineNumber()));
// check if signature location refers to correct locations in the code
// wrongly recorded signature locations of implicit template methods in C++ caused crashes
+1 -1
View File
@@ -5,7 +5,7 @@
int StorageProvider::getStorageCount() const
{
std::lock_guard<std::mutex> lock(m_storagesMutex);
return m_storages.size();
return static_cast<int>(m_storages.size());
}
void StorageProvider::clear()
@@ -75,7 +75,7 @@ StorageBookmarkCategory SqliteBookmarkStorage::addBookmarkCategory(const Storage
stmt.bind(1, utility::encodeToUtf8(data.name).c_str());
executeStatement(stmt);
return StorageBookmarkCategory(m_database.lastRowId(), data);
return StorageBookmarkCategory(static_cast<Id>(m_database.lastRowId()), data);
}
StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& data)
@@ -93,7 +93,7 @@ StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& da
stmt.bind(3, data.timestamp.c_str());
executeStatement(stmt);
return StorageBookmark(m_database.lastRowId(), data);
return StorageBookmark(static_cast<Id>(m_database.lastRowId()), data);
}
catch (CppSQLite3Exception e)
{
@@ -107,7 +107,7 @@ StorageBookmarkedNode SqliteBookmarkStorage::addBookmarkedNode(const StorageBook
executeStatement(
"INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " +
std::to_string(data.bookmarkId) + ");");
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
std::string statement =
"INSERT INTO bookmarked_node(id, serialized_node_name) "
@@ -125,7 +125,7 @@ StorageBookmarkedEdge SqliteBookmarkStorage::addBookmarkedEdge(const StorageBook
executeStatement(
"INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " +
std::to_string(data.bookmarkId) + ");");
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
std::string statement =
"INSERT INTO bookmarked_edge(id, serialized_source_node_name, serialized_target_node_name, "
@@ -89,14 +89,14 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
std::string name = utility::encodeToUtf8(node.serializedName);
if (name.size() != node.serializedName.size())
{
m_tempWNodeNameIndex.add(node.serializedName, node.id);
m_tempWNodeNameIndex.add(node.serializedName, static_cast<uint32_t>(node.id));
}
else
{
m_tempNodeNameIndex.add(name, node.id);
m_tempNodeNameIndex.add(name, static_cast<uint32_t>(node.id));
}
m_tempNodeTypes.emplace(node.id, node.type);
m_tempNodeTypes.emplace(static_cast<uint32_t>(node.id), node.type);
});
}
@@ -119,11 +119,11 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
if (nodeId)
{
auto it = m_tempNodeTypes.find(nodeId);
auto it = m_tempNodeTypes.find(static_cast<uint32_t>(nodeId));
if (it != m_tempNodeTypes.end() && it->second < data.type)
{
setNodeType(data.type, nodeId);
m_tempNodeTypes[nodeId] = data.type;
m_tempNodeTypes[static_cast<uint32_t>(nodeId)] = data.type;
}
nodeIds[i] = nodeId;
@@ -131,20 +131,20 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
else
{
executeStatement(m_insertElementStmt);
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
nodesToInsert.emplace_back(id, data);
nodeIds[i] = id;
if (name.size() != data.serializedName.size())
{
m_tempWNodeNameIndex.add(data.serializedName, id);
m_tempWNodeNameIndex.add(data.serializedName, static_cast<uint32_t>(id));
}
else
{
m_tempNodeNameIndex.add(name, id);
m_tempNodeNameIndex.add(name, static_cast<uint32_t>(id));
}
m_tempNodeTypes.emplace(id, data.type);
m_tempNodeTypes.emplace(static_cast<uint32_t>(id), data.type);
}
}
}
@@ -224,7 +224,8 @@ std::vector<Id> SqliteIndexStorage::addEdges(const std::vector<StorageEdge>& edg
{
forEach<StorageEdge>([this](StorageEdge&& edge) {
m_tempEdgeIndex.emplace(
StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId), edge.id);
StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId),
static_cast<uint32_t>(edge.id));
});
}
@@ -241,12 +242,12 @@ std::vector<Id> SqliteIndexStorage::addEdges(const std::vector<StorageEdge>& edg
else
{
executeStatement(m_insertElementStmt);
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
edgeIds[i] = id;
edgesToInsert.emplace_back(id, data);
m_tempEdgeIndex.emplace(data, id);
m_tempEdgeIndex.emplace(data, static_cast<uint32_t>(id));
}
}
@@ -272,7 +273,8 @@ std::vector<Id> SqliteIndexStorage::addLocalSymbols(const std::set<StorageLocalS
std::pair<std::wstring, std::wstring> name = splitLocalSymbolName(localSymbol.name);
if (name.second.size())
{
m_tempLocalSymbolIndex[name.first].emplace(name.second, localSymbol.id);
m_tempLocalSymbolIndex[name.first].emplace(
name.second, static_cast<uint32_t>(localSymbol.id));
}
});
}
@@ -300,13 +302,13 @@ std::vector<Id> SqliteIndexStorage::addLocalSymbols(const std::set<StorageLocalS
if (!symbolIds[i])
{
executeStatement(m_insertElementStmt);
const Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
symbolIds[i] = id;
symbolsToInsert.emplace_back(id, data);
if (name.second.size())
{
m_tempLocalSymbolIndex[name.first].emplace(name.second, id);
m_tempLocalSymbolIndex[name.first].emplace(name.second, static_cast<uint32_t>(id));
}
}
@@ -333,11 +335,15 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
{
forEach<StorageSourceLocation>([this](StorageSourceLocation&& loc) {
std::map<TempSourceLocation, uint32_t>& index =
m_tempSourceLocationIndices[loc.fileNodeId];
m_tempSourceLocationIndices[static_cast<uint32_t>(loc.fileNodeId)];
index.emplace(
TempSourceLocation(
loc.startLine, loc.endLine - loc.startLine, loc.startCol, loc.endCol, loc.type),
loc.id);
static_cast<uint32_t>(loc.startLine),
static_cast<uint16_t>(loc.endLine - loc.startLine),
static_cast<uint16_t>(loc.startCol),
static_cast<uint16_t>(loc.endCol),
loc.type),
static_cast<uint32_t>(loc.id));
});
}
@@ -349,9 +355,13 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
{
const StorageSourceLocation& data = locations[i];
const TempSourceLocation tempLoc(
data.startLine, data.endLine - data.startLine, data.startCol, data.endCol, data.type);
static_cast<uint32_t>(data.startLine),
static_cast<uint16_t>(data.endLine - data.startLine),
static_cast<uint16_t>(data.startCol),
static_cast<uint16_t>(data.endCol),
data.type);
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[data.fileNodeId];
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>::const_iterator it = index.find(tempLoc);
if (it != index.end())
{
@@ -363,7 +373,7 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
Id id = lastRowId + 1 + locationsToInsert.size();
locationIds[i] = id;
index.emplace(tempLoc, id);
index.emplace(tempLoc, static_cast<uint32_t>(id));
locationsToInsert.emplace_back(data);
}
@@ -434,7 +444,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data)
if (id == 0)
{
executeStatement(m_insertElementStmt);
id = m_database.lastRowId();
id = static_cast<Id>(m_database.lastRowId());
m_insertErrorStmt.bind(1, int(id));
m_insertErrorStmt.bind(2, utility::encodeToUtf8(sanitizedMessage).c_str());
@@ -445,7 +455,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data)
const bool success = executeStatement(m_insertErrorStmt);
if (success)
{
id = m_database.lastRowId();
id = static_cast<Id>(m_database.lastRowId());
}
}
@@ -1349,35 +1359,35 @@ void SqliteIndexStorage::setupPrecompiledStatements()
"INSERT INTO node(id, type, serialized_name) VALUES",
3,
[](CppSQLite3Statement& stmt, const StorageNode& node, size_t index) {
stmt.bind(index * 3 + 1, int(node.id));
stmt.bind(index * 3 + 2, int(node.type));
stmt.bind(index * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str());
stmt.bind(int(index) * 3 + 1, int(node.id));
stmt.bind(int(index) * 3 + 2, int(node.type));
stmt.bind(int(index) * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str());
},
m_database);
m_insertEdgeBatchStatement.compile(
"INSERT INTO edge(id, type, source_node_id, target_node_id) VALUES",
4,
[](CppSQLite3Statement& stmt, const StorageEdge& edge, size_t index) {
stmt.bind(index * 4 + 1, int(edge.id));
stmt.bind(index * 4 + 2, int(edge.type));
stmt.bind(index * 4 + 3, int(edge.sourceNodeId));
stmt.bind(index * 4 + 4, int(edge.targetNodeId));
stmt.bind(int(index) * 4 + 1, int(edge.id));
stmt.bind(int(index) * 4 + 2, int(edge.type));
stmt.bind(int(index) * 4 + 3, int(edge.sourceNodeId));
stmt.bind(int(index) * 4 + 4, int(edge.targetNodeId));
},
m_database);
m_insertSymbolBatchStatement.compile(
"INSERT OR IGNORE INTO symbol(id, definition_kind) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageSymbol& symbol, size_t index) {
stmt.bind(index * 2 + 1, int(symbol.id));
stmt.bind(index * 2 + 2, int(symbol.definitionKind));
stmt.bind(int(index) * 2 + 1, int(symbol.id));
stmt.bind(int(index) * 2 + 2, int(symbol.definitionKind));
},
m_database);
m_insertLocalSymbolBatchStatement.compile(
"INSERT INTO local_symbol(id, name) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageLocalSymbol& symbol, size_t index) {
stmt.bind(index * 2 + 1, int(symbol.id));
stmt.bind(index * 2 + 2, utility::encodeToUtf8(symbol.name).c_str());
stmt.bind(int(index) * 2 + 1, int(symbol.id));
stmt.bind(int(index) * 2 + 2, utility::encodeToUtf8(symbol.name).c_str());
},
m_database);
m_insertSourceLocationBatchStatement.compile(
@@ -1385,28 +1395,28 @@ void SqliteIndexStorage::setupPrecompiledStatements()
"end_column, type) VALUES",
6,
[](CppSQLite3Statement& stmt, const StorageSourceLocationData& location, size_t index) {
stmt.bind(index * 6 + 1, int(location.fileNodeId));
stmt.bind(index * 6 + 2, int(location.startLine));
stmt.bind(index * 6 + 3, int(location.startCol));
stmt.bind(index * 6 + 4, int(location.endLine));
stmt.bind(index * 6 + 5, int(location.endCol));
stmt.bind(index * 6 + 6, int(location.type));
stmt.bind(int(index) * 6 + 1, int(location.fileNodeId));
stmt.bind(int(index) * 6 + 2, int(location.startLine));
stmt.bind(int(index) * 6 + 3, int(location.startCol));
stmt.bind(int(index) * 6 + 4, int(location.endLine));
stmt.bind(int(index) * 6 + 5, int(location.endCol));
stmt.bind(int(index) * 6 + 6, int(location.type));
},
m_database);
m_insertOccurenceBatchStatement.compile(
"INSERT OR IGNORE INTO occurrence(element_id, source_location_id) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageOccurrence& occurrence, size_t index) {
stmt.bind(index * 2 + 1, int(occurrence.elementId));
stmt.bind(index * 2 + 2, int(occurrence.sourceLocationId));
stmt.bind(int(index) * 2 + 1, int(occurrence.elementId));
stmt.bind(int(index) * 2 + 2, int(occurrence.sourceLocationId));
},
m_database);
m_insertComponentAccessBatchStatement.compile(
"INSERT OR IGNORE INTO component_access(node_id, type) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageComponentAccess& componentAccess, size_t index) {
stmt.bind(index * 2 + 1, int(componentAccess.nodeId));
stmt.bind(index * 2 + 2, int(componentAccess.type));
stmt.bind(int(index) * 2 + 1, int(componentAccess.nodeId));
stmt.bind(int(index) * 2 + 2, int(componentAccess.type));
},
m_database);
+5 -4
View File
@@ -599,7 +599,8 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size();
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("shallow_indexing", info.shallow));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("source_file_count", sourceFileCount));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>(
"source_file_count", static_cast<int>(sourceFileCount)));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexed_source_file_count", 0));
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("interrupted_indexing", false));
taskSequential->addTask(std::make_shared<TaskSetValue<float>>("index_time", 0.0f));
@@ -617,7 +618,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
if (!indexerCommandProvider->empty())
{
const int adjustedIndexerThreadCount = std::min<int>(
indexerThreadCount, indexerCommandProvider->size());
indexerThreadCount, static_cast<int>(indexerCommandProvider->size()));
std::shared_ptr<StorageProvider> storageProvider = std::make_shared<StorageProvider>();
// add tasks for setting some variables on the blackboard that are used during indexing
@@ -719,7 +720,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
if (!customIndexerCommandProvider->empty())
{
const int adjustedIndexerThreadCount = std::min<int>(
indexerThreadCount, customIndexerCommandProvider->size());
indexerThreadCount, static_cast<int>(customIndexerCommandProvider->size()));
taskSequential->addTask(std::make_shared<TaskExecuteCustomCommands>(
std::move(customIndexerCommandProvider),
@@ -813,7 +814,7 @@ bool Project::swapToTempStorageFile(
FileSystem::remove(indexDbFilePath);
FileSystem::rename(tempIndexDbFilePath, indexDbFilePath);
}
catch (std::exception& e)
catch (std::exception& /*e*/)
{
if (m_hasGUI)
{
+5
View File
@@ -472,6 +472,11 @@ SettingsMigrator ProjectSettings::getMigrations() const
languageName = "java";
break;
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
case LANGUAGE_PYTHON:
continue;
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
default:
continue;
}
+1 -1
View File
@@ -96,7 +96,7 @@ size_t Settings::getVersion() const
void Settings::setVersion(size_t version)
{
setValue<int>("version", version);
setValue<int>("version", static_cast<int>(version));
}
Settings::Settings()
@@ -23,8 +23,8 @@ public:
SourceGroupSettings::load(config, key);
using expand_type = int[];
expand_type a {0, loadHelper<ComponentTypes>(config, key)...};
using expand_type = bool[];
expand_type a {false, loadHelper<ComponentTypes>(config, key)...};
}
void saveSettings(ConfigManager* config) override
@@ -33,8 +33,8 @@ public:
SourceGroupSettings::save(config, key);
using expand_type = int[];
expand_type a {0, saveHelper<ComponentTypes>(config, key)...};
using expand_type = bool[];
expand_type a {false, saveHelper<ComponentTypes>(config, key)...};
}
bool equalsSettings(const SourceGroupSettingsBase* other) override
@@ -51,7 +51,7 @@ public:
return false;
}
using expand_type = int[];
using expand_type = bool[];
expand_type a {false, equalsHelper<ComponentTypes>(other)...};
bool r = true;
+6
View File
@@ -32,7 +32,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return strncpy(destination, source, num);
#pragma warning(pop)
}
};
@@ -50,7 +53,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return wcsncpy(destination, source, num);
#pragma warning(pop)
}
};
+4 -4
View File
@@ -23,7 +23,7 @@ std::string TimeStamp::secondsToString(double secs)
int seconds = int(secs);
secs -= seconds;
int milliSeconds = secs * 1000;
const int milliSeconds = static_cast<int>(secs * 1000);
if (hours > 9)
{
@@ -110,12 +110,12 @@ std::string TimeStamp::dayOfWeekShort() const
size_t TimeStamp::deltaMS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_milliseconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_milliseconds()));
}
size_t TimeStamp::deltaS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_seconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_seconds()));
}
bool TimeStamp::isSameDay(const TimeStamp& other) const
@@ -139,5 +139,5 @@ size_t TimeStamp::deltaDays(const TimeStamp& other) const
size_t TimeStamp::deltaHours(const TimeStamp& other) const
{
boost::posix_time::time_duration delta = m_time - other.m_time;
return abs(delta.total_seconds() / 3600);
return static_cast<size_t>(abs(delta.total_seconds() / 3600));
}
+3
View File
@@ -261,8 +261,11 @@ std::vector<FilePath> FilePath::expandEnvironmentVariables() const
std::smatch match;
while (std::regex_search(text, match, env))
{
#pragma warning(push)
#pragma warning(disable : 4996)
const char* s = match[1].matched ? getenv(match[1].str().c_str())
: getenv(match[2].str().c_str());
#pragma warning(pop)
if (s == nullptr)
{
LOG_ERROR_STREAM(<< match[1].str() << " is not an environment variable in: " << text);
+1 -1
View File
@@ -28,7 +28,7 @@ std::vector<FilePath> utility::partitionFilePathsBySize(std::vector<FilePath> fi
sourceFileSizesToCommands.end(),
[](const PairType& p, const PairType& q) { return p.first > q.first; });
if (0 < partitionCount && partitionCount < sourceFileSizesToCommands.size())
if (0 < partitionCount && partitionCount < static_cast<int>(sourceFileSizesToCommands.size()))
{
for (int i = 0; i < partitionCount; i++)
{
@@ -195,7 +195,6 @@ SharedMemory::~SharedMemory()
LOG_ERROR_STREAM(
<< "boost exception thrown at shared memory destruction - " << getMemoryName() << ": "
<< e.what());
throw e;
}
}
+4
View File
@@ -13,6 +13,9 @@ std::wstring FileLogger::generateDatedFileName(
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm t = *std::localtime(&time);
if (offsetDays != 0)
@@ -20,6 +23,7 @@ std::wstring FileLogger::generateDatedFileName(
time = mktime(&t) + offsetDays * 24 * 60 * 60;
t = *std::localtime(&time);
}
#pragma warning(pop)
std::wstringstream filename;
if (!prefix.empty())
@@ -79,7 +79,7 @@ void LogManagerImplementation::clearLoggers()
int LogManagerImplementation::getLoggerCount() const
{
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
return m_loggers.size();
return static_cast<int>(m_loggers.size());
}
void LogManagerImplementation::logInfo(
@@ -128,7 +128,12 @@ tm LogManagerImplementation::getTime()
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm result = *std::localtime(&time); // this is done because localtime returns a pointer to a
// statically allocated object
#pragma warning(pop)
return result;
}
+2 -2
View File
@@ -70,7 +70,7 @@ void MatrixDynamicBase<T>::setValue(
template <class T>
unsigned int MatrixDynamicBase<T>::getColumnsCount() const
{
return m_values.size();
return static_cast<unsigned int>(m_values.size());
}
template <class T>
@@ -78,7 +78,7 @@ unsigned int MatrixDynamicBase<T>::getRowsCount() const
{
if (m_values.size() > 0)
{
return m_values[0].size();
return static_cast<unsigned int>(m_values[0].size());
}
return 0;
@@ -22,7 +22,7 @@ void TaskGroupParallel::doEnter(std::shared_ptr<Blackboard> blackboard)
if (m_needsToStartThreads)
{
m_needsToStartThreads = false;
m_activeTaskCount = m_tasks.size();
m_activeTaskCount = static_cast<int>(m_tasks.size());
for (size_t i = 0; i < m_tasks.size(); i++)
{
m_tasks[i]->active = true;
+1 -1
View File
@@ -81,7 +81,7 @@ TextAccess::~TextAccess() {}
unsigned int TextAccess::getLineCount() const
{
return m_lines.size();
return static_cast<unsigned int>(m_lines.size());
}
bool TextAccess::isEmpty() const
+2 -2
View File
@@ -119,12 +119,12 @@ void Tracer::printTraces()
if (p.second)
{
acc->event = event.get();
acc->time = event->time;
acc->time = static_cast<float>(event->time);
acc->count = 1;
}
else
{
acc->time += event->time;
acc->time += static_cast<float>(event->time);
acc->count++;
}
}
+4 -4
View File
@@ -7,9 +7,9 @@
unsigned long utility::getLargestByteSizeOfAllocatableMemory()
{
MEMORY_BASIC_INFORMATION mbi;
unsigned long start = 0;
__int64 start = 0;
bool recording = false;
unsigned long freestart = 0, largestFreestart = 0;
__int64 freestart = 0, largestFreestart = 0;
__int64 free = 0, largestFree = 0;
while (true)
@@ -39,10 +39,10 @@ unsigned long utility::getLargestByteSizeOfAllocatableMemory()
free = 0;
recording = false;
}
start += mbi.RegionSize;
start += static_cast<unsigned long>(mbi.RegionSize);
}
return largestFree;
return static_cast<unsigned int>(largestFree);
}
#endif // WIN32
@@ -1,7 +1,7 @@
#ifndef GENERATE_PCH_ACTION_H
#define GENERATE_PCH_ACTION_H
#include "clang/Frontend/FrontendActions.h"
#include <clang/Frontend/FrontendActions.h>
class ParserClient;
class CanonicalFilePathCache;
@@ -1,7 +1,7 @@
#ifndef SINGLE_FRONTEND_ACTION_FACTORY
#define SINGLE_FRONTEND_ACTION_FACTORY
#include "clang/Tooling/Tooling.h"
#include <clang/Tooling/Tooling.h>
class SingleFrontendActionFactory: public clang::tooling::FrontendActionFactory
{
@@ -167,7 +167,7 @@ std::unique_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
std::vector<std::wstring> templateArguments;
const clang::TemplateArgumentList& templateArgumentList =
templateSpecialitarionDecl->getTemplateArgs();
for (size_t i = 0; i < templateArgumentList.size(); i++)
for (unsigned i = 0; i < templateArgumentList.size(); i++)
{
if (templateArgumentList.get(i).isDependent())
{
@@ -220,7 +220,7 @@ std::unique_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
{
const clang::TemplateArgumentList* templateArgumentList =
functionDecl->getTemplateSpecializationArgs();
for (size_t i = 0; i < templateArgumentList->size(); i++)
for (unsigned i = 0; i < templateArgumentList->size(); i++)
{
const clang::TemplateArgument& templateArgument = templateArgumentList->get(i);
if (templateArgument.isDependent())
@@ -402,7 +402,7 @@ std::unique_ptr<CxxDeclName> CxxDeclNameResolver::getDeclName(const clang::Named
clang::dyn_cast_or_null<clang::VarTemplateSpecializationDecl>(varDecl);
const clang::TemplateArgumentList& templateArgumentList =
templateSpecializationDeclaration->getTemplateArgs();
for (size_t i = 0; i < templateArgumentList.size(); i++)
for (unsigned i = 0; i < templateArgumentList.size(); i++)
{
const clang::TemplateArgument& templateArgument = templateArgumentList.get(i);
if (templateArgument.isDependent())
@@ -484,7 +484,7 @@ std::vector<std::wstring> CxxDeclNameResolver::getTemplateParameterStrings(
{
std::vector<std::wstring> templateParameterStrings;
clang::TemplateParameterList* parameterList = templateDecl->getTemplateParameters();
for (size_t i = 0; i < parameterList->size(); i++)
for (unsigned i = 0; i < parameterList->size(); i++)
{
templateParameterStrings.push_back(getTemplateParameterString(parameterList->getParam(i)));
}
@@ -43,7 +43,7 @@ std::vector<std::wstring> CxxDeclNameResolver::getTemplateParameterStringsOfPart
const clang::TemplateArgumentList& templateArgumentList =
partialSpecializationDecl->getTemplateArgs();
for (int i = 0; i < templateArgumentList.size(); i++)
for (unsigned i = 0; i < templateArgumentList.size(); i++)
{
const clang::TemplateArgument& templateArgument = templateArgumentList.get(i);
const clang::TemplateArgument::ArgKind argKind = templateArgument.getKind();
@@ -89,7 +89,7 @@ std::wstring CxxTemplateParameterStringResolver::getTemplateParameterTypeString(
std::wstringstream ss;
ss << L"template<";
const clang::TemplateParameterList* parameterList = parameter->getTemplateParameters();
for (size_t i = 0; i < parameterList->size(); i++)
for (unsigned i = 0; i < parameterList->size(); i++)
{
if (i > 0)
{
@@ -160,7 +160,7 @@ std::unique_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
resolver.ignoreContextDecl(templateSpecializationType->getTemplateName()
.getAsTemplateDecl()
->getTemplatedDecl());
for (size_t i = 0; i < templateSpecializationType->getNumArgs(); i++)
for (unsigned i = 0; i < templateSpecializationType->getNumArgs(); i++)
{
if (templateSpecializationType->getArg(i).isDependent())
{
@@ -218,7 +218,7 @@ std::unique_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
std::vector<std::wstring> templateArguments;
CxxTemplateArgumentNameResolver resolver(this);
for (size_t i = 0; i < dependentType->getNumArgs(); i++)
for (unsigned i = 0; i < dependentType->getNumArgs(); i++)
{
templateArguments.push_back(
resolver.getTemplateArgumentName(dependentType->getArg(i)));
@@ -255,7 +255,7 @@ std::unique_ptr<CxxTypeName> CxxTypeNameResolver::getName(const clang::Type* typ
std::wstring nameString =
CxxTypeName::makeUnsolvedIfNull(getName(protoType->getReturnType()))->toString();
nameString += L"(";
for (size_t i = 0; i < protoType->getNumParams(); i++)
for (unsigned i = 0; i < protoType->getNumParams(); i++)
{
if (i != 0)
{
@@ -68,6 +68,8 @@ AccessKind utility::convertAccessSpecifier(clang::AccessSpecifier access)
return ACCESS_PRIVATE;
case clang::AS_none:
return ACCESS_NONE;
default:
return ACCESS_NONE;
}
}
@@ -85,6 +87,8 @@ SymbolKind utility::convertTagKind(const clang::TagTypeKind tagKind)
return SYMBOL_ENUM;
case clang::TTK_Interface:
return SYMBOL_KIND_MAX;
default:
return SYMBOL_KIND_MAX;
}
}
+1 -1
View File
@@ -162,7 +162,7 @@ std::vector<IncludeDirective> IncludeProcessing::getIncludeDirectives(
TextCodec codec(ApplicationSettings::getInstance()->getTextEncoding());
const std::vector<std::string> lines = textAccess->getAllLines();
for (size_t i = 0; i < lines.size(); i++)
for (unsigned i = 0; i < lines.size(); i++)
{
const std::wstring line = codec.decode(lines[i]);
const std::wstring lineTrimmedToHash = utility::trim(line);
@@ -41,11 +41,14 @@ void setupApp(int argc, char* argv[])
FilePath userDataPath = AppPath::getAppPath().concatenate(L"user/");
if (!userDataPath.exists())
{
#pragma warning(push)
#pragma warning(disable : 4996)
FilePath userLocalPath = FilePath(std::string(std::getenv("LOCALAPPDATA")));
if (!userLocalPath.exists())
{
userLocalPath = FilePath(std::string(std::getenv("APPDATA")) + "/../local");
}
#pragma warning(pop)
if (userLocalPath.exists())
{
+1 -1
View File
@@ -167,7 +167,7 @@ void QtStatusBar::showIndexingProgress(size_t progressPercent)
m_indexingStatus->show();
m_vlineIndexing->show();
m_indexingProgress->setValue(progressPercent);
m_indexingProgress->setValue(static_cast<int>(progressPercent));
}
void QtStatusBar::hideIndexingProgress()
+4 -3
View File
@@ -75,9 +75,10 @@ void QtTable::updateRows()
}
}
int rowCount = model()->rowCount() > m_rowsToFill ? model()->rowCount() : m_rowsToFill;
int width = ApplicationSettings::getInstance()->getFontSize() * 0.7 *
int(1 + std::log10(rowCount));
const int rowCount = model()->rowCount() > m_rowsToFill ? model()->rowCount()
: static_cast<int>(m_rowsToFill);
const int width = static_cast<int>(
ApplicationSettings::getInstance()->getFontSize() * 0.7 * int(1 + std::log10(rowCount)));
verticalHeader()->setStyleSheet("::section { width: " + QString::number(width) + "px; }");
verticalHeader()->setDefaultSectionSize(ApplicationSettings::getInstance()->getFontSize() + 6);
+13 -10
View File
@@ -134,7 +134,7 @@ QSize QtCodeArea::sizeHint() const
height += horizontalScrollBar()->height();
}
return QSize(width + lineNumberAreaWidth() + 1, height + 5);
return QSize(static_cast<int>(width + lineNumberAreaWidth() + 1), static_cast<int>(height + 5));
}
void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event)
@@ -242,7 +242,7 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event)
{
if (block.isVisible() && bottom >= drawAreaTop)
{
const int number = blockNumber + getStartLineNumber();
const int number = static_cast<int>(blockNumber + getStartLineNumber());
const int height = bottom - top - std::max(0, bottom - drawAreaBottom);
p.setColor(textColor);
@@ -274,7 +274,7 @@ void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent* event)
int QtCodeArea::lineNumberDigits() const
{
return utility::digits(getEndLineNumber());
return static_cast<int>(utility::digits(getEndLineNumber()));
}
int QtCodeArea::lineNumberAreaWidth() const
@@ -426,7 +426,8 @@ QRectF QtCodeArea::getLineRectForLineNumber(size_t lineNumber) const
lineNumber = getEndLineNumber();
}
QTextBlock block = document()->findBlockByLineNumber(lineNumber - getStartLineNumber());
QTextBlock block = document()->findBlockByLineNumber(
static_cast<int>(lineNumber - getStartLineNumber()));
return blockBoundingGeometry(block);
}
@@ -447,8 +448,8 @@ void QtCodeArea::findScreenMatches(
}
Annotation matchAnnotation;
matchAnnotation.start = pos;
matchAnnotation.end = pos + query.size();
matchAnnotation.start = static_cast<int>(pos);
matchAnnotation.end = static_cast<int>(pos + query.size());
std::pair<int, int> start = toLineColumn(matchAnnotation.start);
matchAnnotation.startLine = start.first;
@@ -483,7 +484,8 @@ void QtCodeArea::clearScreenMatches()
while (i > 0 && m_annotations[i - 1].locationType == LOCATION_SCREEN_SEARCH)
{
i--;
m_linesToRehighlight.push_back(m_annotations[i].startLine - getStartLineNumber());
m_linesToRehighlight.push_back(
static_cast<int>(m_annotations[i].startLine - getStartLineNumber()));
}
if (i != m_annotations.size())
@@ -555,8 +557,8 @@ void QtCodeArea::ensureLocationIdVisible(Id locationId, int parentWidth, bool an
}
const double percentTarget = double(targetWidth) / (totalWidth - visibleWidth);
const int newValue = (scrollBar->maximum() - scrollBar->minimum()) * percentTarget +
scrollBar->minimum();
const int newValue = static_cast<int>(
(scrollBar->maximum() - scrollBar->minimum()) * percentTarget + scrollBar->minimum());
if (animated && ApplicationSettings::getInstance()->getUseAnimations())
{
@@ -684,7 +686,8 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
QScrollBar* scrollbar = horizontalScrollBar();
int visibleContentWidth = width() - lineNumberAreaWidth();
float deltaPosRatio = float(deltaX) / (visibleContentWidth);
scrollbar->setValue(scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep()));
scrollbar->setValue(static_cast<int>(
scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep())));
}
else if (m_isDragging)
{
+17 -17
View File
@@ -129,7 +129,7 @@ QSize QtCodeField::sizeHint() const
width = std::max(blockWidth, width);
}
return QSize(width + 1, height + 5);
return QSize(width + 1, static_cast<int>(height + 5));
}
size_t QtCodeField::getStartLineNumber() const
@@ -144,7 +144,7 @@ size_t QtCodeField::getEndLineNumber() const
int QtCodeField::totalLineHeight() const
{
return blockBoundingRect(firstVisibleBlock()).height() * blockCount();
return static_cast<int>(blockBoundingRect(firstVisibleBlock()).height() * blockCount());
}
std::string QtCodeField::getCode() const
@@ -167,9 +167,9 @@ void QtCodeField::paintEvent(QPaintEvent* event)
QPainter painter(viewport());
QTextBlock block = firstVisibleBlock();
int top = blockBoundingGeometry(block).translated(contentOffset()).top();
int bottom = top + blockBoundingRect(block).height();
int blockHeight = blockBoundingRect(block).height();
int top = static_cast<int>(blockBoundingGeometry(block).translated(contentOffset()).top());
int bottom = static_cast<int>(top + blockBoundingRect(block).height());
int blockHeight = static_cast<int>(blockBoundingRect(block).height());
int firstVisibleLine = -1;
int lastVisibleLine = -1;
@@ -195,8 +195,8 @@ void QtCodeField::paintEvent(QPaintEvent* event)
// TODO: this causes another paint event if lines get rehighlighted
m_highlighter->highlightRange(firstVisibleLine, lastVisibleLine);
firstVisibleLine += m_startLineNumber;
lastVisibleLine += m_startLineNumber;
firstVisibleLine += static_cast<int>(m_startLineNumber);
lastVisibleLine += static_cast<int>(m_startLineNumber);
int borderRadius = 3;
@@ -234,7 +234,7 @@ void QtCodeField::paintEvent(QPaintEvent* event)
{
painter.drawRoundedRect(
0,
top + (annotation.startLine - m_startLineNumber) * blockHeight,
static_cast<int>(top + (annotation.startLine - m_startLineNumber) * blockHeight),
width(),
(annotation.endLine - annotation.startLine + 1) * blockHeight,
borderRadius,
@@ -369,7 +369,7 @@ bool QtCodeField::annotateText(
if (wasFocused != annotation.isFocused || wasActive != annotation.isActive)
{
m_linesToRehighlight.push_back(annotation.startLine - m_startLineNumber);
m_linesToRehighlight.push_back(static_cast<int>(annotation.startLine - m_startLineNumber));
}
}
@@ -406,14 +406,14 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
if (!startLocation || startLocation->getLineNumber() < m_startLineNumber)
{
annotation.start = startTextEditPosition();
annotation.startLine = m_startLineNumber;
annotation.startLine = static_cast<int>(m_startLineNumber);
annotation.startCol = 0;
}
else if (startLocation->getLineNumber() <= endLineNumber)
{
const int startLine = startLocation->getLineNumber();
const int startLine = static_cast<int>(startLocation->getLineNumber());
const int startCol = getColumnCorrectedForMultibyteCharacters(
startLine, startLocation->getColumnNumber() - 1);
startLine, static_cast<int>(startLocation->getColumnNumber() - 1));
annotation.start = toTextEditPosition(startLine, startCol);
annotation.startLine = startLine;
@@ -428,14 +428,14 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
if (!endLocation || endLocation->getLineNumber() > endLineNumber)
{
annotation.end = endTextEditPosition();
annotation.endLine = endLineNumber;
annotation.endLine = static_cast<int>(endLineNumber);
annotation.endCol = m_lineLengths[document()->blockCount() - 1];
}
else if (endLocation->getLineNumber() >= m_startLineNumber)
{
const int endLine = endLocation->getLineNumber();
const int endLine = static_cast<int>(endLocation->getLineNumber());
const int endCol = getColumnCorrectedForMultibyteCharacters(
endLine, endLocation->getColumnNumber());
endLine, static_cast<int>(endLocation->getColumnNumber()));
annotation.end = toTextEditPosition(endLine, endCol);
annotation.endLine = endLine;
@@ -517,7 +517,7 @@ void QtCodeField::activateAnnotations(const std::vector<const Annotation*>& anno
int QtCodeField::toTextEditPosition(int lineNumber, int columnNumber) const
{
lineNumber -= m_startLineNumber - 1;
lineNumber -= static_cast<int>(m_startLineNumber - 1);
int position = 0;
for (int i = 0; i < lineNumber - 1; i++)
@@ -531,7 +531,7 @@ int QtCodeField::toTextEditPosition(int lineNumber, int columnNumber) const
std::pair<int, int> QtCodeField::toLineColumn(int textEditPosition) const
{
int lineNumber = m_startLineNumber;
int lineNumber = static_cast<int>(m_startLineNumber);
for (int i = 0; i < document()->lineCount(); i++)
{
int nextTextEditPosition = textEditPosition - m_lineLengths[i];
@@ -128,7 +128,7 @@ QtCodeFile* QtCodeFileList::getFile(const FilePath& filePath)
void QtCodeFileList::addFile(const CodeFileParams& params)
{
QtCodeFile* file = getFile(params.locationFile->getFilePath());
file->setWholeFile(params.locationFile->isWhole(), params.referenceCount);
file->setWholeFile(params.locationFile->isWhole(), static_cast<int>(params.referenceCount));
file->setModificationTime(params.modificationTime);
file->setIsComplete(params.locationFile->isComplete());
file->setIsIndexed(params.locationFile->isIndexed());
@@ -221,7 +221,7 @@ void QtCodeFileList::scrollTo(
}
else if (lineNumber)
{
snippet = file->getSnippetForLine(lineNumber);
snippet = file->getSnippetForLine(static_cast<unsigned int>(lineNumber));
}
else
{
@@ -115,7 +115,7 @@ bool QtCodeFileSingle::addFile(const CodeFileParams& params, bool useSingleFileC
&QtCodeNavigator::scrolled);
setFileData(file);
updateRefCount(params.referenceCount);
updateRefCount(static_cast<int>(params.referenceCount));
if (useSingleFileCache)
{
@@ -316,7 +316,7 @@ void QtCodeFileSingle::setFileData(const FileData& file)
m_titleBar->setIsIndexed(file.isIndexed);
}
updateRefCount(m_area->getActiveLocationCount());
updateRefCount(static_cast<int>(m_area->getActiveLocationCount()));
titleButton->updateTexts();
titleButton->show();
@@ -24,7 +24,7 @@ QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
setObjectName(QStringLiteral("title_button"));
minimumSizeHint(); // force font loading
setFixedHeight(std::max(fontMetrics().height() * 1.2, 28.0));
setFixedHeight(static_cast<int>(std::max(fontMetrics().height() * 1.2, 28.0)));
setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
setIconSize(QSize(16, 16));
@@ -116,9 +116,9 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(
QScrollBar* scrollBar = area->verticalScrollBar();
double scrollFactor = double(scrollBar->maximum()) / scrollableHeight;
int visibleY = double(scrollBar->value()) / scrollFactor;
int scrollY = totalHeight * percentA;
int rectHeight = percentB ? (totalHeight * percentB) - scrollY : 0;
const int visibleY = static_cast<int>(double(scrollBar->value()) / scrollFactor);
int scrollY = static_cast<int>(totalHeight * percentA);
const int rectHeight = percentB ? static_cast<int>((totalHeight * percentB) - scrollY) : 0;
if (rectHeight > visibleHeight)
{
@@ -149,8 +149,8 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(
break;
}
int value = scrollY * scrollFactor;
int diff = value - scrollBar->value();
const int value = static_cast<int>(scrollY * scrollFactor);
const int diff = value - scrollBar->value();
if (diff > 5 || diff < -5)
{
if (animated && ApplicationSettings::getInstance()->getUseAnimations() && area->isVisible())
@@ -555,7 +555,7 @@ void QtCodeNavigator::scrollTo(const CodeScrollParams& params, bool animated)
QAbstractScrollArea* area = m_current->getScrollArea();
if (area)
{
area->verticalScrollBar()->setValue(params.value);
area->verticalScrollBar()->setValue(static_cast<int>(params.value));
}
};
}
@@ -56,7 +56,7 @@ void QtProgressBar::paintEvent(QPaintEvent* event)
}
else
{
painter.fillRect(0, 2, geometry().width() * m_percent / 100, 6, "white");
painter.fillRect(0, 2, static_cast<int>(geometry().width() * m_percent / 100), 6, "white");
}
}
@@ -18,13 +18,13 @@ void QtAutocompletionModel::setMatchList(const std::vector<SearchMatch>& matchLi
{
size_t rowCount = std::max(m_matchList.size(), matchList.size());
m_matchList = matchList;
emit dataChanged(index(0, 0), index(rowCount - 1, 5));
emit dataChanged(index(0, 0), index(static_cast<int>(rowCount - 1), 5));
}
int QtAutocompletionModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return m_matchList.size();
return static_cast<int>(m_matchList.size());
}
int QtAutocompletionModel::columnCount(const QModelIndex& parent) const
@@ -169,7 +169,7 @@ void QtAutocompletionDelegate::paint(
}
int top1 = 6;
int top2 = m_charHeight1 + 3;
int top2 = static_cast<int>(m_charHeight1 + 3);
// draw background
QColor backgroundColor = option.palette.color(
@@ -189,10 +189,10 @@ void QtAutocompletionDelegate::paint(
}
QRect rect(
option.rect.left() + m_charWidth1 * (idx + 1) + 2,
static_cast<int>(option.rect.left() + m_charWidth1 * (idx + 1) + 2),
option.rect.top() + top1 - 1,
m_charWidth1 + 1,
m_charHeight1 - 1);
static_cast<int>(m_charWidth1 + 1),
static_cast<int>(m_charHeight1 - 1));
painter->fillRect(rect, fillColor);
highlightText[idx] = text.at(idx);
@@ -201,12 +201,17 @@ void QtAutocompletionDelegate::paint(
}
else
{
QRect rect(option.rect.left(), option.rect.top() + top1, m_charWidth1 - 1, m_charHeight1 - 2);
QRect rect(
option.rect.left(),
option.rect.top() + top1,
static_cast<int>(m_charWidth1 - 1),
static_cast<int>(m_charHeight1 - 2));
painter->fillRect(rect, fillColor);
}
// draw text normal
painter->drawText(option.rect.adjusted(m_charWidth1 + 2, top1 - 3, 0, 0), Qt::AlignLeft, text);
painter->drawText(
option.rect.adjusted(static_cast<int>(m_charWidth1 + 2), top1 - 3, 0, 0), Qt::AlignLeft, text);
// draw text highlighted
painter->save();
@@ -214,7 +219,9 @@ void QtAutocompletionDelegate::paint(
highlightPen.setColor(textColor);
painter->setPen(highlightPen);
painter->drawText(
option.rect.adjusted(m_charWidth1 + 2, top1 - 3, 0, 0), Qt::AlignLeft, highlightText);
option.rect.adjusted(static_cast<int>(m_charWidth1 + 2), top1 - 3, 0, 0),
Qt::AlignLeft,
highlightText);
painter->restore();
// draw subtext
@@ -222,8 +229,8 @@ void QtAutocompletionDelegate::paint(
{
// draw arrow icon
painter->drawPixmap(
option.rect.left() + m_charWidth2 * 2,
option.rect.top() + top2 + 1 + (m_charHeight2 - m_arrow.height()) / 2,
static_cast<int>(option.rect.left() + m_charWidth2 * 2),
static_cast<int>(option.rect.top() + top2 + 1 + (m_charHeight2 - m_arrow.height()) / 2),
m_arrow.pixmap());
painter->setFont(m_font2);
@@ -240,10 +247,10 @@ void QtAutocompletionDelegate::paint(
}
QRect rect(
option.rect.left() + m_charWidth2 * (idx + 3) + 2,
static_cast<int>(option.rect.left() + m_charWidth2 * (idx + 3) + 2),
option.rect.top() + top2 + 1,
m_charWidth2 + 1,
m_charHeight2);
static_cast<int>(m_charWidth2 + 1),
static_cast<int>(m_charHeight2));
painter->fillRect(rect, fillColor);
highlightSubtext[idx] = subtext.at(idx);
@@ -257,7 +264,9 @@ void QtAutocompletionDelegate::paint(
// draw subtext normal
painter->drawText(
option.rect.adjusted((3 * m_charWidth2) + 2, top2, 0, 0), Qt::AlignLeft, subtext);
option.rect.adjusted(static_cast<int>((3 * m_charWidth2) + 2), top2, 0, 0),
Qt::AlignLeft,
subtext);
// draw subtext highlighted
painter->save();
@@ -265,7 +274,9 @@ void QtAutocompletionDelegate::paint(
highlightPen.setColor(textColor);
painter->setPen(highlightPen);
painter->drawText(
option.rect.adjusted((3 * m_charWidth2) + 2, top2, 0, 0), Qt::AlignLeft, highlightSubtext);
option.rect.adjusted(static_cast<int>((3 * m_charWidth2) + 2), top2, 0, 0),
Qt::AlignLeft,
highlightSubtext);
painter->restore();
}
@@ -278,13 +289,21 @@ void QtAutocompletionDelegate::paint(
typePen.setColor(scheme->getColor("search/popup/by_text").c_str());
painter->setPen(typePen);
int width = m_charWidth2 * type.size();
int x = painter->viewport().right() - width - m_charWidth2;
int width = static_cast<int>(m_charWidth2 * type.size());
int x = static_cast<int>(painter->viewport().right() - width - m_charWidth2);
int y = option.rect.top() + top2;
painter->fillRect(
QRect(x - m_charWidth2, y, width + m_charWidth2 * 3, m_charHeight2 + 2), backgroundColor);
painter->drawText(QRect(x, y, width + m_charWidth2, m_charHeight2), Qt::AlignRight, type);
QRect(
static_cast<int>(x - m_charWidth2),
y,
static_cast<int>(width + m_charWidth2 * 3),
static_cast<int>(m_charHeight2 + 2)),
backgroundColor);
painter->drawText(
QRect(x, y, static_cast<int>(width + m_charWidth2), static_cast<int>(m_charHeight2)),
Qt::AlignRight,
type);
}
// draw bottom line
@@ -303,8 +322,9 @@ QSize QtAutocompletionDelegate::sizeHint(const QStyleOptionViewItem& option, con
QString type = m_model->longestType();
return QSize(
std::max((text.size() + 2) * m_charWidth1, (subtext.size() + type.size() + 6) * m_charWidth2),
m_charHeight1 * 2 + 3);
static_cast<int>(std::max(
(text.size() + 2) * m_charWidth1, (subtext.size() + type.size() + 6) * m_charWidth2)),
static_cast<int>(m_charHeight1 * 2 + 3));
}
void QtAutocompletionDelegate::calculateCharSizes(QFont font)
@@ -329,7 +349,7 @@ void QtAutocompletionDelegate::calculateCharSizes(QFont font)
"---------------------------------------------------------------------------"
"-------------------------")) /
500.0f;
m_charHeight1 = metrics1.height();
m_charHeight1 = static_cast<float>(metrics1.height());
font.setPixelSize(ApplicationSettings::getInstance()->getFontSize() - 3);
m_font2 = font;
@@ -347,11 +367,11 @@ void QtAutocompletionDelegate::calculateCharSizes(QFont font)
"---------------------------------------------------------------------------"
"-------------------------")) /
500.0f;
m_charHeight2 = metrics2.height();
m_charHeight2 = static_cast<float>(metrics2.height());
m_arrow = QtDeviceScaledPixmap(
QString::fromStdString(ResourcePaths::getGuiPath().str() + "search_view/images/arrow.png"));
m_arrow.scaleToWidth(m_charWidth2);
m_arrow.scaleToWidth(static_cast<int>(m_charWidth2));
m_arrow.colorize(ColorScheme::getInstance()->getColor("search/popup/by_text").c_str());
}
@@ -12,14 +12,16 @@ void QtSearchBarButton::refresh()
{
QtSelfRefreshIconButton::refresh();
int size = m_small ? 10 : 16;
const int size = m_small ? 10 : 16;
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + size, size + 14);
setFixedHeight(height);
const float height = std::max(
static_cast<float>(ApplicationSettings::getInstance()->getFontSize() + size),
static_cast<float>(size + 14));
setFixedHeight(static_cast<int>(height));
if (!m_small)
{
int iconSize = int(height / 4) * 2 + 2;
const int iconSize = int(height / 4) * 2 + 2;
setIconSize(QSize(iconSize, iconSize));
}
}
@@ -340,7 +340,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event)
setEditText(QString::fromStdString(str));
if (size)
{
setCursorPosition(size);
setCursorPosition(static_cast<int>(size));
}
requestAutoCompletions();
@@ -437,7 +437,7 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event)
if (m_cursorIndex < m_elements.size())
{
editTextToElement();
moveCursorTo(m_elements.size());
moveCursorTo(static_cast<int>(m_elements.size()));
return;
}
}
@@ -555,7 +555,7 @@ void QtSmartSearchBox::mouseReleaseEvent(QMouseEvent* event)
int dist = m_elements[i]->x() + m_elements[i]->width() - event->x();
if (abs(dist) < abs(minDist))
{
pos = i + 1;
pos = static_cast<int>(i) + 1;
minDist = dist;
}
}
@@ -565,7 +565,7 @@ void QtSmartSearchBox::mouseReleaseEvent(QMouseEvent* event)
if (pos - m_cursorIndex != 0)
{
moveCursor(pos - m_cursorIndex);
moveCursor(static_cast<int>(pos - m_cursorIndex));
}
else if (hasSelected)
{
@@ -707,7 +707,7 @@ void QtSmartSearchBox::onElementSelected(QtSearchElement* element)
void QtSmartSearchBox::moveCursor(int offset)
{
moveCursorTo(m_cursorIndex + offset);
moveCursorTo(static_cast<int>(m_cursorIndex + offset));
}
void QtSmartSearchBox::moveCursorTo(int target)
@@ -788,7 +788,7 @@ bool QtSmartSearchBox::editTextToElement()
SearchMatch QtSmartSearchBox::editElement(QtSearchElement* element)
{
for (int i = m_elements.size() - 1; i >= 0; i--)
for (int i = static_cast<int>(m_elements.size() - 1); i >= 0; i--)
{
if (m_elements[i] == element)
{
@@ -939,7 +939,7 @@ void QtSmartSearchBox::layoutElements()
{
QtSearchElement* button = m_elements[i];
QSize size = button->minimumSizeHint();
int y = (rect().height() - size.height()) / 2.0;
const int y = static_cast<int>((rect().height() - size.height()) / 2.0);
button->setGeometry(elementX[i] + offsetX, y, size.width(), size.height());
}
@@ -13,7 +13,7 @@ QtCountCircleItem::QtCountCircleItem(QGraphicsItem* parent): QtRoundedRectItem(p
QFont font;
font.setFamily(GraphViewStyle::getFontNameOfExpandToggleNode().c_str());
font.setPixelSize(GraphViewStyle::getFontSizeOfCountCircle());
font.setPixelSize(static_cast<int>(GraphViewStyle::getFontSizeOfCountCircle()));
font.setWeight(QFont::Normal);
m_number = new QGraphicsSimpleTextItem(this);
@@ -38,17 +38,17 @@ void QtCountCircleItem::setPosition(const Vec2f& pos)
void QtCountCircleItem::setNumber(size_t number)
{
QString numberStr = QString::number(number);
const QString numberStr = QString::number(number);
m_number->setText(numberStr);
QPointF center = this->rect().center();
this->setPosition(Vec2f(center.x(), center.y()));
const QPointF center = this->rect().center();
this->setPosition(Vec2f(static_cast<float>(center.x()), static_cast<float>(center.y())));
}
void QtCountCircleItem::setStyle(QColor color, QColor fontColor, QColor borderColor, size_t borderWidth)
{
this->setBrush(color);
this->setPen(QPen(borderColor, borderWidth));
this->setPen(QPen(borderColor, static_cast<qreal>(borderWidth)));
m_number->setBrush(fontColor);
}
@@ -241,11 +241,11 @@ void QtGraphicsView::updateZoom(float delta)
if (factor <= 0.0f)
{
factor = 0.000001;
factor = 0.000001f;
}
double newZoom = m_zoomFactor * factor;
setZoomFactor(qBound(0.1, newZoom, 100.0));
setZoomFactor(static_cast<float>(qBound(0.1, newZoom, 100.0)));
}
void QtGraphicsView::resizeEvent(QResizeEvent* event)
@@ -373,7 +373,7 @@ void QtGraphicsView::wheelEvent(QWheelEvent* event)
{
if (event->delta() != 0.0f)
{
updateZoom(event->delta());
updateZoom(static_cast<float>(event->delta()));
}
}
else
@@ -536,12 +536,12 @@ void QtGraphicsView::updateTimer()
if (x != 0)
{
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + x);
horizontalScrollBar()->setValue(static_cast<int>(horizontalScrollBar()->value() + x));
}
if (y != 0)
{
verticalScrollBar()->setValue(verticalScrollBar()->value() + y);
verticalScrollBar()->setValue(static_cast<int>(verticalScrollBar()->value() + y));
}
if (z != 0)
@@ -79,11 +79,11 @@ void QtLineItemAngled::paint(QPainter* painter, const QStyleOptionGraphicsItem*
{
if (dir % 2 == 1 && std::abs(a.y() - b.y()) < 2 * br)
{
br = std::abs(a.y() - b.y()) / 2;
br = static_cast<int>(std::abs(a.y() - b.y()) / 2);
}
else if (dir % 2 == 0 && std::abs(a.x() - b.x()) < 2 * br)
{
br = std::abs(a.x() - b.x()) / 2;
br = static_cast<int>(std::abs(a.x() - b.x()) / 2);
}
}
+12 -12
View File
@@ -145,11 +145,11 @@ QPolygon QtLineItemBase::getPath() const
Vec2f t[4];
getPivotPoints(t, tR, tR, tOff.y, true);
QPoint a(t[it].x, t[it].y);
QPoint d(o[io].x, o[io].y);
QPoint a(static_cast<int>(t[it].x), static_cast<int>(t[it].y));
QPoint d(static_cast<int>(o[io].x), static_cast<int>(o[io].y));
QPoint b(tP[it].x, tP[it].y);
QPoint c(oP[io].x, oP[io].y);
QPoint b(static_cast<int>(tP[it].x), static_cast<int>(tP[it].y));
QPoint c(static_cast<int>(oP[io].x), static_cast<int>(oP[io].y));
switch (it)
{
@@ -219,8 +219,8 @@ QPolygon QtLineItemBase::getPath() const
{
it = (it + 2) % 4;
a = QPoint(t[it].x, t[it].y);
b = QPoint(tP[it].x, tP[it].y);
a = QPoint(static_cast<int>(t[it].x), static_cast<int>(t[it].y));
b = QPoint(static_cast<int>(tP[it].x), static_cast<int>(tP[it].y));
switch (it)
{
@@ -242,8 +242,8 @@ QPolygon QtLineItemBase::getPath() const
{
io = (io + 2) % 4;
d = QPoint(o[io].x, o[io].y);
c = QPoint(oP[io].x, oP[io].y);
d = QPoint(static_cast<int>(o[io].x), static_cast<int>(o[io].y));
c = QPoint(static_cast<int>(oP[io].x), static_cast<int>(oP[io].y));
switch (io)
{
@@ -438,9 +438,9 @@ void QtLineItemBase::getPivotPoints(
{
float f = 1 / 2.f;
p[0] = Vec2f(in.x + (in.z - in.x) * f + offset, out.y);
p[2] = Vec2f(in.x + (in.z - in.x) * f + offset, out.w);
p[0] = Vec2f(static_cast<float>(in.x + (in.z - in.x) * f + offset), static_cast<float>(out.y));
p[2] = Vec2f(static_cast<float>(in.x + (in.z - in.x) * f + offset), static_cast<float>(out.w));
p[1] = Vec2f(out.z, in.y + (in.w - in.y) * f + offset);
p[3] = Vec2f(out.x, in.y + (in.w - in.y) * f + offset);
p[1] = Vec2f(static_cast<float>(out.z), static_cast<float>(in.y + (in.w - in.y) * f + offset));
p[3] = Vec2f(static_cast<float>(out.x), static_cast<float>(in.y + (in.w - in.y) * f + offset));
}
@@ -5,7 +5,7 @@
#include "QtGraphNode.h"
QtGraphNodeComponentClickable::QtGraphNodeComponentClickable(QtGraphNode* graphNode)
: QtGraphNodeComponent(graphNode), m_mousePos(0.0f, 0.0f), m_mouseMoved(false)
: QtGraphNodeComponent(graphNode), m_mousePos(0, 0), m_mouseMoved(false)
{
}
@@ -18,7 +18,8 @@ void QtGraphNodeComponentClickable::nodeMousePressEvent(QGraphicsSceneMouseEvent
return;
}
m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y());
m_mousePos = Vec2i(
static_cast<int>(event->scenePos().x()), static_cast<int>(event->scenePos().y()));
m_mouseMoved = false;
if (event->button() == Qt::MiddleButton)
@@ -29,7 +30,8 @@ void QtGraphNodeComponentClickable::nodeMousePressEvent(QGraphicsSceneMouseEvent
void QtGraphNodeComponentClickable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
Vec2i mousePos = Vec2i(event->scenePos().x(), event->scenePos().y());
Vec2i mousePos = Vec2i(
static_cast<int>(event->scenePos().x()), static_cast<int>(event->scenePos().y()));
if ((mousePos - m_mousePos).getLength() > 3.0f)
{
@@ -5,7 +5,7 @@
#include "QtGraphNode.h"
QtGraphNodeComponentMoveable::QtGraphNodeComponentMoveable(QtGraphNode* graphNode)
: QtGraphNodeComponent(graphNode), m_mouseOffset(0.0f, 0.0f)
: QtGraphNodeComponent(graphNode), m_mouseOffset(0, 0)
{
}
@@ -19,16 +19,17 @@ void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent*
}
m_oldPos = m_graphNode->getPosition();
m_mouseOffset.x = event->scenePos().x() - m_oldPos.x;
m_mouseOffset.y = event->scenePos().y() - m_oldPos.y;
m_mouseOffset.x = static_cast<int>(event->scenePos().x() - m_oldPos.x);
m_mouseOffset.y = static_cast<int>(event->scenePos().y() - m_oldPos.y);
event->accept();
}
void QtGraphNodeComponentMoveable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
m_graphNode->setPosition(
Vec2i(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y));
m_graphNode->setPosition(Vec2i(
static_cast<int>(event->scenePos().x() - m_mouseOffset.x),
static_cast<int>(event->scenePos().y() - m_mouseOffset.y)));
event->accept();
}
@@ -55,7 +55,7 @@ QtGraphEdge::QtGraphEdge(
, m_isTrailEdge(false)
, m_useBezier(false)
, m_isInteractive(isInteractive)
, m_mousePos(0.0f, 0.0f)
, m_mousePos(0, 0)
, m_mouseMoved(false)
{
this->setCursor(Qt::PointingHandCursor);
@@ -399,7 +399,7 @@ void QtGraphEdge::focusIn()
if (type == Edge::EDGE_AGGREGATION)
{
info.count = m_weight;
info.count = static_cast<int>(m_weight);
info.countText = "edge";
}
info.offset = Vec2i(10, 20);
@@ -435,13 +435,15 @@ void QtGraphEdge::focusOut()
void QtGraphEdge::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y());
m_mousePos = Vec2i(
static_cast<int>(event->scenePos().x()), static_cast<int>(event->scenePos().y()));
m_mouseMoved = false;
}
void QtGraphEdge::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
Vec2i mousePos = Vec2i(event->scenePos().x(), event->scenePos().y());
Vec2i mousePos = Vec2i(
static_cast<int>(event->scenePos().x()), static_cast<int>(event->scenePos().y()));
if ((mousePos - m_mousePos).getLength() > 1.0f)
{
+15 -11
View File
@@ -95,7 +95,7 @@ const std::list<QtGraphNode*>& QtGraphNode::getSubNodes() const
Vec2i QtGraphNode::getPosition() const
{
return Vec2i(this->scenePos().x(), this->scenePos().y());
return Vec2i(static_cast<int>(this->scenePos().x()), static_cast<int>(this->scenePos().y()));
}
bool QtGraphNode::setPosition(const Vec2i& position)
@@ -578,7 +578,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
if (!m_icon && !style.iconPath.empty())
{
QtDeviceScaledPixmap pixmap(QString::fromStdWString(style.iconPath.wstr()));
pixmap.scaleToHeight(style.iconSize);
pixmap.scaleToHeight(static_cast<int>(style.iconSize));
m_icon = new QGraphicsPixmapItem(
utility::colorizePixmap(pixmap.pixmap(), style.color.icon.c_str()), this);
@@ -588,7 +588,7 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
}
QFont font(style.fontName.c_str());
font.setPixelSize(style.fontSize);
font.setPixelSize(static_cast<int>(style.fontSize));
if (style.fontBold)
{
font.setWeight(QFont::Bold);
@@ -596,7 +596,9 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
m_text->setFont(font);
m_text->setBrush(QBrush(style.color.text.c_str()));
m_text->setPos(style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y);
m_text->setPos(
static_cast<qreal>(style.iconOffset.x + style.iconSize + style.textOffset.x),
static_cast<qreal>(style.textOffset.y));
if (m_matchLength)
{
@@ -605,16 +607,18 @@ void QtGraphNode::setStyle(const GraphViewStyle::NodeStyle& style)
m_matchText->setFont(font);
m_matchText->setBrush(QBrush(color.text.c_str()));
m_matchText->setPos(
style.iconOffset.x + style.iconSize + style.textOffset.x, style.textOffset.y);
static_cast<qreal>(style.iconOffset.x + style.iconSize + style.textOffset.x),
static_cast<qreal>(style.textOffset.y));
float charWidth =
const float charWidth =
QFontMetrics(font).width(QStringLiteral("QtGraphNode::QtGraphNode::QtGraphNode")) / 37.0f;
float charHeight = QFontMetrics(font).height();
const float charHeight = static_cast<float>(QFontMetrics(font).height());
m_matchRect->setRect(
style.iconOffset.x + style.iconSize + style.textOffset.x + m_matchPos * charWidth,
style.textOffset.y,
m_matchLength * charWidth,
charHeight);
static_cast<qreal>(
style.iconOffset.x + style.iconSize + style.textOffset.x + m_matchPos * charWidth),
static_cast<qreal>(style.textOffset.y),
static_cast<qreal>(m_matchLength * charWidth),
static_cast<qreal>(charHeight));
m_matchRect->setPen(QPen(color.border.c_str()));
m_matchRect->setBrush(QBrush(color.fill.c_str()));
m_matchRect->setRadius(3);
@@ -87,8 +87,8 @@ void QtGraphNodeAccess::updateStyle()
if (m_accessIcon)
{
m_text->setPos(
style.textOffset.x + m_accessIconSize + 3,
style.textOffset.y + m_accessIconSize - style.fontSize);
static_cast<qreal>(style.textOffset.x + m_accessIconSize + 3),
static_cast<qreal>(style.textOffset.y + m_accessIconSize - style.fontSize));
m_accessIcon->setPos(style.textOffset.x, style.textOffset.y);
m_accessIcon->setPixmap(
@@ -97,7 +97,8 @@ void QtGraphNodeAccess::updateStyle()
else
{
m_text->setPos(
style.textOffset.x, style.textOffset.y + m_accessIconSize + 2 - style.fontSize);
static_cast<qreal>(style.textOffset.x),
static_cast<qreal>(style.textOffset.y + m_accessIconSize + 2 - style.fontSize));
}
}
@@ -56,7 +56,8 @@ void QtGraphNodeBundle::updateStyle()
}
setStyle(style);
Vec2f pos(m_rect->rect().right(), m_rect->rect().top() - 2);
Vec2f pos(
static_cast<float>(m_rect->rect().right()), static_cast<float>(m_rect->rect().top() - 2));
if (m_type.getNodeStyle() == NodeType::STYLE_BIG_NODE)
{
pos += Vec2f(-2, 2);
@@ -68,9 +68,10 @@ void QtGraphNodeExpandToggle::updateStyle()
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfExpandToggleNode();
setStyle(style);
float textX = (m_rect->rect().width() / 2) -
(QFontMetrics(m_text->font()).width(m_text->text()) / 2);
float textY = m_rect->rect().height() / 2 - QFontMetrics(m_text->font()).height() / 1.8f;
float textX = static_cast<float>(
(m_rect->rect().width() / 2) - (QFontMetrics(m_text->font()).width(m_text->text()) / 2));
const float textY = static_cast<float>(
m_rect->rect().height() / 2 - QFontMetrics(m_text->font()).height() / 1.8f);
// move the text to the nearest integer x pos, instead of the next lower int pos
// improves results on windows systems
@@ -40,9 +40,10 @@ QtGraphNodeGroup::QtGraphNodeGroup(Id tokenId, const std::wstring& name, GroupTy
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfGroupNode(type, false);
GraphViewStyle::NodeMargins margins = GraphViewStyle::getMarginsOfGroupNode(type, true);
int width = style.textOffset.x * 2 + style.borderWidth + margins.charWidth * name.size();
int height = margins.spacingA + margins.charHeight;
int radius = style.cornerRadius;
const int width = static_cast<int>(
style.textOffset.x * 2 + style.borderWidth + margins.charWidth * name.size());
const int height = static_cast<int>(margins.spacingA + margins.charHeight);
const int radius = style.cornerRadius;
QPainterPath path;
path.moveTo(width, 0);
@@ -21,7 +21,7 @@ QtGraphNodeQualifier::QtGraphNodeQualifier(const NameHierarchy& name): m_qualifi
QFont font;
font.setFamily(GraphViewStyle::getFontNameForDataNode().c_str());
font.setPixelSize(GraphViewStyle::getFontSizeOfQualifier());
font.setPixelSize(static_cast<int>(GraphViewStyle::getFontSizeOfQualifier()));
font.setWeight(QFont::Normal);
m_name = new QGraphicsSimpleTextItem(this);
@@ -38,12 +38,12 @@ bool QtGraphNodeQualifier::isQualifierNode() const
bool QtGraphNodeQualifier::setPosition(const Vec2i& pos)
{
int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10;
int height = QFontMetrics(m_name->font()).height() + 2;
int arrowWidth = height * 0.85;
const int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10;
const int height = QFontMetrics(m_name->font()).height() + 2;
const int arrowWidth = static_cast<int>(height * 0.85);
float smallFactor = 0.5f;
int arrowOffset = arrowWidth * smallFactor;
const float smallFactor = 0.5f;
const int arrowOffset = static_cast<int>(arrowWidth * smallFactor);
m_background->setRect(
pos.x - width - arrowWidth + arrowOffset, pos.y - height / 2, width, height);
@@ -109,12 +109,12 @@ void QtGraphNodeQualifier::updateStyle()
void QtGraphNodeQualifier::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10;
int height = QFontMetrics(m_name->font()).height() + 2;
int arrowWidth = height * 0.85;
float smallFactor = 0.5f;
int arrowOffset = arrowWidth * smallFactor;
int offset = width + arrowWidth - arrowOffset;
const int width = QFontMetrics(m_name->font()).width(m_name->text()) + 10;
const int height = QFontMetrics(m_name->font()).height() + 2;
const int arrowWidth = static_cast<int>(height * 0.85);
const float smallFactor = 0.5f;
const int arrowOffset = static_cast<int>(arrowWidth * smallFactor);
const int offset = width + arrowWidth - arrowOffset;
setRect(m_pos.x - offset, m_pos.y - height / 2, width + arrowWidth, height);
@@ -141,10 +141,10 @@ void QtGraphNodeQualifier::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
void QtGraphNodeQualifier::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
{
int height = QFontMetrics(m_name->font()).height() + 2;
int arrowWidth = height * 0.85;
float smallFactor = 0.5f;
int arrowOffset = arrowWidth * smallFactor;
const int height = QFontMetrics(m_name->font()).height() + 2;
const int arrowWidth = static_cast<int>(height * 0.85);
const float smallFactor = 0.5f;
const int arrowOffset = static_cast<int>(arrowWidth * smallFactor);
setRect(m_pos.x - arrowWidth + arrowOffset, m_pos.y - height / 2, arrowWidth, height);
+1 -1
View File
@@ -1,5 +1,5 @@
#include "QtTcpWrapper.h"
#include "qdatastream.h"
#include <qdatastream.h>
#include "logging.h"
@@ -120,13 +120,17 @@ void addMsvcCompatibilityFlagsOnDemand(std::shared_ptr<SourceGroupSettingsWithCx
template <typename SettingsType>
void addSourceGroupContents(
QtProjectWizardContentGroup* group, std::shared_ptr<SettingsType> settings, QtProjectWizardWindow* window);
QtProjectWizardContentGroup* group,
std::shared_ptr<SettingsType> settings,
QtProjectWizardWindow* window);
#if BUILD_CXX_LANGUAGE_PACKAGE
template <>
void addSourceGroupContents<SourceGroupSettingsCEmpty>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsCEmpty> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsCEmpty> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentCStandard(settings, window));
group->addContent(new QtProjectWizardContentCrossCompilationOptions(settings, window));
@@ -151,12 +155,13 @@ void addSourceGroupContents<SourceGroupSettingsCEmpty>(
group->addContent(new QtProjectWizardContentFlags(settings, window));
group->addContent(new QtProjectWizardContentPathCxxPch(settings, settings, window));
group->addContent(new QtProjectWizardContentCxxPchFlags(settings, window, false));
}
template <>
void addSourceGroupContents<SourceGroupSettingsCppEmpty>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsCppEmpty> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsCppEmpty> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentCppStandard(settings, window));
group->addContent(new QtProjectWizardContentCrossCompilationOptions(settings, window));
@@ -185,10 +190,13 @@ void addSourceGroupContents<SourceGroupSettingsCppEmpty>(
template <>
void addSourceGroupContents<SourceGroupSettingsCxxCdb>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsCxxCdb> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsCxxCdb> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentPathCDB(settings, window));
group->addContent(new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Compilation Database"));
group->addContent(
new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Compilation Database"));
group->addContent(new QtProjectWizardContentPathsExclude(settings, window));
group->addSpace();
@@ -210,14 +218,17 @@ void addSourceGroupContents<SourceGroupSettingsCxxCdb>(
template <>
void addSourceGroupContents<SourceGroupSettingsCxxCodeblocks>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentCppStandard(settings, window));
group->addContent(new QtProjectWizardContentCStandard(settings, window));
group->addContent(new QtProjectWizardContentPathCodeblocksProject(settings, window));
group->addSpace();
group->addContent(new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Code::Blocks Project"));
group->addContent(
new QtProjectWizardContentPathsIndexedHeaders(settings, window, "Code::Blocks Project"));
group->addContent(new QtProjectWizardContentPathsExclude(settings, window));
group->addContent(new QtProjectWizardContentExtensions(settings, window));
group->addSpace();
@@ -242,7 +253,9 @@ void addSourceGroupContents<SourceGroupSettingsCxxCodeblocks>(
template <>
void addSourceGroupContents<SourceGroupSettingsJavaEmpty>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsJavaEmpty> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsJavaEmpty> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentJavaStandard(settings, window));
group->addSpace();
@@ -255,7 +268,9 @@ void addSourceGroupContents<SourceGroupSettingsJavaEmpty>(
template <>
void addSourceGroupContents<SourceGroupSettingsJavaMaven>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsJavaMaven> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsJavaMaven> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentJavaStandard(settings, window));
group->addContent(new QtProjectWizardContentPathSourceMaven(settings, window));
@@ -267,7 +282,9 @@ void addSourceGroupContents<SourceGroupSettingsJavaMaven>(
template <>
void addSourceGroupContents<SourceGroupSettingsJavaGradle>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsJavaGradle> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsJavaGradle> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentJavaStandard(settings, window));
group->addContent(new QtProjectWizardContentPathSourceGradle(settings, window));
@@ -281,7 +298,9 @@ void addSourceGroupContents<SourceGroupSettingsJavaGradle>(
template <>
void addSourceGroupContents<SourceGroupSettingsPythonEmpty>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsPythonEmpty> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsPythonEmpty> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentPathPythonEnvironment(settings, window));
group->addContent(new QtProjectWizardContentPathsSource(settings, window));
@@ -293,7 +312,9 @@ void addSourceGroupContents<SourceGroupSettingsPythonEmpty>(
template <>
void addSourceGroupContents<SourceGroupSettingsCustomCommand>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsCustomCommand> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsCustomCommand> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentCustomCommand(settings, window));
group->addContent(new QtProjectWizardContentPathsSource(settings, window));
@@ -303,7 +324,9 @@ void addSourceGroupContents<SourceGroupSettingsCustomCommand>(
template <>
void addSourceGroupContents<SourceGroupSettingsUnloadable>(
QtProjectWizardContentGroup* group, std::shared_ptr<SourceGroupSettingsUnloadable> settings, QtProjectWizardWindow* window)
QtProjectWizardContentGroup* group,
std::shared_ptr<SourceGroupSettingsUnloadable> settings,
QtProjectWizardWindow* window)
{
group->addContent(new QtProjectWizardContentUnloadable(settings, window));
}
@@ -661,7 +684,8 @@ void QtProjectWizard::selectedSourceGroupChanged(int index)
{
addSourceGroupContents(summary, settings, this);
}
else if (std::shared_ptr<SourceGroupSettingsUnloadable> settings =
else if (
std::shared_ptr<SourceGroupSettingsUnloadable> settings =
std::dynamic_pointer_cast<SourceGroupSettingsUnloadable>(group))
{
addSourceGroupContents(summary, settings, this);
@@ -905,11 +929,9 @@ void QtProjectWizard::newSourceGroupFromVS()
});
window->resize(QSize(560, 320));
connect(window, &QtProjectWizardWindow::next,
[this](){
selectedProjectType(SOURCE_GROUP_CXX_CDB);
}
);
connect(window, &QtProjectWizardWindow::next, [this]() {
selectedProjectType(SOURCE_GROUP_CXX_CDB);
});
window->show();
window->setNextEnabled(true);
@@ -943,12 +965,14 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType)
}
break;
case SOURCE_GROUP_CXX_CDB:
settings = std::make_shared<SourceGroupSettingsCxxCdb>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsCxxCdb>(
sourceGroupId, m_projectSettings.get());
break;
case SOURCE_GROUP_CXX_CODEBLOCKS:
{
std::shared_ptr<SourceGroupSettingsCxxCodeblocks> cxxSettings =
std::make_shared<SourceGroupSettingsCxxCodeblocks>(sourceGroupId, m_projectSettings.get());
std::make_shared<SourceGroupSettingsCxxCodeblocks>(
sourceGroupId, m_projectSettings.get());
addMsvcCompatibilityFlagsOnDemand(cxxSettings);
settings = cxxSettings;
}
@@ -960,24 +984,29 @@ void QtProjectWizard::selectedProjectType(SourceGroupType sourceGroupType)
#if BUILD_JAVA_LANGUAGE_PACKAGE
case SOURCE_GROUP_JAVA_EMPTY:
settings = std::make_shared<SourceGroupSettingsJavaEmpty>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsJavaEmpty>(
sourceGroupId, m_projectSettings.get());
break;
case SOURCE_GROUP_JAVA_MAVEN:
settings = std::make_shared<SourceGroupSettingsJavaMaven>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsJavaMaven>(
sourceGroupId, m_projectSettings.get());
break;
case SOURCE_GROUP_JAVA_GRADLE:
settings = std::make_shared<SourceGroupSettingsJavaGradle>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsJavaGradle>(
sourceGroupId, m_projectSettings.get());
break;
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
case SOURCE_GROUP_PYTHON_EMPTY:
settings = std::make_shared<SourceGroupSettingsPythonEmpty>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsPythonEmpty>(
sourceGroupId, m_projectSettings.get());
break;
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
case SOURCE_GROUP_CUSTOM_COMMAND:
settings = std::make_shared<SourceGroupSettingsCustomCommand>(sourceGroupId, m_projectSettings.get());
settings = std::make_shared<SourceGroupSettingsCustomCommand>(
sourceGroupId, m_projectSettings.get());
break;
case SOURCE_GROUP_UNKNOWN:
break;
@@ -1000,7 +1029,7 @@ void QtProjectWizard::createSourceGroup(std::shared_ptr<SourceGroupSettings> set
m_previouslySelectedIndex = -1;
m_sourceGroupList->setCurrentRow(int(m_allSourceGroupSettings.size()) - 1);
m_sourceGroupList->setCurrentRow(static_cast<int>(m_allSourceGroupSettings.size()) - 1);
}
void QtProjectWizard::createProject()
@@ -33,7 +33,7 @@ void QtProjectWizardContentCStandard::load()
std::vector<std::wstring> standards = m_sourceGroupSettings->getAvailableCStandards();
for (size_t i = 0; i < standards.size(); i++)
{
m_standard->insertItem(i, QString::fromStdWString(standards[i]));
m_standard->insertItem(static_cast<int>(i), QString::fromStdWString(standards[i]));
}
m_standard->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getCStandard()));
@@ -33,7 +33,7 @@ void QtProjectWizardContentCppStandard::load()
std::vector<std::wstring> standards = m_sourceGroupSettings->getAvailableCppStandards();
for (size_t i = 0; i < standards.size(); i++)
{
m_standard->insertItem(i, QString::fromStdWString(standards[i]));
m_standard->insertItem(static_cast<int>(i), QString::fromStdWString(standards[i]));
}
m_standard->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getCppStandard()));
@@ -70,7 +70,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout
std::sort(archTypes.begin(), archTypes.end());
for (size_t i = 0; i < archTypes.size(); i++)
{
m_arch->insertItem(i, QString::fromStdWString(archTypes[i]));
m_arch->insertItem(static_cast<int>(i), QString::fromStdWString(archTypes[i]));
}
m_arch->setCurrentIndex(m_arch->findText("x86_64"));
@@ -87,7 +87,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout
std::sort(vendorTypes.begin() + 1, vendorTypes.end());
for (size_t i = 0; i < vendorTypes.size(); i++)
{
m_vendor->insertItem(i, QString::fromStdWString(vendorTypes[i]));
m_vendor->insertItem(static_cast<int>(i), QString::fromStdWString(vendorTypes[i]));
}
gridLayout->addWidget(label, 1, 0, Qt::AlignRight);
@@ -103,7 +103,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout
std::sort(osTypes.begin() + 1, osTypes.end());
for (size_t i = 0; i < osTypes.size(); i++)
{
m_sys->insertItem(i, QString::fromStdWString(osTypes[i]));
m_sys->insertItem(static_cast<int>(i), QString::fromStdWString(osTypes[i]));
}
gridLayout->addWidget(label, 2, 0, Qt::AlignRight);
@@ -119,7 +119,7 @@ void QtProjectWizardContentCrossCompilationOptions::populate(QGridLayout* layout
std::sort(environmentTypes.begin() + 1, environmentTypes.end());
for (size_t i = 0; i < environmentTypes.size(); i++)
{
m_abi->insertItem(i, QString::fromStdWString(environmentTypes[i]));
m_abi->insertItem(static_cast<int>(i), QString::fromStdWString(environmentTypes[i]));
}
gridLayout->addWidget(label, 3, 0, Qt::AlignRight);
@@ -90,7 +90,8 @@ void QtProjectWizardContentPreferences::populate(QGridLayout* layout, int& row)
for (size_t i = 0; i < m_colorSchemePaths.size(); i++)
{
m_colorSchemes->insertItem(
i, QString::fromStdWString(m_colorSchemePaths[i].withoutExtension().fileName()));
static_cast<int>(i),
QString::fromStdWString(m_colorSchemePaths[i].withoutExtension().fileName()));
}
connect(
m_colorSchemes,
@@ -493,7 +494,7 @@ void QtProjectWizardContentPreferences::load()
m_textEncoding->setCurrentText(QString::fromStdString(appSettings->getTextEncoding()));
FilePath colorSchemePath = appSettings->getColorSchemePath();
for (size_t i = 0; i < m_colorSchemePaths.size(); i++)
for (int i = 0; i < static_cast<int>(m_colorSchemePaths.size()); i++)
{
if (colorSchemePath == m_colorSchemePaths[i])
{
@@ -584,7 +585,7 @@ void QtProjectWizardContentPreferences::save()
if (m_screenScaleFactor)
{
appSettings->setScreenScaleFactor(m_screenScaleFactor->currentData().toDouble());
appSettings->setScreenScaleFactor(m_screenScaleFactor->currentData().toFloat());
}
float scrollSpeed = m_scrollSpeed->text().toFloat();
@@ -208,7 +208,7 @@ void QtProjectWizardContentPathsHeaderSearch::validateIncludesButtonClicked()
sourceFilePaths,
utility::toSet(indexedFilePaths),
utility::toSet(headerSearchPaths),
log2(sourceFilePaths.size()),
static_cast<size_t>(log2(sourceFilePaths.size())),
[&](const float progress) {
dialogView->showProgressDialog(
L"Processing",
@@ -280,7 +280,7 @@ void QtProjectWizardContentPathsHeaderSearch::finishedSelectDetectIncludesRootPa
sourceFilePaths,
utility::toSet(searchedPaths),
utility::toSet(headerSearchPaths),
log2(sourceFilePaths.size()),
static_cast<size_t>(log2(sourceFilePaths.size())),
[&](const float progress) {
dialogView->showProgressDialog(
L"Processing",
@@ -36,13 +36,15 @@ qreal QtDeviceScaledPixmap::height() const
void QtDeviceScaledPixmap::scaleToWidth(int width)
{
m_pixmap = m_pixmap.scaledToWidth(width * devicePixelRatio(), Qt::SmoothTransformation);
m_pixmap = m_pixmap.scaledToWidth(
static_cast<int>(width * devicePixelRatio()), Qt::SmoothTransformation);
m_pixmap.setDevicePixelRatio(devicePixelRatio());
}
void QtDeviceScaledPixmap::scaleToHeight(int height)
{
m_pixmap = m_pixmap.scaledToHeight(height * devicePixelRatio(), Qt::SmoothTransformation);
m_pixmap = m_pixmap.scaledToHeight(
static_cast<int>(height * devicePixelRatio()), Qt::SmoothTransformation);
m_pixmap.setDevicePixelRatio(devicePixelRatio());
}
+2 -2
View File
@@ -170,8 +170,8 @@ void QtHighlighter::highlightDocument()
QTextDocument* doc = document();
size_t docStart = 0;
size_t docEnd = 0;
int docStart = 0;
int docEnd = 0;
for (int i = 0; i < doc->blockCount(); i++)
{
docEnd += doc->findBlockByLineNumber(i).length();
@@ -31,6 +31,6 @@ void QtScrollSpeedChangeListener::doChangeScrollSpeed(float scrollSpeed)
{
if (m_scrollBar)
{
m_scrollBar->setSingleStep(std::ceil(m_singleStep * scrollSpeed));
m_scrollBar->setSingleStep(static_cast<int>(std::ceil(m_singleStep * scrollSpeed)));
}
}
@@ -29,7 +29,8 @@ void QtWindowsTaskbarButton::setProgress(float progress)
if (m_taskbarProgress != nullptr)
{
m_taskbarProgress->show();
m_taskbarProgress->setValue(std::max(0, std::min<int>(100, 100 * progress)));
m_taskbarProgress->setValue(
static_cast<int>(std::max(0, std::min<int>(100, static_cast<int>(100 * progress)))));
}
#endif
}
+13 -13
View File
@@ -99,37 +99,37 @@ std::string getStyleSheet(const FilePath& path)
if (val.find("font_size") != std::string::npos)
{
// check for modifier
if (val.find("+") != std::string::npos)
if (val.find('+') != std::string::npos)
{
int pos = val.find("+");
std::string sub = val.substr(pos + 1);
const size_t findPos = val.find('+');
std::string sub = val.substr(findPos + 1);
int mod = std::stoi(sub);
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + mod);
}
else if (val.find("-") != std::string::npos)
else if (val.find('-') != std::string::npos)
{
int pos = val.find("-");
std::string sub = val.substr(pos + 1);
const size_t findPos = val.find('-');
std::string sub = val.substr(findPos + 1);
int mod = std::stoi(sub);
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() - mod);
}
else if (val.find("*") != std::string::npos)
else if (val.find('*') != std::string::npos)
{
int pos = val.find("*");
std::string sub = val.substr(pos + 1);
const size_t findPos = val.find('*');
std::string sub = val.substr(findPos + 1);
int mod = std::stoi(sub);
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() * mod);
}
else if (val.find("/") != std::string::npos)
else if (val.find('/') != std::string::npos)
{
int pos = val.find("/");
std::string sub = val.substr(pos + 1);
const size_t findPos = val.find('/');
std::string sub = val.substr(findPos + 1);
int mod = std::stoi(sub);
@@ -151,7 +151,7 @@ std::string getStyleSheet(const FilePath& path)
size_t index = 0;
while (true)
{
index = val.find("\\", index);
index = val.find('\\', index);
if (index == std::string::npos)
{
break;
+2 -1
View File
@@ -70,7 +70,8 @@ QtErrorView::QtErrorView(ViewLayout* viewLayout)
return;
}
const Id errorId = m_model->item(index.row(), Column::ID)->text().toLongLong();
const Id errorId = static_cast<Id>(
m_model->item(index.row(), Column::ID)->text().toLongLong());
m_controllerProxy.executeAsTaskWithArgs(&ErrorController::showError, errorId);
}
+11 -8
View File
@@ -363,7 +363,8 @@ void QtGraphView::rebuildGraph(
// move graph to center
QPointF center = itemsBoundingRect(m_nodes).center();
Vec2i o = GraphViewStyle::alignOnRaster(Vec2i(center.x(), center.y()));
const Vec2i o = GraphViewStyle::alignOnRaster(
Vec2i(static_cast<int>(center.x()), static_cast<int>(center.y())));
QPointF offset = QPointF(o.x, o.y);
m_sceneRectOffset = offset - center;
@@ -503,8 +504,10 @@ Vec2i QtGraphView::getViewSize() const
{
QtGraphicsView* view = getView();
float zoomFactor = view->getZoomFactor();
return Vec2i((view->width() - 50) / zoomFactor, (view->height() - 100) / zoomFactor);
const float zoomFactor = view->getZoomFactor();
return Vec2i(
static_cast<int>((view->width() - 50) / zoomFactor),
static_cast<int>((view->height() - 100) / zoomFactor));
}
GroupType QtGraphView::getGrouping() const
@@ -1006,7 +1009,7 @@ QtGraphNode* QtGraphView::createNodeRecursive(
}
else if (node->isExpandToggleNode())
{
newNode = new QtGraphNodeExpandToggle(node->isExpanded(), node->invisibleSubNodeCount);
newNode = new QtGraphNodeExpandToggle(node->isExpanded(), static_cast<int>(node->invisibleSubNodeCount));
}
else if (node->isBundleNode())
{
@@ -1107,10 +1110,10 @@ QtGraphEdge* QtGraphView::createEdge(
std::vector<Vec4i> path = edge->path;
for (size_t i = 0; i < path.size(); i++)
{
path[i].x = path[i].x - pathOffset.x();
path[i].z = path[i].z - pathOffset.x();
path[i].y = path[i].y - pathOffset.y();
path[i].w = path[i].w - pathOffset.y();
path[i].x = static_cast<int>(path[i].x - pathOffset.x());
path[i].z = static_cast<int>(path[i].z - pathOffset.x());
path[i].y = static_cast<int>(path[i].y - pathOffset.y());
path[i].w = static_cast<int>(path[i].w - pathOffset.y());
}
for (const Vec4i& rect: path)
+2 -2
View File
@@ -15,7 +15,7 @@ float QtGraphViewStyleImpl::getCharWidth(const std::string& fontName, size_t fon
float QtGraphViewStyleImpl::getCharHeight(const std::string& fontName, size_t fontSize)
{
return QFontMetrics(getFontForStyleType(fontName, fontSize)).height();
return static_cast<float>(QFontMetrics(getFontForStyleType(fontName, fontSize)).height());
}
float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform()
@@ -31,6 +31,6 @@ float QtGraphViewStyleImpl::getGraphViewZoomDifferenceForPlatform()
QFont QtGraphViewStyleImpl::getFontForStyleType(const std::string& fontName, size_t fontSize) const
{
QFont font(fontName.c_str());
font.setPixelSize(fontSize);
font.setPixelSize(static_cast<int>(fontSize));
return font;
}
+3 -2
View File
@@ -137,12 +137,13 @@ void QtTabsView::addTab()
void QtTabsView::insertTab(bool showTab, const SearchMatch& match)
{
int tabId = TabId::nextTab();
int tabId = static_cast<int>(TabId::nextTab());
m_tabBar->blockSignals(true);
m_insertedTabCount++;
int idx = match.isValid() ? m_tabBar->currentIndex() + m_insertedTabCount : m_tabBar->count() + 1;
int idx = match.isValid() ? static_cast<int>(m_tabBar->currentIndex() + m_insertedTabCount)
: m_tabBar->count() + 1;
idx = m_tabBar->insertTab(idx, QStringLiteral(" Empty Tab "));
m_tabBar->setTabData(idx, QVariant(tabId));
+2 -1
View File
@@ -35,7 +35,8 @@ void QtAbout::setupAbout()
sourcetrailLogo.scaleToHeight(150);
QLabel* sourcetrailLogoLabel = new QLabel(this);
sourcetrailLogoLabel->setPixmap(sourcetrailLogo.pixmap());
sourcetrailLogoLabel->resize(sourcetrailLogo.width(), sourcetrailLogo.height());
sourcetrailLogoLabel->resize(
static_cast<int>(sourcetrailLogo.width()), static_cast<int>(sourcetrailLogo.height()));
windowLayout->addWidget(
sourcetrailLogoLabel, 0, Qt::Alignment(Qt::AlignmentFlag::AlignHCenter));
}
+1 -1
View File
@@ -65,7 +65,7 @@ QLabel* QtIndexingDialog::createFlagLabel(QWidget* parent)
QLabel* flagLabel = new QLabel(parent);
flagLabel->setPixmap(flag.pixmap());
flagLabel->resize(flag.width(), flag.height());
flagLabel->resize(static_cast<int>(flag.width()), static_cast<int>(flag.height()));
flagLabel->move(15, 75);
flagLabel->show();
@@ -6,7 +6,7 @@
#include "MessageIndexingInterrupted.h"
QtIndexingProgressDialog::QtIndexingProgressDialog(bool hideable, QWidget* parent)
: QtProgressBarDialog(0.38, true, parent), m_filePathLabel(nullptr), m_errorWidget(nullptr)
: QtProgressBarDialog(0.38f, true, parent), m_filePathLabel(nullptr), m_errorWidget(nullptr)
{
setSizeGripStyle(false);
@@ -57,7 +57,7 @@ void QtIndexingProgressDialog::updateIndexingProgress(
QString::number(fileCount) + "/" + QString::number(totalFileCount) + " File" +
(totalFileCount > 1 ? "s" : ""));
int progress = 0;
size_t progress = 0;
if (totalFileCount > 0)
{
progress = fileCount * 100 / totalFileCount;

Some files were not shown because too many files have changed in this diff Show More