Remove dead code "< QT_VERSION_CHECK(5, 14, 0)"

Qt Creator required Qt 5.14 or higher. Let's removed the #idef-ed code
for building against lower Qt versions.

Add a comment in porting.h where we still need such code for sdktool.

Change-Id: Ib330275208eec4a2f285b4b9f480530c171f538a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Alessandro Portale
2021-03-09 16:56:25 +01:00
parent e960062b80
commit 93fbd5be02
25 changed files with 5 additions and 159 deletions

View File

@@ -151,11 +151,7 @@ namespace ADS {
return QLabel::minimumSizeHint();
const QFontMetrics &fm = fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->m_text.left(2) + ""), fm.height());
#else
QSize size(fm.width(d->m_text.left(2) + ""), fm.height());
#endif
return size;
}
@@ -165,11 +161,7 @@ namespace ADS {
return QLabel::sizeHint();
const QFontMetrics &fm = fontMetrics();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
QSize size(fm.horizontalAdvance(d->m_text), QLabel::sizeHint().height());
#else
QSize size(fm.width(d->m_text), QLabel::sizeHint().height());
#endif
return size;
}

View File

@@ -878,13 +878,8 @@ bool FloatingDockContainer::event(QEvent *event)
// is clicked.
// It is really great to work around the whole NonClientMouseArea
// bugs
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
if (event->type() == QEvent::NonClientAreaMouseButtonPress
/*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
#else
if (event->type() == QEvent::NonClientAreaMouseButtonPress
&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton))
#endif
{
qCInfo(adsLog) << Q_FUNC_INFO << "QEvent::NonClientAreaMouseButtonPress"
<< event->type();

View File

@@ -64,11 +64,7 @@ bool GeometryUtilities::intersect(const QPolygonF &polygon, const QLineF &line,
for (int i = 0; i <= polygon.size() - 2; ++i) {
QLineF polygonLine(polygon.at(i), polygon.at(i+1));
QPointF point;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectType intersectionType = polygonLine.intersect(line, &point);
#else
QLineF::IntersectType intersectionType = polygonLine.intersects(line, &point);
#endif
if (intersectionType == QLineF::BoundedIntersection) {
qreal dist = QLineF(point, nearestPoint <= 0 ? line.p1() : line.p2()).length();
if (!found || dist < mindist) {
@@ -102,11 +98,7 @@ bool GeometryUtilities::intersect(const QList<QPolygonF> &polygons, const QLineF
for (int i = 0; i <= polygon.size() - 2; ++i) {
const QLineF polygonLine(polygon.at(i), polygon.at(i + 1));
QPointF point;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QLineF::IntersectType intersectionType = polygonLine.intersect(line, &point);
#else
QLineF::IntersectType intersectionType = polygonLine.intersects(line, &point);
#endif
if (intersectionType == QLineF::BoundedIntersection) {
qreal dist = QLineF(point, nearestPoint <= 0 ? line.p1() : line.p2()).length();
if (!found || dist < mindist) {

View File

@@ -352,13 +352,8 @@ void PropertiesView::MView::visitMElement(const MElement *element)
m_stereotypeComboBox->addItems(m_propertiesView->stereotypeController()->knownStereotypes(m_stereotypeElement));
connect(m_stereotypeComboBox->lineEdit(), &QLineEdit::textEdited,
this, &PropertiesView::MView::onStereotypesChanged);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
connect(m_stereotypeComboBox, QOverload<const QString &>::of(&QComboBox::activated),
this, &PropertiesView::MView::onStereotypesChanged);
#else
connect(m_stereotypeComboBox, &QComboBox::textActivated,
this, &PropertiesView::MView::onStereotypesChanged);
#endif
}
if (!m_stereotypeComboBox->hasFocus()) {
QList<QString> stereotypeList;

View File

@@ -209,13 +209,8 @@ void TimelineRenderer::wheelEvent(QWheelEvent *event)
int degrees = (event->angleDelta().x() + event->angleDelta().y()) / 8;
const qint64 circle = 360;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
qint64 mouseTime = event->pos().x() * zoom->windowDuration() / width() +
zoom->windowStart();
#else
qint64 mouseTime = event->position().toPoint().x() * zoom->windowDuration() / width() +
zoom->windowStart();
#endif
qint64 beforeMouse = (mouseTime - zoom->rangeStart()) * (circle - degrees) / circle;
qint64 afterMouse = (zoom->rangeEnd() - mouseTime) * (circle - degrees) / circle;

View File

@@ -1283,37 +1283,21 @@ OutputIterator set_union(InputIterator1 first1,
template <class T>
QSet<T> toSet(const QList<T> &list)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
return list.toSet();
#else
return QSet<T>(list.begin(), list.end());
#endif
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
template<class T>
QSet<T> toSet(const QVector<T> &vec)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
QSet<T> result;
for (const T &p : vec) {
result.insert(p);
}
return result;
#else
return QSet<T>(vec.begin(), vec.end());
#endif
}
#endif
template<class T>
QList<T> toList(const QSet<T> &set)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
return set.toList();
#else
return QList<T>(set.begin(), set.end());
#endif
}
template <class Key, class T>

View File

@@ -35,6 +35,7 @@
namespace Utils {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
// Keep the support code for lower Qt versions for sdktool
constexpr QString::SplitBehavior SkipEmptyParts = QString::SkipEmptyParts;
#else
constexpr Qt::SplitBehaviorFlags SkipEmptyParts = Qt::SkipEmptyParts;

View File

@@ -94,9 +94,6 @@ GeneralSettingsWidget::GeneralSettingsWidget(GeneralSettings *q)
tr("Show keyboard shortcuts in context menus (default: %1)")
.arg(q->m_defaultShowShortcutsInContextMenu ? tr("on") : tr("off")));
m_ui.showShortcutsInContextMenus->setChecked(GeneralSettings::showShortcutsInContextMenu());
#if (QT_VERSION < QT_VERSION_CHECK(5, 13, 0))
m_ui.showShortcutsInContextMenus->setVisible(false);
#endif
if (Utils::HostOsInfo::isMacHost()) {
m_ui.dpiCheckbox->setVisible(false);
@@ -250,9 +247,7 @@ void GeneralSettings::setShowShortcutsInContextMenu(bool show)
ICore::settings()->setValueWithDefault(settingsKeyShortcutsInContextMenu,
show,
m_defaultShowShortcutsInContextMenu);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
QGuiApplication::styleHints()->setShowShortcutsInContextMenus(show);
#endif
}
GeneralSettings::GeneralSettings()

View File

@@ -36,20 +36,6 @@
#include <unordered_map>
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
namespace std {
template<> struct hash<QString>
{
using argument_type = QString;
using result_type = size_t;
result_type operator()(const argument_type &v) const
{
return hash<string>()(v.toStdString());
}
};
} // namespace std
#endif
using ExtensionMap = std::unordered_map<QString, Core::JsExpander::ObjectFactory>;
Q_GLOBAL_STATIC(ExtensionMap, globalJsExtensions);

View File

@@ -33,10 +33,8 @@
#ifdef QTC_WEBENGINE_HELPVIEWER
#include "webenginehelpviewer.h"
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
#include <QWebEngineUrlScheme>
#endif
#endif
#ifdef QTC_LITEHTML_HELPVIEWER
#include "litehtmlhelpviewer.h"
#endif

View File

@@ -152,11 +152,7 @@ WebEngineHelpViewer::WebEngineHelpViewer(QWidget *parent) :
QTC_ASSERT(viewProfile, return);
if (!viewProfile->urlSchemeHandler("qthelp"))
viewProfile->installUrlSchemeHandler("qthelp", helpUrlSchemeHandler());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
viewProfile->setUrlRequestInterceptor(helpurlRequestInterceptor());
#else
viewProfile->setRequestInterceptor(helpurlRequestInterceptor());
#endif
}
void WebEngineHelpViewer::setViewerFont(const QFont &font)

View File

@@ -72,11 +72,7 @@ void EditorDiagramView::wheelEvent(QWheelEvent *wheelEvent)
{
if (wheelEvent->modifiers() == Qt::ControlModifier) {
int degree = wheelEvent->angleDelta().y() / 8;
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QPoint zoomOrigin = wheelEvent->pos();
#else
QPoint zoomOrigin = wheelEvent->position().toPoint();
#endif
if (degree > 0)
emit zoomIn(zoomOrigin);
else if (degree < 0)

View File

@@ -192,11 +192,7 @@ bool BuildStepList::removeStep(int position)
void BuildStepList::moveStepUp(int position)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
m_steps.swapItemsAt(position - 1, position);
#else
m_steps.swap(position - 1, position);
#endif
emit stepMoved(position, position - 1);
}

View File

@@ -91,11 +91,7 @@ QWidget *ChangeStyleWidgetAction::createWidget(QWidget *parent)
});
connect(comboBox,
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QOverload<const QString &>::of(&QComboBox::activated),
#else
&QComboBox::textActivated,
#endif
this,
[this](const QString &style) {

View File

@@ -167,12 +167,7 @@ QString GradientPresetItem::getNameByPreset(Preset value)
QGradient GradientPresetItem::createGradientFromPreset(Preset value)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
return QGradient(value);
#else
Q_UNUSED(value)
return {};
#endif
}
QDebug &operator<<(QDebug &stream, const GradientPresetItem &gradient)

View File

@@ -39,17 +39,8 @@ class GradientPresetItem
Q_PROPERTY(int presetID READ presetID FINAL)
public:
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
using Preset = QGradient::Preset;
#else
enum Preset {};
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
static const int numPresets = Preset::NumPresets;
#else
static const int numPresets = 181;
#endif
explicit GradientPresetItem();
explicit GradientPresetItem(const QGradient &value, const QString &name = QString());

View File

@@ -579,11 +579,7 @@ void RichTextEditor::setupTableActions()
tableFormat.setCellSpacing(2.0);
tableFormat.setCellPadding(2.0);
tableFormat.setBorder(1.0);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
tableFormat.setBorderCollapse(true);
#endif
cursor.insertTable(1, 1, tableFormat);
//move cursor into the first cell of the table:

View File

@@ -56,9 +56,7 @@ FloatControl::FloatControl()
setValue(0.0);
setButtonSymbols(QAbstractSpinBox::NoButtons);
setFrame(false);
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
setStepType(QAbstractSpinBox::AdaptiveDecimalStepType);
#endif
setMinimum(std::numeric_limits<float>::lowest());
setMaximum(std::numeric_limits<float>::max());

View File

@@ -186,22 +186,12 @@ void DesignerMcuManager::readVersionData(const DesignerMcuManager::Version &vers
//handling banned properties:
const QStringList bannedProperties = readPropertyList("bannedProperties", child);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_bannedProperties.unite(QSet<QString>(bannedProperties.begin(), bannedProperties.end()));
#elif
m_bannedProperties.unite(QSet<QString>::fromList(bannedProperties));
#endif
}
const QList<QString> bannedItems = readPropertyList("bannedItems", versionData);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_bannedItems = QSet<QString>(bannedItems.begin(), bannedItems.end());
#elif
m_bannedItems = QSet<QString>::fromList(bannedItems);
#endif
m_bannedItems = QSet<QString>(bannedItems.begin(), bannedItems.end());
m_allowedImports = readPropertyList("allowedImports", versionData);
m_bannedImports = readPropertyList("bannedImports", versionData);
m_currentVersion = version;

View File

@@ -76,13 +76,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::NAVIGATOR_SHOW_ONLY_VISIBLE_ITEMS, true);
restoreValue(settings, DesignerSettingsKey::NAVIGATOR_REVERSE_ITEM_ORDER, false);
restoreValue(settings, DesignerSettingsKey::STANDALONE_MODE, false);
restoreValue(settings, DesignerSettingsKey::ENABLE_TIMELINEVIEW,
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
false
#else
true
#endif
);
restoreValue(settings, DesignerSettingsKey::ENABLE_TIMELINEVIEW, true);
restoreValue(settings, DesignerSettingsKey::SIMPLE_COLOR_PALETTE_CONTENT, QStringList());
restoreValue(settings, DesignerSettingsKey::ALWAYS_DESIGN_MODE, true);
restoreValue(settings, DesignerSettingsKey::DISABLE_ITEM_LIBRARY_UPDATE_TIMER, true);

View File

@@ -80,11 +80,7 @@ void NavigatorGraphicsView::wheelEvent(QWheelEvent *event)
else
emit zoomOut();
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
emit moveMainViewTo(mapToScene(event->pos()));
#else
emit moveMainViewTo(mapToScene(event->position().toPoint()));
#endif
} else
QGraphicsView::wheelEvent(event);
}

View File

@@ -225,11 +225,7 @@ void layout(const QList<QGraphicsItem*> &items)
firstItem = initialItem->outputTransitions().constFirst()->connectedItem(initialItem);
int index = childItems.indexOf(firstItem);
if (index > 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
childItems.swap(index, 0);
#else
childItems.swapItemsAt(index, 0);
#endif
}
// Search final-item

View File

@@ -306,19 +306,11 @@ void TransitionItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
QPointF intersPoint;
QLineF line2(p, p + QPointF(SELECTION_DISTANCE, SELECTION_DISTANCE));
line2.setAngle(line.angle() + 90);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection)
#else
if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection)
#endif
if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection) {
sel = true;
else {
} else {
line2.setAngle(line.angle() - 90);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
sel = line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection;
#else
sel = line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection;
#endif
}
if (sel)
@@ -805,11 +797,7 @@ QPointF TransitionItem::findIntersectionPoint(ConnectableItem *item, const QLine
for (int i = 1; i < itemPolygon.count(); ++i) {
p2 = itemPolygon.at(i) + item->scenePos();
checkLine = QLineF(p1, p2);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if (checkLine.intersect(line, &intersectPoint) == QLineF::BoundedIntersection)
#else
if (checkLine.intersects(line, &intersectPoint) == QLineF::BoundedIntersection)
#endif
return intersectPoint;
p1 = p2;
}
@@ -1096,19 +1084,11 @@ bool TransitionItem::containsScenePoint(const QPointF &p) const
QPointF intersPoint;
QLineF line2(pp, pp + QPointF(SELECTION_DISTANCE, SELECTION_DISTANCE));
line2.setAngle(line.angle() + 90);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection) {
#else
if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection) {
#endif
return true;
} else {
line2.setAngle(line.angle() - 90);
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
if (line.intersect(line2, &intersPoint) == QLineF::BoundedIntersection)
#else
if (line.intersects(line2, &intersPoint) == QLineF::BoundedIntersection)
#endif
return true;
}
}

View File

@@ -1214,11 +1214,7 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
QAbstractTextDocumentLayout *layout = doc->documentLayout();
layout->setPaintDevice(p.device());
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
int dpiy = p.device()->logicalDpiY();
#else
int dpiy = qRound(QGuiApplication::primaryScreen()->logicalDotsPerInchY());
#endif
int margin = int((2/2.54)*dpiy); // 2 cm margins
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();

View File

@@ -4709,7 +4709,6 @@ void tst_TestCore::testImplicitComponents()
void tst_TestCore::testRevisionedProperties()
{
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
const char* qmlString
= "import QtQuick 2.12\n"
"import QtQuick.Controls 2.0\n"
@@ -4761,8 +4760,6 @@ void tst_TestCore::testRevisionedProperties()
QVERIFY(metaInfo12.hasProperty("orientation"));
QVERIFY(metaInfoU.hasProperty("orientation"));
#endif
}
void tst_TestCore::testStatesRewriter()