From c063290ac7189bdd15221450f598504f43286b43 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sun, 19 Mar 2017 00:20:26 +0100 Subject: [PATCH] Random simplifications, cosmetics/whitespace/consistency fixes. --- main.cpp | 5 +++-- pv/binding/decoder.cpp | 5 +---- pv/data/analogsegment.cpp | 21 ++++++++++++--------- pv/data/decode/decoder.hpp | 3 +-- pv/data/decoderstack.cpp | 2 +- pv/data/decoderstack.hpp | 3 +-- pv/data/logic.cpp | 6 ++---- pv/data/logicsegment.cpp | 6 +++--- pv/data/logicsegment.hpp | 2 +- pv/data/segment.cpp | 14 +++++--------- pv/data/signalbase.cpp | 3 +-- pv/dialogs/inputoutputoptions.hpp | 2 +- pv/dialogs/settings.cpp | 17 ++++++----------- pv/dialogs/storeprogress.hpp | 3 +-- pv/mainwindow.cpp | 8 ++++---- pv/popups/channels.cpp | 6 ++---- pv/prop/int.cpp | 3 +-- pv/session.cpp | 2 +- pv/session.hpp | 3 +-- pv/storesession.cpp | 2 +- pv/toolbars/mainbar.cpp | 8 +++----- pv/util.cpp | 25 ++++++------------------- pv/util.hpp | 21 ++++++--------------- pv/view/analogsignal.cpp | 16 +++++++--------- pv/view/decodetrace.cpp | 16 ++++++---------- pv/view/decodetrace.hpp | 3 +-- pv/view/header.cpp | 3 +-- pv/view/logicsignal.cpp | 3 +-- pv/view/logicsignal.hpp | 3 +-- pv/view/ruler.hpp | 1 - pv/view/trace.cpp | 9 ++++----- pv/view/tracetreeitem.cpp | 2 +- pv/view/tracetreeitemowner.hpp | 3 +-- pv/view/view.cpp | 6 ++---- pv/view/view.hpp | 6 ++++-- pv/view/viewport.cpp | 3 +-- pv/views/trace/standardbar.hpp | 2 +- pv/views/viewbase.hpp | 5 +++-- pv/widgets/decodergroupbox.cpp | 3 +-- pv/widgets/decodermenu.cpp | 2 +- pv/widgets/decodermenu.hpp | 1 - pv/widgets/popup.cpp | 4 ++-- pv/widgets/sweeptimingwidget.cpp | 8 ++------ pv/widgets/wellarray.cpp | 2 +- signalhandler.cpp | 3 +-- 45 files changed, 106 insertions(+), 168 deletions(-) diff --git a/main.cpp b/main.cpp index 2119b81e..690a559c 100644 --- a/main.cpp +++ b/main.cpp @@ -136,10 +136,11 @@ int main(int argc, char *argv[]) if (argc - optind > 1) { fprintf(stderr, "Only one file can be opened.\n"); return 1; - } else if (argc - optind == 1) { - open_file = argv[argc - 1]; } + if (argc - optind == 1) + open_file = argv[argc - 1]; + // Initialise libsigrok context = sigrok::Context::create(); #ifdef ANDROID diff --git a/pv/binding/decoder.cpp b/pv/binding/decoder.cpp index c5d01487..b968ab79 100644 --- a/pv/binding/decoder.cpp +++ b/pv/binding/decoder.cpp @@ -128,10 +128,7 @@ Glib::VariantBase Decoder::getter(const char *id) } } - if (val) - return Glib::VariantBase(val, true); - else - return Glib::VariantBase(); + return (val) ? Glib::VariantBase(val, true) : Glib::VariantBase(); } void Decoder::setter(const char *id, Glib::VariantBase value) diff --git a/pv/data/analogsegment.cpp b/pv/data/analogsegment.cpp index 6719340c..45db047e 100644 --- a/pv/data/analogsegment.cpp +++ b/pv/data/analogsegment.cpp @@ -43,8 +43,7 @@ namespace data { const int AnalogSegment::EnvelopeScalePower = 4; const int AnalogSegment::EnvelopeScaleFactor = 1 << EnvelopeScalePower; -const float AnalogSegment::LogEnvelopeScaleFactor = - logf(EnvelopeScaleFactor); +const float AnalogSegment::LogEnvelopeScaleFactor = logf(EnvelopeScaleFactor); const uint64_t AnalogSegment::EnvelopeDataUnit = 64*1024; // bytes AnalogSegment::AnalogSegment(Analog& owner, uint64_t samplerate) : @@ -73,7 +72,7 @@ void AnalogSegment::append_interleaved_samples(const float *data, uint64_t prev_sample_count = sample_count_; - for (uint32_t i=0; i < sample_count; i++) { + for (uint32_t i = 0; i < sample_count; i++) { append_single_sample((void*)data); data += stride; } @@ -174,8 +173,10 @@ void AnalogSegment::append_payload_to_envelope_levels() it = begin_raw_sample_iteration(0); for (uint64_t i = 0; i < sample_count_; i++) { const float sample = *((float*)it->value); - if (sample < min_value_) min_value_ = sample; - if (sample > max_value_) max_value_ = sample; + if (sample < min_value_) + min_value_ = sample; + if (sample > max_value_) + max_value_ = sample; continue_raw_sample_iteration(it, 1); } end_raw_sample_iteration(it); @@ -191,7 +192,7 @@ void AnalogSegment::append_payload_to_envelope_levels() // Iterate through the samples to populate the first level mipmap uint64_t start_sample = prev_length * EnvelopeScaleFactor; - uint64_t end_sample = e0.length * EnvelopeScaleFactor; + uint64_t end_sample = e0.length * EnvelopeScaleFactor; it = begin_raw_sample_iteration(start_sample); for (uint64_t i = start_sample; i < end_sample; i += EnvelopeScaleFactor) { @@ -202,8 +203,10 @@ void AnalogSegment::append_payload_to_envelope_levels() *max_element(samples, samples + EnvelopeScaleFactor), }; - if (sub_sample.min < min_value_) min_value_ = sub_sample.min; - if (sub_sample.max > max_value_) max_value_ = sub_sample.max; + if (sub_sample.min < min_value_) + min_value_ = sub_sample.min; + if (sub_sample.max > max_value_) + max_value_ = sub_sample.max; continue_raw_sample_iteration(it, EnvelopeScaleFactor); *dest_ptr++ = sub_sample; @@ -213,7 +216,7 @@ void AnalogSegment::append_payload_to_envelope_levels() // Compute higher level mipmaps for (unsigned int level = 1; level < ScaleStepCount; level++) { Envelope &e = envelope_levels_[level]; - const Envelope &el = envelope_levels_[level-1]; + const Envelope &el = envelope_levels_[level - 1]; // Expand the data buffer to fit the new samples prev_length = e.length; diff --git a/pv/data/decode/decoder.hpp b/pv/data/decode/decoder.hpp index 1b323f0b..1b655662 100644 --- a/pv/data/decode/decoder.hpp +++ b/pv/data/decode/decoder.hpp @@ -68,8 +68,7 @@ public: bool have_required_channels() const; - srd_decoder_inst* create_decoder_inst( - srd_session *session) const; + srd_decoder_inst* create_decoder_inst(srd_session *session) const; set< shared_ptr > get_data(); diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index d3e1f4ac..8fc32423 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -416,7 +416,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) row_iter = d->rows_.find((*r).second); else { // Failing that, use the decoder as a key - row_iter = d->rows_.find(Row(decc)); + row_iter = d->rows_.find(Row(decc)); } assert(row_iter != d->rows_.end()); diff --git a/pv/data/decoderstack.hpp b/pv/data/decoderstack.hpp index 8a9e0e45..5216006e 100644 --- a/pv/data/decoderstack.hpp +++ b/pv/data/decoderstack.hpp @@ -127,8 +127,7 @@ private: void decode_proc(); - static void annotation_callback(srd_proto_data *pdata, - void *decoder); + static void annotation_callback(srd_proto_data *pdata, void *decoder); private Q_SLOTS: void on_new_frame(); diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index 399c8134..ac47c29d 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -42,8 +42,7 @@ unsigned int Logic::num_channels() const return num_channels_; } -void Logic::push_segment( - shared_ptr &segment) +void Logic::push_segment(shared_ptr &segment) { segments_.push_front(segment); } @@ -55,8 +54,7 @@ const deque< shared_ptr >& Logic::logic_segments() const vector< shared_ptr > Logic::segments() const { - return vector< shared_ptr >( - segments_.begin(), segments_.end()); + return vector< shared_ptr >(segments_.begin(), segments_.end()); } void Logic::clear() diff --git a/pv/data/logicsegment.cpp b/pv/data/logicsegment.cpp index db2ce054..cbaf54a4 100644 --- a/pv/data/logicsegment.cpp +++ b/pv/data/logicsegment.cpp @@ -44,7 +44,7 @@ namespace data { const int LogicSegment::MipMapScalePower = 4; const int LogicSegment::MipMapScaleFactor = 1 << MipMapScalePower; const float LogicSegment::LogMipMapScaleFactor = logf(MipMapScaleFactor); -const uint64_t LogicSegment::MipMapDataUnit = 64*1024; // bytes +const uint64_t LogicSegment::MipMapDataUnit = 64 * 1024; // bytes LogicSegment::LogicSegment(pv::data::Logic& owner, unsigned int unit_size, uint64_t samplerate) : @@ -177,7 +177,7 @@ const uint8_t* LogicSegment::get_samples(int64_t start_sample, lock_guard lock(mutex_); - return get_raw_samples(start_sample, (end_sample-start_sample)); + return get_raw_samples(start_sample, (end_sample - start_sample)); } SegmentLogicDataIterator* LogicSegment::begin_sample_iteration(uint64_t start) @@ -257,7 +257,7 @@ void LogicSegment::append_payload_to_mipmap() // Compute higher level mipmaps for (unsigned int level = 1; level < ScaleStepCount; level++) { MipMapLevel &m = mip_map_[level]; - const MipMapLevel &ml = mip_map_[level-1]; + const MipMapLevel &ml = mip_map_[level - 1]; // Expand the data buffer to fit the new samples prev_length = m.length; diff --git a/pv/data/logicsegment.hpp b/pv/data/logicsegment.hpp index bc9c77d0..3c012a45 100644 --- a/pv/data/logicsegment.hpp +++ b/pv/data/logicsegment.hpp @@ -93,7 +93,7 @@ public: private: uint64_t unpack_sample(const uint8_t *ptr) const; void pack_sample(uint8_t *ptr, uint64_t value); - + void reallocate_mipmap_level(MipMapLevel &m); void append_payload_to_mipmap(); diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index ceaf0a05..88015c36 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -117,8 +117,7 @@ void Segment::append_single_sample(void *data) // There will always be space for at least one sample in // the current chunk, so we do not need to test for space - memcpy(current_chunk_ + (used_samples_ * unit_size_), - data, unit_size_); + memcpy(current_chunk_ + (used_samples_ * unit_size_), data, unit_size_); used_samples_++; unused_samples_--; @@ -222,14 +221,12 @@ void Segment::continue_raw_sample_iteration(SegmentRawDataIterator* it, uint64_t { lock_guard lock(mutex_); + // Fail gracefully if we are asked to deliver data we don't have if (it->sample_index > sample_count_) - { - // Fail gracefully if we are asked to deliver data we don't have return; - } else { - it->sample_index += increase; - it->chunk_offs += (increase * unit_size_); - } + + it->sample_index += increase; + it->chunk_offs += (increase * unit_size_); if (it->chunk_offs > (chunk_size_ - 1)) { it->chunk_num++; @@ -252,6 +249,5 @@ void Segment::end_raw_sample_iteration(SegmentRawDataIterator* it) } } - } // namespace data } // namespace pv diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 949c8237..ff661007 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -37,7 +37,7 @@ using std::tie; namespace pv { namespace data { -const int SignalBase::ColourBGAlpha = 8*256/100; +const int SignalBase::ColourBGAlpha = 8 * 256 / 100; SignalBase::SignalBase(shared_ptr channel, ChannelType channel_type) : channel_(channel), @@ -398,6 +398,5 @@ void SignalBase::on_capture_state_changed(int state) } } - } // namespace data } // namespace pv diff --git a/pv/dialogs/inputoutputoptions.hpp b/pv/dialogs/inputoutputoptions.hpp index 5d5ab55a..be6d3308 100644 --- a/pv/dialogs/inputoutputoptions.hpp +++ b/pv/dialogs/inputoutputoptions.hpp @@ -47,7 +47,7 @@ public: * @param title the title of the dialog. * @param options the map of options to use as a template. * @param parent the parent widget of the dialog. - */ + */ InputOutputOptions(const QString &title, const map> &options, QWidget *parent); diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index b8150b7b..b8f9bf9f 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -57,7 +57,7 @@ Settings::Settings(DeviceManager &device_manager, QWidget *parent) : page_list->setViewMode(QListView::IconMode); page_list->setIconSize(QSize(icon_size, icon_size)); page_list->setMovement(QListView::Static); - page_list->setMaximumWidth(icon_size + icon_size/2); + page_list->setMaximumWidth(icon_size + (icon_size / 2)); page_list->setSpacing(12); pages = new QStackedWidget; @@ -168,15 +168,13 @@ QWidget *Settings::get_about_page(QWidget *parent) const /* Library info */ s.append("" + - tr("Used libraries:") + - ""); + tr("Used libraries:") + ""); s.append(QString("%1%2") .arg(QString("Qt"), qVersion())); /* Set up the supported field */ s.append("" + - tr("Supported hardware drivers:") + - ""); + tr("Supported hardware drivers:") + ""); for (auto entry : context->drivers()) { s.append(QString("%1%2") .arg(QString::fromUtf8(entry.first.c_str()), @@ -184,8 +182,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const } s.append("" + - tr("Supported input formats:") + - ""); + tr("Supported input formats:") + ""); for (auto entry : context->input_formats()) { s.append(QString("%1%2") .arg(QString::fromUtf8(entry.first.c_str()), @@ -193,8 +190,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const } s.append("" + - tr("Supported output formats:") + - ""); + tr("Supported output formats:") + ""); for (auto entry : context->output_formats()) { s.append(QString("%1%2") .arg(QString::fromUtf8(entry.first.c_str()), @@ -203,8 +199,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const #ifdef ENABLE_DECODE s.append("" + - tr("Supported protocol decoders:") + - ""); + tr("Supported protocol decoders:") + ""); for (const GSList *l = srd_decoder_list(); l; l = l->next) { dec = (struct srd_decoder *)l->data; s.append(QString("%1%2") diff --git a/pv/dialogs/storeprogress.hpp b/pv/dialogs/storeprogress.hpp index 48e1239d..b57ad25e 100644 --- a/pv/dialogs/storeprogress.hpp +++ b/pv/dialogs/storeprogress.hpp @@ -47,8 +47,7 @@ public: const shared_ptr output_format, const map &options, const pair sample_range, - const Session &session, - QWidget *parent = nullptr); + const Session &session, QWidget *parent = nullptr); virtual ~StoreProgress(); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index dd8be229..7e48e5a9 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -134,10 +134,10 @@ shared_ptr MainWindow::get_active_view() const QDockWidget *dock = nullptr; while (w) { - dock = qobject_cast(w); - if (dock) - break; - w = w->parent(); + dock = qobject_cast(w); + if (dock) + break; + w = w->parent(); } // Get the view contained in the dock widget diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index 0251a9d1..4a5e396c 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -168,13 +168,11 @@ void Channels::populate_group(shared_ptr group, QString("

