From: Joel Holdsworth Date: Sat, 2 Jan 2016 15:32:02 +0000 (+0000) Subject: DecodeTrace: Use an stl algorithm to find if all annotations are the same colour X-Git-Tag: pulseview-0.3.0~9 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8c0302f5df5182c0d3531d511416b5c9b1ea8e89;p=pulseview.git DecodeTrace: Use an stl algorithm to find if all annotations are the same colour --- diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index f2aadd1b..30d1667c 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -431,14 +431,10 @@ void DecodeTrace::draw_annotation_block( // Check if all annotations are of the same type (i.e. we can use one color) // or if we should use a neutral color (i.e. gray) - bool single_format = true; - int format = annotations.front().format(); - - for (const Annotation &a : annotations) - if (a.format() != format) { - single_format = false; - break; - } + const int format = annotations.front().format(); + const bool single_format = std::all_of( + annotations.begin(), annotations.end(), + [&](const Annotation &a) { return a.format() == format; }); p.setPen((single_format ? OutlineColours[colour] : Qt::gray)); p.setBrush(QBrush((single_format ? Colours[colour] : Qt::gray),