Skip to content

Commit c8d6d70

Browse files
authored
Merge pull request #1001 from Vekhir/fix-qt6-warnings
Fix qt and c++ warnings
2 parents 2e12978 + 7bf783a commit c8d6d70

23 files changed

Lines changed: 174 additions & 25 deletions

plugins/cffadaptor/src/UBCFFAdaptor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parsePageset(const QStringList &page
631631

632632
QDomElement svgPagesetElement = mDocumentToWrite->createElementNS(svgIWBNS,":"+ tIWBPageSet);
633633

634-
for (const auto &value : qAsConst(pageList)) {
634+
for (const auto &value : std::as_const(pageList)) {
635635
svgPagesetElement.appendChild(value);
636636
}
637637

@@ -680,7 +680,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen
680680
// to do:
681681
// there we must to sort elements (take elements from list and assign parent ordered like in parseSVGGGroup)
682682
// we returns just element because we don't care about layer.
683-
for (const auto &value : qAsConst(svgElements)) {
683+
for (const auto &value : std::as_const(svgElements)) {
684684
svgElementPart.appendChild(value);
685685
}
686686

@@ -1612,7 +1612,7 @@ bool UBCFFAdaptor::UBToCFFConverter::parseSVGGGroup(const QDomElement &element,
16121612
std::sort(layers.begin(), layers.end());
16131613
int layer = layers.at(0);
16141614

1615-
for (const auto &value : qAsConst(svgElements)) {
1615+
for (const auto &value : std::as_const(svgElements)) {
16161616
svgElementPart.appendChild(value);
16171617
}
16181618

src/adaptors/UBSvgSubsetAdaptor.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,14 +551,22 @@ std::shared_ptr<UBGraphicsScene> UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScen
551551

552552
if (!ubFillOnDarkBackground.isNull())
553553
{
554+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
555+
mGroupDarkBackgroundColor = QColor::fromString(ubFillOnDarkBackground.toString());
556+
#else
554557
mGroupDarkBackgroundColor.setNamedColor(ubFillOnDarkBackground.toString());
558+
#endif
555559
}
556560

557561
auto ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background");
558562

559563
if (!ubFillOnLightBackground.isNull())
560564
{
565+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
566+
mGroupLightBackgroundColor = QColor::fromString(ubFillOnLightBackground.toString());
567+
#else
561568
mGroupLightBackgroundColor.setNamedColor(ubFillOnLightBackground.toString());
569+
#endif
562570
}
563571

564572
auto ubUuid = mXmlReader.attributes().value(mNamespaceUri, "uuid");
@@ -1784,7 +1792,11 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
17841792
QColor brushColor = pDefaultColor;
17851793

17861794
if (!svgFill.isNull())
1795+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1796+
brushColor = QColor::fromString(svgFill.toString());
1797+
#else
17871798
brushColor.setNamedColor(svgFill.toString());
1799+
#endif
17881800

17891801
auto svgFillOpacity = mXmlReader.attributes().value("fill-opacity");
17901802
qreal opacity = 1.0;
@@ -1801,8 +1813,12 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
18011813

18021814
if (!ubFillOnDarkBackground.isNull())
18031815
{
1816+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1817+
QColor color = QColor::fromString(ubFillOnDarkBackground.toString());
1818+
#else
18041819
QColor color;
18051820
color.setNamedColor(ubFillOnDarkBackground.toString());
1821+
#endif
18061822
if (!color.isValid())
18071823
color = Qt::white;
18081824

@@ -1820,8 +1836,12 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
18201836

18211837
if (!ubFillOnLightBackground.isNull())
18221838
{
1839+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1840+
QColor color = QColor::fromString(ubFillOnLightBackground.toString());
1841+
#else
18231842
QColor color;
18241843
color.setNamedColor(ubFillOnLightBackground.toString());
1844+
#endif
18251845
if (!color.isValid())
18261846
color = Qt::black;
18271847
color.setAlphaF(opacity);
@@ -1890,7 +1910,11 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
18901910

18911911
if (!svgStroke.isNull())
18921912
{
1913+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1914+
brushColor = QColor::fromString(svgStroke.toString());
1915+
#else
18931916
brushColor.setNamedColor(svgStroke.toString());
1917+
#endif
18941918

18951919
}
18961920

@@ -1909,8 +1933,12 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
19091933

19101934
if (!ubFillOnDarkBackground.isNull())
19111935
{
1936+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1937+
QColor color = QColor::fromString(ubFillOnDarkBackground.toString());
1938+
#else
19121939
QColor color;
19131940
color.setNamedColor(ubFillOnDarkBackground.toString());
1941+
#endif
19141942
if (!color.isValid())
19151943
color = Qt::white;
19161944

@@ -1928,8 +1956,12 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromLin
19281956

19291957
if (!ubFillOnLightBackground.isNull())
19301958
{
1959+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1960+
QColor color = QColor::fromString(ubFillOnLightBackground.toString());
1961+
#else
19311962
QColor color;
19321963
color.setNamedColor(ubFillOnLightBackground.toString());
1964+
#endif
19331965
if (!color.isValid())
19341966
color = Qt::black;
19351967
color.setAlphaF(opacity);
@@ -1961,7 +1993,11 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
19611993
auto svgStroke = mXmlReader.attributes().value("stroke");
19621994
if (!svgStroke.isNull())
19631995
{
1996+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
1997+
brushColor = QColor::fromString(svgStroke.toString());
1998+
#else
19641999
brushColor.setNamedColor(svgStroke.toString());
2000+
#endif
19652001
}
19662002

19672003
qreal opacity = 1.0;
@@ -1987,7 +2023,11 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
19872023
auto ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background");
19882024
if (!ubFillOnDarkBackground.isNull())
19892025
{
2026+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
2027+
colorOnDarkBackground = QColor::fromString(ubFillOnDarkBackground.toString());
2028+
#else
19902029
colorOnDarkBackground.setNamedColor(ubFillOnDarkBackground.toString());
2030+
#endif
19912031
}
19922032

19932033
if (!colorOnDarkBackground.isValid())
@@ -2000,8 +2040,11 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
20002040
auto ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background");
20012041
if (!ubFillOnLightBackground.isNull())
20022042
{
2003-
QColor colorOnLightBackground;
2043+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
2044+
colorOnLightBackground = QColor::fromString(ubFillOnLightBackground.toString());
2045+
#else
20042046
colorOnLightBackground.setNamedColor(ubFillOnLightBackground.toString());
2047+
#endif
20052048
}
20062049

20072050
if (!colorOnLightBackground.isValid())
@@ -2763,16 +2806,24 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
27632806
auto ubFillOnLightBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-light-background");
27642807

27652808
if (!ubFillOnDarkBackground.isNull()) {
2809+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
2810+
QColor color = QColor::fromString(ubFillOnDarkBackground.toString());
2811+
#else
27662812
QColor color;
27672813
color.setNamedColor(ubFillOnDarkBackground.toString());
2814+
#endif
27682815
if (!color.isValid())
27692816
color = Qt::white;
27702817
textItem->setColorOnDarkBackground(color);
27712818
}
27722819

27732820
if (!ubFillOnLightBackground.isNull()) {
2821+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
2822+
QColor color = QColor::fromString(ubFillOnLightBackground.toString());
2823+
#else
27742824
QColor color;
27752825
color.setNamedColor(ubFillOnLightBackground.toString());
2826+
#endif
27762827
if (!color.isValid())
27772828
color = Qt::black;
27782829
textItem->setColorOnLightBackground(color);
@@ -2873,8 +2924,12 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
28732924

28742925
auto fill = mXmlReader.attributes().value("color");
28752926
if (!fill.isNull()) {
2927+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
2928+
QColor textColor = QColor::fromString(fill.toString());
2929+
#else
28762930
QColor textColor;
28772931
textColor.setNamedColor(fill.toString());
2932+
#endif
28782933
textItem->setDefaultTextColor(textColor);
28792934
}
28802935

src/adaptors/UBWidgetUpgradeAdaptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void UBWidgetUpgradeAdaptor::fillLibraryWidgets()
209209
widgetPaths << UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->applicationInteractivesDirectory());
210210
widgetPaths << UBPersistenceManager::persistenceManager()->allWidgets(UBSettings::settings()->userInteractiveDirectory());
211211

212-
for (const QString& wigetPath : qAsConst(widgetPaths)) {
212+
for (const QString& wigetPath : std::as_const(widgetPaths)) {
213213
Widget widget(wigetPath);
214214

215215
if (widget.valid())

src/api/UBWidgetUniboardAPI.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ void UBWidgetUniboardAPI::setPenColor(const QString& penColor)
165165
}
166166
else
167167
{
168+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
169+
QColor svgColor = QColor::fromString(penColor);
170+
#else
168171
QColor svgColor;
169172
svgColor.setNamedColor(penColor);
173+
#endif
170174
if (svgColor.isValid())
171175
{
172176
UBApplication::boardController->setPenColorOnDarkBackground(svgColor);
@@ -194,8 +198,12 @@ void UBWidgetUniboardAPI::setMarkerColor(const QString& penColor)
194198
}
195199
else
196200
{
201+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
202+
QColor svgColor = QColor::fromString(penColor);
203+
#else
197204
QColor svgColor;
198205
svgColor.setNamedColor(penColor);
206+
#endif
199207
if (svgColor.isValid())
200208
{
201209
UBApplication::boardController->setMarkerColorOnDarkBackground(svgColor);

src/board/UBBoardPaletteManager.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,11 @@ void UBBoardPaletteManager::connectPalettes()
405405
{
406406
connect(UBApplication::mainWindow->actionStylus, SIGNAL(toggled(bool)), this, SLOT(toggleStylusPalette(bool)));
407407

408+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
409+
foreach(QObject *widget, UBApplication::mainWindow->actionZoomIn->associatedObjects())
410+
#else
408411
foreach(QWidget *widget, UBApplication::mainWindow->actionZoomIn->associatedWidgets())
412+
#endif
409413
{
410414
QAbstractButton *button = qobject_cast<QAbstractButton*>(widget);
411415
if (button)
@@ -415,7 +419,11 @@ void UBBoardPaletteManager::connectPalettes()
415419
}
416420
}
417421

422+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
423+
foreach(QObject *widget, UBApplication::mainWindow->actionZoomOut->associatedObjects())
424+
#else
418425
foreach(QWidget *widget, UBApplication::mainWindow->actionZoomOut->associatedWidgets())
426+
#endif
419427
{
420428
QAbstractButton *button = qobject_cast<QAbstractButton*>(widget);
421429
if (button)
@@ -425,7 +433,11 @@ void UBBoardPaletteManager::connectPalettes()
425433
}
426434
}
427435

436+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
437+
foreach(QObject *widget, UBApplication::mainWindow->actionHand->associatedObjects())
438+
#else
428439
foreach(QWidget *widget, UBApplication::mainWindow->actionHand->associatedWidgets())
440+
#endif
429441
{
430442
QAbstractButton *button = qobject_cast<QAbstractButton*>(widget);
431443
if (button)
@@ -458,7 +470,11 @@ void UBBoardPaletteManager::connectPalettes()
458470
connect(UBApplication::mainWindow->actionEraseBackground,SIGNAL(triggered()),mErasePalette,SLOT(close()));
459471
connect(mErasePalette, SIGNAL(closed()), this, SLOT(erasePaletteClosed()));
460472

473+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
474+
foreach(QObject *widget, UBApplication::mainWindow->actionErase->associatedObjects())
475+
#else
461476
foreach(QWidget *widget, UBApplication::mainWindow->actionErase->associatedWidgets())
477+
#endif
462478
{
463479
QAbstractButton *button = qobject_cast<QAbstractButton*>(widget);
464480
if (button)
@@ -473,7 +489,11 @@ void UBBoardPaletteManager::connectPalettes()
473489
connect(UBApplication::mainWindow->actionImportPage, SIGNAL(triggered()), mPagePalette, SLOT(close()));
474490
connect(mPagePalette, SIGNAL(closed()), this, SLOT(pagePaletteClosed()));
475491

492+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
493+
foreach(QObject *widget, UBApplication::mainWindow->actionPages->associatedObjects())
494+
#else
476495
foreach(QWidget *widget, UBApplication::mainWindow->actionPages->associatedWidgets())
496+
#endif
477497
{
478498
QAbstractButton *button = qobject_cast<QAbstractButton*>(widget);
479499
if (button)

src/board/UBBoardView.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,13 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
822822

823823
if (itemShouldReceiveSuspendedMousePressEvent(getMovingItem()))
824824
{
825+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
826+
suspendedMousePressEvent = new QMouseEvent(event->type(), event->position(), event->globalPosition(), event->button(), event->buttons(), event->modifiers());
827+
#elif (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
828+
suspendedMousePressEvent = new QMouseEvent(event->type(), event->position(), event->button(), event->buttons(), event->modifiers());
829+
#else
825830
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers());
831+
#endif
826832
}
827833
}
828834
}

src/board/UBFeaturesController.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ QString UBFeature::getNameFromVirtualPath(const QString &pVirtPath)
241241
QString result;
242242
int slashPos = pVirtPath.lastIndexOf("/");
243243
if (slashPos != -1) {
244-
result = pVirtPath.right(pVirtPath.count() - slashPos - 1);
244+
result = pVirtPath.right(pVirtPath.length() - slashPos - 1);
245245
} else {
246246
qDebug() << "UBFeature: incorrect virtual path parameter specified";
247247
}
@@ -441,7 +441,7 @@ void UBFeaturesController::scanFS()
441441
}
442442

443443
QSet<QUrl> favoriteDocumentsToRemove;
444-
for (auto&& favoriteElement : qAsConst(*favoriteSet))
444+
for (auto&& favoriteElement : std::as_const(*favoriteSet))
445445
{
446446
if (favoriteElement.fileName().endsWith(".rdf"))
447447
{
@@ -462,7 +462,7 @@ void UBFeaturesController::scanFS()
462462
}
463463
}
464464

465-
for (auto&& favoriteDocumentToRemove : qAsConst(favoriteDocumentsToRemove))
465+
for (auto&& favoriteDocumentToRemove : std::as_const(favoriteDocumentsToRemove))
466466
{
467467
removeFromFavorite(favoriteDocumentToRemove);
468468
}
@@ -529,7 +529,7 @@ bool UBFeaturesController::isInFavoriteList(QUrl url)
529529

530530
bool UBFeaturesController::isDocumentInFavoriteList(QString documentFolderName)
531531
{
532-
for(auto&& url : qAsConst(*favoriteSet))
532+
for(auto&& url : std::as_const(*favoriteSet))
533533
{
534534
QString localFile = url.toLocalFile();
535535
if (localFile.endsWith(".rdf"))
@@ -546,7 +546,7 @@ bool UBFeaturesController::isDocumentInFavoriteList(QString documentFolderName)
546546

547547
bool UBFeaturesController::isInRecentlyOpenDocuments(QString documentFolderName)
548548
{
549-
for(auto&& url : qAsConst(recentlyOpenDocuments))
549+
for(auto&& url : std::as_const(recentlyOpenDocuments))
550550
{
551551
QString localFile = url.toLocalFile();
552552
if (localFile.endsWith(".rdf"))
@@ -611,10 +611,10 @@ QString UBFeaturesController::uniqNameForFeature(const UBFeature &feature, const
611611
if (!parentVirtualPath.endsWith("/")) {
612612
parentVirtualPath.append("/");
613613
}
614-
//Cut virtual path prevfix
614+
//Cut virtual path prefix
615615
int i = curResultName.indexOf(feature.getFullVirtualPath());
616616
if (i != -1) {
617-
curResultName = curResultName.right(curFeature.getFullVirtualPath().count() - i - parentVirtualPath.count());
617+
curResultName = curResultName.right(curFeature.getFullVirtualPath().length() - i - parentVirtualPath.length());
618618
}
619619
//if directory has children, emptying the name;
620620
i = curResultName.indexOf("/");
@@ -869,7 +869,7 @@ QString UBFeaturesController::categoryNameForVirtualPath(const QString &str)
869869
QString result;
870870
int ind = str.lastIndexOf("/");
871871
if (ind != -1) {
872-
result = str.right(str.count() - ind - 1);
872+
result = str.right(str.length() - ind - 1);
873873
}
874874
return result;
875875
}

src/core/UBApplication.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,11 @@ void UBApplication::setDisabled(bool disable)
546546

547547
void UBApplication::decorateActionMenu(QAction* action)
548548
{
549+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
550+
foreach(QObject* menuWidget, action->associatedObjects())
551+
#else
549552
foreach(QWidget* menuWidget, action->associatedWidgets())
553+
#endif
550554
{
551555
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
552556

src/core/UBDisplayManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void UBDisplayManager::blackout()
448448

449449
UBPlatformUtils::fadeDisplayOut();
450450

451-
for (UBBlackoutWidget* blackoutWidget : qAsConst(mBlackoutWidgets))
451+
for (UBBlackoutWidget* blackoutWidget : std::as_const(mBlackoutWidgets))
452452
{
453453
UBPlatformUtils::showFullScreen(blackoutWidget);
454454
}

0 commit comments

Comments
 (0)