%1

").arg(group->name().c_str()))); // Create the channel group grid - QGridLayout *const channel_grid = - create_channel_group_grid(sigs); + QGridLayout *const channel_grid = create_channel_group_grid(sigs); layout_.addRow(channel_grid); // Create the channel group options - if (binding) - { + if (binding) { binding->add_properties_to_form(&layout_, true); group_bindings_.push_back(binding); } diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp index d791bd96..ce77b959 100644 --- a/pv/prop/int.cpp +++ b/pv/prop/int.cpp @@ -140,8 +140,7 @@ void Int::commit() new_value = g_variant_new_int64(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) new_value = g_variant_new_uint64(spin_box_->value()); - else - { + else { // Unexpected value type. assert(false); } diff --git a/pv/session.cpp b/pv/session.cpp index f65b05a1..d00ff97a 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -1035,7 +1035,7 @@ void Session::feed_in_analog(shared_ptr analog) void Session::data_feed_in(shared_ptr device, shared_ptr packet) { - static bool frame_began=false; + static bool frame_began = false; (void)device; diff --git a/pv/session.hpp b/pv/session.hpp index 7229c7e3..faf1396d 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -169,8 +169,7 @@ public: bool has_view(shared_ptr view); - const unordered_set< shared_ptr > - signalbases() const; + const unordered_set< shared_ptr > signalbases() const; #ifdef ENABLE_DECODE bool add_decoder(srd_decoder *const dec); diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 8916cb8c..8b638de8 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -226,7 +226,7 @@ void StoreSession::store_proc(vector< shared_ptr > achannel_li // Qt needs the progress values to fit inside an int. If they would // not, scale the current and max values down until they do. while ((sample_count_ >> progress_scale) > INT_MAX) - progress_scale ++; + progress_scale++; unit_count_ = sample_count_ >> progress_scale; diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index f3bbcee1..838fefca 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -420,8 +420,7 @@ void MainBar::update_sample_count_selector() min_sample_count = min(max(min_sample_count, MinSampleCount), max_sample_count); - sample_count_.show_125_list( - min_sample_count, max_sample_count); + sample_count_.show_125_list(min_sample_count, max_sample_count); if (sr_dev->config_check(ConfigKey::LIMIT_SAMPLES, Capability::GET)) { auto gvar = sr_dev->config_get(ConfigKey::LIMIT_SAMPLES); @@ -581,8 +580,7 @@ void MainBar::add_decoder(srd_decoder *decoder) #endif } -void MainBar::export_file(shared_ptr format, - bool selection_only) +void MainBar::export_file(shared_ptr format, bool selection_only) { using pv::dialogs::StoreProgress; @@ -741,7 +739,7 @@ void MainBar::on_sample_rate_changed() void MainBar::on_config_changed() { commit_sample_count(); - commit_sample_rate(); + commit_sample_rate(); } void MainBar::on_actionNewView_triggered() diff --git a/pv/util.cpp b/pv/util.cpp index c5f9c832..7d711f19 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -110,12 +110,8 @@ static QTextStream& operator<<(QTextStream& stream, const Timestamp& t) return stream << QString::fromStdString(str); } -QString format_time_si( - const Timestamp& v, - SIPrefix prefix, - unsigned int precision, - QString unit, - bool sign) +QString format_time_si(const Timestamp& v, SIPrefix prefix, + unsigned int precision, QString unit, bool sign) { if (prefix == SIPrefix::unspecified) { // No prefix given, calculate it @@ -142,22 +138,14 @@ QString format_time_si( QTextStream ts(&s); if (sign && !v.is_zero()) ts << forcesign; - ts - << qSetRealNumberPrecision(precision) - << (v * multiplier) - << ' ' - << prefix - << unit; + ts << qSetRealNumberPrecision(precision) << (v * multiplier) << ' ' + << prefix << unit; return s; } -QString format_time_si_adjusted( - const Timestamp& t, - SIPrefix prefix, - unsigned precision, - QString unit, - bool sign) +QString format_time_si_adjusted(const Timestamp& t, SIPrefix prefix, + unsigned precision, QString unit, bool sign) { // The precision is always given without taking the prefix into account // so we need to deduct the number of decimals the prefix might imply @@ -170,7 +158,6 @@ QString format_time_si_adjusted( return format_time_si(t, prefix, relative_prec, unit, sign); } - // Helper for 'format_time_minutes()'. static QString pad_number(unsigned int number, int length) { diff --git a/pv/util.hpp b/pv/util.hpp index 1c78b89f..bc71624b 100644 --- a/pv/util.hpp +++ b/pv/util.hpp @@ -74,12 +74,9 @@ typedef boost::multiprecision::number< * * @return The formatted value. */ -QString format_time_si( - const Timestamp& v, - SIPrefix prefix = SIPrefix::unspecified, - unsigned precision = 0, - QString unit = "s", - bool sign = true); +QString format_time_si(const Timestamp& v, + SIPrefix prefix = SIPrefix::unspecified, unsigned precision = 0, + QString unit = "s", bool sign = true); /** * Wrapper around 'format_time_si()' that interprets the given 'precision' @@ -96,12 +93,8 @@ QString format_time_si( * * @return The formatted value. */ -QString format_time_si_adjusted( - const Timestamp& t, - SIPrefix prefix, - unsigned precision = 0, - QString unit = "s", - bool sign = true); +QString format_time_si_adjusted(const Timestamp& t, SIPrefix prefix, + unsigned precision = 0, QString unit = "s", bool sign = true); /** * Formats the given timestamp using "[+-]DD:HH:MM:SS.mmm uuu nnn ppp..." format. @@ -116,9 +109,7 @@ QString format_time_si_adjusted( * * @return The formatted value. */ -QString format_time_minutes( - const Timestamp& t, - signed precision = 0, +QString format_time_minutes(const Timestamp& t, signed precision = 0, bool sign = true); } // namespace util diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 8f79f919..af979c0c 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -68,8 +68,8 @@ const QColor AnalogSignal::SignalColours[4] = { QColor(0x4E, 0x9A, 0x06) // Green }; -const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40*256/100); -const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20*256/100); +const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40 * 256 / 100); +const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20 * 256 / 100); const QColor AnalogSignal::SamplingPointColour(0x77, 0x77, 0x77); @@ -157,16 +157,14 @@ int AnalogSignal::scale_handle_offset() const { const int h = (pos_vdivs_ + neg_vdivs_) * div_height_; - return ((scale_index_drag_offset_ - scale_index_) * - h / 4) - h / 2; + return ((scale_index_drag_offset_ - scale_index_) * h / 4) - h / 2; } void AnalogSignal::scale_handle_dragged(int offset) { const int h = (pos_vdivs_ + neg_vdivs_) * div_height_; - scale_index_ = scale_index_drag_offset_ - - (offset + h / 2) / (h / 4); + scale_index_ = scale_index_drag_offset_ - (offset + h / 2) / (h / 4); update_scale(); } @@ -371,7 +369,7 @@ void AnalogSignal::paint_envelope(QPainter &p, QRectF *const rects = new QRectF[e.length]; QRectF *rect = rects; - for (uint64_t sample = 0; sample < e.length-1; sample++) { + for (uint64_t sample = 0; sample < e.length - 1; sample++) { const float x = ((e.scale * sample + e.start) / samples_per_pixel - pixels_offset) + left; const AnalogSegment::EnvelopeSample *const s = @@ -379,8 +377,8 @@ void AnalogSignal::paint_envelope(QPainter &p, // We overlap this sample with the next so that vertical // gaps do not appear during steep rising or falling edges - const float b = y - max(s->max, (s+1)->min) * scale_; - const float t = y - min(s->min, (s+1)->max) * scale_; + const float b = y - max(s->max, (s + 1)->min) * scale_; + const float t = y - min(s->min, (s + 1)->max) * scale_; float h = b - t; if (h >= 0.0f && h <= 1.0f) diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 670d6ef1..55b5f575 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -52,7 +52,6 @@ extern "C" { #include #include - using std::all_of; using std::list; using std::make_pair; @@ -438,8 +437,7 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, const double start = a.start_sample() / samples_per_pixel - pixels_offset; - const double end = a.end_sample() / samples_per_pixel - - pixels_offset; + const double end = a.end_sample() / samples_per_pixel - pixels_offset; const size_t colour = (base_colour + a.format()) % countof(Colours); p.setPen(OutlineColours[colour]); @@ -451,8 +449,7 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, if (a.start_sample() == a.end_sample()) draw_instant(a, p, h, start, y); else - draw_range(a, p, h, start, end, y, pp, - row_title_width); + draw_range(a, p, h, start, end, y, pp, row_title_width); } void DecodeTrace::draw_annotation_block( @@ -490,7 +487,7 @@ void DecodeTrace::draw_annotation_block( p.setBrush(QBrush((single_format ? Colours[colour] : Qt::gray), Qt::Dense4Pattern)); p.drawRoundedRect( - QRectF(start, top, end - start, bottom - top), h/4, h/4); + QRectF(start, top, end - start, bottom - top), h / 4, h / 4); } void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p, @@ -619,8 +616,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, if (!data || data->logic_segments().empty()) return; - const shared_ptr segment = - data->logic_segments().front(); + const shared_ptr segment = data->logic_segments().front(); assert(segment); const int64_t sample_count = (int64_t)segment->get_sample_count(); if (sample_count == 0) @@ -639,7 +635,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, samples_per_pixel - pixels_offset, left - 1.0); const double end = min(sample_count / samples_per_pixel - pixels_offset, right + 1.0); - const QRectF no_decode_rect(start, y - h/2 + 0.5, end - start, h); + const QRectF no_decode_rect(start, y - (h / 2) + 0.5, end - start, h); p.setPen(QPen(Qt::NoPen)); p.setBrush(Qt::white); @@ -963,7 +959,7 @@ void DecodeTrace::on_delete_decoder(int index) decoder_stack->remove(index); // Update the popup - create_popup_form(); + create_popup_form(); decoder_stack->begin_decode(); } diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp index 3103a3c0..9f575524 100644 --- a/pv/view/decodetrace.hpp +++ b/pv/view/decodetrace.hpp @@ -182,8 +182,7 @@ private: const shared_ptr &dec, const srd_channel *const pdch); - void commit_decoder_channels( - shared_ptr &dec); + void commit_decoder_channels(shared_ptr &dec); void commit_channels(); diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 28f8130d..0e9445ea 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -103,8 +103,7 @@ void Header::paintEvent(QPaintEvent*) // would be clipped away. const QRect rect(0, 0, width() - BaselineOffset, height()); - vector< shared_ptr > items( - view_.list_by_type()); + vector< shared_ptr > items(view_.list_by_type()); stable_sort(items.begin(), items.end(), [](const shared_ptr &a, const shared_ptr &b) { diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 2f4ac22c..9c8f6b31 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -176,8 +176,7 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) if (segments.empty()) return; - const shared_ptr &segment = - segments.front(); + const shared_ptr &segment = segments.front(); double samplerate = segment->samplerate(); diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index 274fd6cd..27312023 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -118,8 +118,7 @@ private: void init_trigger_actions(QWidget *parent); const vector get_trigger_types() const; - QAction* action_from_trigger_type( - const sigrok::TriggerMatchType *type); + QAction* action_from_trigger_type(const sigrok::TriggerMatchType *type); const sigrok::TriggerMatchType* trigger_type_from_action( QAction *action); void populate_popup_form(QWidget *parent, QFormLayout *form); diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index 192de791..1efd8737 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -55,7 +55,6 @@ class Ruler : public MarginWidget friend struct RulerTest::tick_position_test_2; private: - /// Height of the ruler in multipes of the text height static const float RulerHeight; diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 0d4a4536..985c2950 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -42,11 +42,11 @@ namespace pv { namespace views { namespace TraceView { -const QPen Trace::AxisPen(QColor(0, 0, 0, 30*256/100)); +const QPen Trace::AxisPen(QColor(0, 0, 0, 30 * 256 / 100)); const int Trace::LabelHitPadding = 2; -const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10*255/100); -const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100); +const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10 * 255 / 100); +const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15 * 255 / 100); Trace::Trace(shared_ptr channel) : base_(channel), @@ -138,8 +138,7 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent) create_popup_form(); - connect(popup_, SIGNAL(closed()), - this, SLOT(on_popup_closed())); + connect(popup_, SIGNAL(closed()), this, SLOT(on_popup_closed())); return popup_; } diff --git a/pv/view/tracetreeitem.cpp b/pv/view/tracetreeitem.cpp index 1cc3dd6d..97c31dc4 100644 --- a/pv/view/tracetreeitem.cpp +++ b/pv/view/tracetreeitem.cpp @@ -140,7 +140,7 @@ QPoint TraceTreeItem::point(const QRect &rect) const void TraceTreeItem::set_bgcolour_state(bool state) { - bgcolour_state_ = state; + bgcolour_state_ = state; } } // namespace TraceView diff --git a/pv/view/tracetreeitemowner.hpp b/pv/view/tracetreeitemowner.hpp index 92aae37f..58a656d0 100644 --- a/pv/view/tracetreeitemowner.hpp +++ b/pv/view/tracetreeitemowner.hpp @@ -75,8 +75,7 @@ public: /** * Returns a list of row items owned by this object. */ - vector< shared_ptr > - trace_tree_child_items() const; + vector< shared_ptr > trace_tree_child_items() const; /** * Clears the list of child items. diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 9e2aeaa8..dc545bab 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -65,7 +65,6 @@ #include "decodetrace.hpp" #endif - using pv::data::SignalData; using pv::data::Segment; using pv::util::TimeUnit; @@ -444,7 +443,7 @@ void View::zoom(double steps) void View::zoom(double steps, int offset) { - set_zoom(scale_ * pow(3.0/2.0, -steps), offset); + set_zoom(scale_ * pow(3.0 / 2.0, -steps), offset); } void View::zoom_fit(bool gui_state) @@ -533,8 +532,7 @@ pair View::get_time_extents() const boost::optional left_time, right_time; const set< shared_ptr > visible_data = get_visible_data(); for (const shared_ptr d : visible_data) { - const vector< shared_ptr > segments = - d->segments(); + const vector< shared_ptr > segments = d->segments(); for (const shared_ptr &s : segments) { double samplerate = s->samplerate(); samplerate = (samplerate <= 0.0) ? 1.0 : samplerate; diff --git a/pv/view/view.hpp b/pv/view/view.hpp index aebc2540..ee62d113 100644 --- a/pv/view/view.hpp +++ b/pv/view/view.hpp @@ -67,7 +67,8 @@ class Trace; class Viewport; class TriggerMarker; -class CustomAbstractScrollArea : public QAbstractScrollArea { +class CustomAbstractScrollArea : public QAbstractScrollArea +{ Q_OBJECT public: @@ -76,7 +77,8 @@ public: bool viewportEvent(QEvent *event); }; -class View : public ViewBase, public TraceTreeItemOwner { +class View : public ViewBase, public TraceTreeItemOwner +{ Q_OBJECT private: diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index d3f25aa6..4b5fe245 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -59,8 +59,7 @@ shared_ptr Viewport::get_mouse_over_item(const QPoint &pt) const ViewItemPaintParams pp(rect(), view_.scale(), view_.offset()); const vector< shared_ptr > items(this->items()); for (auto i = items.rbegin(); i != items.rend(); i++) - if ((*i)->enabled() && - (*i)->hit_box_rect(pp).contains(pt)) + if ((*i)->enabled() && (*i)->hit_box_rect(pp).contains(pt)) return *i; return nullptr; } diff --git a/pv/views/trace/standardbar.hpp b/pv/views/trace/standardbar.hpp index c00c218d..7a76a639 100644 --- a/pv/views/trace/standardbar.hpp +++ b/pv/views/trace/standardbar.hpp @@ -48,7 +48,7 @@ class StandardBar : public QToolBar public: StandardBar(Session &session, QWidget *parent, - TraceView::View *view, bool add_default_widgets=true); + TraceView::View *view, bool add_default_widgets = true); Session &session() const; diff --git a/pv/views/viewbase.hpp b/pv/views/viewbase.hpp index 95f3ff75..45aae7f1 100644 --- a/pv/views/viewbase.hpp +++ b/pv/views/viewbase.hpp @@ -49,11 +49,12 @@ enum ViewType { ViewTypeTabularDecode }; -class ViewBase : public QWidget { +class ViewBase : public QWidget +{ Q_OBJECT public: - explicit ViewBase(Session &session, bool is_main_view=false, QWidget *parent = nullptr); + explicit ViewBase(Session &session, bool is_main_view = false, QWidget *parent = nullptr); Session& session(); const Session& session() const; diff --git a/pv/widgets/decodergroupbox.cpp b/pv/widgets/decodergroupbox.cpp index 623ebdde..f5b9f253 100644 --- a/pv/widgets/decodergroupbox.cpp +++ b/pv/widgets/decodergroupbox.cpp @@ -37,8 +37,7 @@ DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent, bool isDeletabl layout_->setContentsMargins(0, 0, 0, 0); setLayout(layout_); - layout_->addWidget(new QLabel(QString("

