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:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user