From a9598e83e8bb6f237e5f8b7c29de43cfed13d16b Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 20 Feb 2020 12:56:19 +0100 Subject: [PATCH] Enable all of clazy level1 --- .gitlab-ci.yml | 2 +- autotests/modifyannotationpropertiestest.cpp | 16 ++++++---------- ui/presentationsearchbar.cpp | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea559a594..eea05ebf6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ build_clazy_clang_tidy: script: - srcdir=`pwd` && mkdir -p /tmp/okular_build && cd /tmp/okular_build && CC=clang CXX=clazy CXXFLAGS="-Werror -Wno-deprecated-declarations" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -G Ninja $srcdir && cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json && cat compile_commands.aux.json | jq '[.[] | select(.file | contains("/synctex/")| not)]' > compile_commands.json - - CLAZY_CHECKS="level0,incorrect-emit,qhash-namespace,detaching-temporary,range-loop,qdeleteall,inefficient-qlist-soft,qstring-left,const-signal-or-slot,connect-3arg-lambda,qproperty-without-notify" ninja + - CLAZY_CHECKS="level0,level1" ninja # Fix the poppler header, remove when debian:unstable ships poppler 0.82 or later - sed -i "N;N;N;N; s#class MediaRendition\;\nclass MovieAnnotation\;\nclass ScreenAnnotation;#class MediaRendition\;#g" /usr/include/poppler/qt5/poppler-link.h - "run-clang-tidy -header-filter='.*/okular/.*' -checks='-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-loop-convert,modernize-use-nullptr,-bugprone-macro-parentheses,-bugprone-narrowing-conversions,-bugprone-branch-clone,-bugprone-incorrect-roundings' -config=\"{WarningsAsErrors: '*'}\"" diff --git a/autotests/modifyannotationpropertiestest.cpp b/autotests/modifyannotationpropertiestest.cpp index 548eac5c5..430c8f280 100644 --- a/autotests/modifyannotationpropertiestest.cpp +++ b/autotests/modifyannotationpropertiestest.cpp @@ -17,10 +17,6 @@ #include "core/document.h" #include "testingutils.h" -static const QColor RED = QColor(255, 0, 0); -static const QColor GREEN = QColor(0, 255, 0.0); -// static const QColor BLUE = QColor(0, 0, 255); - class ModifyAnnotationPropertiesTest : public QObject { Q_OBJECT @@ -65,7 +61,7 @@ void ModifyAnnotationPropertiesTest::init() m_annot1->setBoundingRectangle( Okular::NormalizedRect( 0.1, 0.1, 0.15, 0.15 ) ); m_annot1->setContents( QStringLiteral( "Hello, World" ) ); m_annot1->setAuthor( QStringLiteral("Jon Mease") ); - m_annot1->style().setColor( RED ); + m_annot1->style().setColor( Qt::red ); m_annot1->style().setWidth( 4.0 ); m_document->addPageAnnotation( 0, m_annot1 ); } @@ -86,22 +82,22 @@ void ModifyAnnotationPropertiesTest::testModifyAnnotationProperties() // Now modify m_annot1's properties and record properties XML string m_annot1->style().setWidth( 8.0 ); - m_annot1->style().setColor( GREEN ); + m_annot1->style().setColor( Qt::green ); m_document->modifyPageAnnotationProperties( 0, m_annot1 ); QString m_annot1XmlA = TestingUtils::getAnnotationXml( m_annot1 ); QCOMPARE( 8.0, m_annot1->style().width() ); - QCOMPARE( GREEN, m_annot1->style().color() ); + QCOMPARE( QColor(Qt::green), m_annot1->style().color() ); // undo modification and check that original properties have been restored m_document->undo(); QCOMPARE( 4.0, m_annot1->style().width() ); - QCOMPARE( RED, m_annot1->style().color() ); + QCOMPARE( QColor(Qt::red), m_annot1->style().color() ); QCOMPARE( origLine1Xml, TestingUtils::getAnnotationXml( m_annot1 ) ); // redo modification and verify that new properties have been restored m_document->redo(); QCOMPARE( 8.0, m_annot1->style().width() ); - QCOMPARE( GREEN, m_annot1->style().color() ); + QCOMPARE( QColor(Qt::green), m_annot1->style().color() ); QCOMPARE( m_annot1XmlA, TestingUtils::getAnnotationXml( m_annot1 ) ); // Verify that default values are properly restored. (We haven't explicitly set opacity yet) @@ -118,7 +114,7 @@ void ModifyAnnotationPropertiesTest::testModifyAnnotationProperties() // And finally undo back to original properties m_document->undo(); QCOMPARE( 4.0, m_annot1->style().width() ); - QCOMPARE( RED, m_annot1->style().color() ); + QCOMPARE( QColor(Qt::red), m_annot1->style().color() ); QCOMPARE( origLine1Xml, TestingUtils::getAnnotationXml( m_annot1 ) ); } diff --git a/ui/presentationsearchbar.cpp b/ui/presentationsearchbar.cpp index 5c3b288a7..2fbc9e959 100644 --- a/ui/presentationsearchbar.cpp +++ b/ui/presentationsearchbar.cpp @@ -35,7 +35,6 @@ class HandleDrag { setCursor( Qt::SizeAllCursor ); setFixedWidth( style()->pixelMetric( QStyle::PM_ToolBarHandleExtent ) ); - installEventFilter( parent ); } void paintEvent( QPaintEvent * ) override @@ -58,6 +57,7 @@ PresentationSearchBar::PresentationSearchBar( Okular::Document *document, QWidge lay->setContentsMargins( 0, 0, 0, 0 ); m_handle = new HandleDrag( this ); + m_handle->installEventFilter( this ); lay->addWidget( m_handle ); QToolButton * closeBtn = new QToolButton( this );