%1

").arg(title)), - 0, 0); + layout_->addWidget(new QLabel(QString("

%1

").arg(title)), 0, 0); layout_->setColumnStretch(0, 1); QHBoxLayout *const toolbar = new QHBoxLayout; diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index e3a95333..994aad1b 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -65,7 +65,7 @@ void DecoderMenu::on_action(QObject *action) (srd_decoder*)((QAction*)action)->data().value(); assert(dec); - decoder_selected(dec); + decoder_selected(dec); } } // widgets diff --git a/pv/widgets/decodermenu.hpp b/pv/widgets/decodermenu.hpp index 3a7dde4b..cec4b574 100644 --- a/pv/widgets/decodermenu.hpp +++ b/pv/widgets/decodermenu.hpp @@ -38,7 +38,6 @@ public: private: static int decoder_name_cmp(const void *a, const void *b); - private Q_SLOTS: void on_action(QObject *action); diff --git a/pv/widgets/popup.cpp b/pv/widgets/popup.cpp index f60e643a..6d211c98 100644 --- a/pv/widgets/popup.cpp +++ b/pv/widgets/popup.cpp @@ -119,7 +119,7 @@ bool Popup::space_for_arrow() const case Bottom: if (point_.y() > y()) return false; - return true; + return true; case Left: if (point_.x() < (x() + width())) @@ -168,7 +168,7 @@ QPolygon Popup::arrow_polygon() const case Left: poly << QPoint(p.x() - l, p.y() + l); break; - + case Top: poly << QPoint(p.x() + l, p.y() - l); break; diff --git a/pv/widgets/sweeptimingwidget.cpp b/pv/widgets/sweeptimingwidget.cpp index 6e24d948..d7686202 100644 --- a/pv/widgets/sweeptimingwidget.cpp +++ b/pv/widgets/sweeptimingwidget.cpp @@ -87,8 +87,7 @@ void SweepTimingWidget::show_list(const uint64_t *vals, size_t count) list_.clear(); for (size_t i = 0; i < count; i++) { char *const s = sr_si_string_u64(vals[i], suffix_); - list_.addItem(QString::fromUtf8(s), - qVariantFromValue(vals[i])); + list_.addItem(QString::fromUtf8(s), qVariantFromValue(vals[i])); g_free(s); } @@ -138,20 +137,17 @@ void SweepTimingWidget::show_125_list(uint64_t min, uint64_t max) uint64_t SweepTimingWidget::value() const { - switch(value_type_) { + switch (value_type_) { case None: return 0; - case MinMaxStep: return (uint64_t)value_.value(); - case List: { const int index = list_.currentIndex(); return (index >= 0) ? list_.itemData( index).value() : 0; } - default: // Unexpected value type assert(false); diff --git a/pv/widgets/wellarray.cpp b/pv/widgets/wellarray.cpp index 3ae6eec6..76175527 100644 --- a/pv/widgets/wellarray.cpp +++ b/pv/widgets/wellarray.cpp @@ -265,7 +265,7 @@ void WellArray::focusOutEvent(QFocusEvent*) */ void WellArray::keyPressEvent(QKeyEvent* event) { - switch(event->key()) { // Look at the key code + switch (event->key()) { // Look at the key code case Qt::Key_Left: // If 'left arrow'-key, if (curCol > 0) // and cr't not in leftmost col setCurrent(curRow, curCol - 1); // set cr't to next left column diff --git a/signalhandler.cpp b/signalhandler.cpp index f262d663..14706261 100644 --- a/signalhandler.cpp +++ b/signalhandler.cpp @@ -71,8 +71,7 @@ void SignalHandler::on_socket_notifier_activated() abort(); } - switch(sig_number) - { + switch (sig_number) { case SIGINT: Q_EMIT int_received(); break; -- 2.30.2