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
@@ -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;
+11 -4
View File
@@ -94,18 +94,25 @@ void QtProgressBarDialog::setGeometries()
if (m_top)
{
QMargins margins = m_content->layout()->contentsMargins();
margins.setTop(m_window->size().height() * m_topRatio + 10);
margins.setTop(static_cast<int>(m_window->size().height() * m_topRatio + 10));
m_content->layout()->setContentsMargins(margins);
m_top->setGeometry(0, 0, m_window->size().width(), m_window->size().height() * m_topRatio);
m_top->setGeometry(
0, 0, m_window->size().width(), static_cast<int>(m_window->size().height() * m_topRatio));
m_title->setGeometry(
45, m_window->size().height() * m_topRatio - 50, m_window->size().width() - 60, 40);
45,
static_cast<int>(m_window->size().height() * m_topRatio - 50),
m_window->size().width() - 60,
40);
}
if (m_progressBar)
{
m_progressBar->setGeometry(
0, m_window->size().height() * m_topRatio - 5, m_window->size().width(), 10);
0,
static_cast<int>(m_window->size().height() * m_topRatio - 5),
m_window->size().width(),
10);
}
}
+2 -1
View File
@@ -351,7 +351,8 @@ void QtWindow::addLogo()
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()));
sourcetrailLogoLabel->move(m_isSubWindow ? 40 : 23, 25);
sourcetrailLogoLabel->show();
@@ -60,8 +60,10 @@ FilePath JavaPathDetectorLinux::getFilePathRelativeToJavaExecutable(FilePath& ja
FilePath JavaPathDetectorLinux::getJavaInJavaHome() const
{
std::string command = "";
#pragma warning(push)
#pragma warning(disable : 4996)
char* p = getenv("JAVA_HOME");
#pragma warning(pop)
if (p == nullptr)
{
return FilePath();