From 8dbbc7f0b9ea59d0f0d62225772f8a56eee125f5 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sat, 22 Nov 2014 08:46:22 +0000 Subject: [PATCH] Make member variable underscores a suffix instead of a prefix This change is made because tokens prefixed with underscore are reserved. --- pv/data/analog.cpp | 8 +- pv/data/analog.h | 2 +- pv/data/analogsnapshot.cpp | 42 +++--- pv/data/analogsnapshot.h | 2 +- pv/data/decode/annotation.cpp | 16 +- pv/data/decode/annotation.h | 8 +- pv/data/decode/decoder.cpp | 32 ++-- pv/data/decode/decoder.h | 8 +- pv/data/decode/row.cpp | 30 ++-- pv/data/decode/row.h | 4 +- pv/data/decode/rowdata.cpp | 8 +- pv/data/decode/rowdata.h | 2 +- pv/data/decoderstack.cpp | 182 +++++++++++------------ pv/data/decoderstack.h | 32 ++-- pv/data/logic.cpp | 14 +- pv/data/logic.h | 4 +- pv/data/logicsnapshot.cpp | 92 ++++++------ pv/data/logicsnapshot.h | 4 +- pv/data/signaldata.cpp | 10 +- pv/data/signaldata.h | 4 +- pv/data/snapshot.cpp | 46 +++--- pv/data/snapshot.h | 10 +- pv/devicemanager.cpp | 32 ++-- pv/devicemanager.h | 6 +- pv/dialogs/connect.cpp | 84 +++++------ pv/dialogs/connect.h | 18 +-- pv/dialogs/storeprogress.cpp | 16 +- pv/dialogs/storeprogress.h | 2 +- pv/mainwindow.cpp | 98 ++++++------ pv/mainwindow.h | 12 +- pv/popups/channels.cpp | 72 ++++----- pv/popups/channels.h | 20 +-- pv/popups/deviceoptions.cpp | 12 +- pv/popups/deviceoptions.h | 6 +- pv/prop/binding/binding.cpp | 6 +- pv/prop/binding/binding.h | 2 +- pv/prop/binding/decoderoptions.cpp | 26 ++-- pv/prop/binding/decoderoptions.h | 4 +- pv/prop/binding/deviceoptions.cpp | 18 +-- pv/prop/binding/deviceoptions.h | 2 +- pv/prop/bool.cpp | 26 ++-- pv/prop/bool.h | 2 +- pv/prop/double.cpp | 44 +++--- pv/prop/double.h | 10 +- pv/prop/enum.cpp | 34 ++--- pv/prop/enum.h | 4 +- pv/prop/int.cpp | 56 +++---- pv/prop/int.h | 8 +- pv/prop/property.cpp | 8 +- pv/prop/property.h | 6 +- pv/prop/string.cpp | 26 ++-- pv/prop/string.h | 2 +- pv/sigsession.cpp | 162 ++++++++++---------- pv/sigsession.h | 26 ++-- pv/storesession.cpp | 64 ++++---- pv/storesession.h | 16 +- pv/toolbars/samplingbar.cpp | 174 +++++++++++----------- pv/toolbars/samplingbar.h | 30 ++-- pv/view/analogsignal.cpp | 38 ++--- pv/view/analogsignal.h | 4 +- pv/view/cursor.cpp | 20 +-- pv/view/cursor.h | 2 +- pv/view/cursorheader.cpp | 48 +++--- pv/view/cursorheader.h | 8 +- pv/view/cursorpair.cpp | 50 +++---- pv/view/cursorpair.h | 6 +- pv/view/decodetrace.cpp | 178 +++++++++++----------- pv/view/decodetrace.h | 24 +-- pv/view/header.cpp | 80 +++++----- pv/view/header.h | 8 +- pv/view/logicsignal.cpp | 142 +++++++++--------- pv/view/logicsignal.h | 22 +-- pv/view/marginwidget.cpp | 2 +- pv/view/marginwidget.h | 2 +- pv/view/rowitem.cpp | 74 +++++----- pv/view/rowitem.h | 8 +- pv/view/rowitemiterator.h | 62 ++++---- pv/view/rowitemowner.cpp | 20 +-- pv/view/rowitemowner.h | 2 +- pv/view/ruler.cpp | 12 +- pv/view/selectableitem.cpp | 20 +-- pv/view/selectableitem.h | 6 +- pv/view/signal.cpp | 44 +++--- pv/view/signal.h | 8 +- pv/view/timemarker.cpp | 46 +++--- pv/view/timemarker.h | 14 +- pv/view/trace.cpp | 60 ++++---- pv/view/trace.h | 8 +- pv/view/tracegroup.cpp | 34 ++--- pv/view/view.cpp | 230 ++++++++++++++--------------- pv/view/view.h | 28 ++-- pv/view/viewport.cpp | 80 +++++----- pv/view/viewport.h | 14 +- pv/widgets/colourbutton.cpp | 36 ++--- pv/widgets/colourbutton.h | 4 +- pv/widgets/colourpopup.cpp | 14 +- pv/widgets/colourpopup.h | 4 +- pv/widgets/decodergroupbox.cpp | 26 ++-- pv/widgets/decodergroupbox.h | 4 +- pv/widgets/decodermenu.cpp | 8 +- pv/widgets/decodermenu.h | 2 +- pv/widgets/popup.cpp | 46 +++--- pv/widgets/popup.h | 4 +- pv/widgets/popuptoolbutton.cpp | 12 +- pv/widgets/popuptoolbutton.h | 2 +- pv/widgets/sweeptimingwidget.cpp | 72 ++++----- pv/widgets/sweeptimingwidget.h | 10 +- signalhandler.cpp | 22 +-- signalhandler.h | 4 +- test/data/analogsnapshot.cpp | 10 +- test/data/decoderstack.cpp | 4 +- test/data/logicsnapshot.cpp | 74 +++++----- 112 files changed, 1728 insertions(+), 1728 deletions(-) diff --git a/pv/data/analog.cpp b/pv/data/analog.cpp index 78fd70e8..eb25629f 100644 --- a/pv/data/analog.cpp +++ b/pv/data/analog.cpp @@ -37,23 +37,23 @@ Analog::Analog() : void Analog::push_snapshot(shared_ptr &snapshot) { - _snapshots.push_front(snapshot); + snapshots_.push_front(snapshot); } deque< shared_ptr >& Analog::get_snapshots() { - return _snapshots; + return snapshots_; } void Analog::clear() { - _snapshots.clear(); + snapshots_.clear(); } uint64_t Analog::get_max_sample_count() const { uint64_t l = 0; - for (const std::shared_ptr s : _snapshots) { + for (const std::shared_ptr s : snapshots_) { assert(s); l = max(l, s->get_sample_count()); } diff --git a/pv/data/analog.h b/pv/data/analog.h index 7e36edd6..b89dd22f 100644 --- a/pv/data/analog.h +++ b/pv/data/analog.h @@ -47,7 +47,7 @@ public: uint64_t get_max_sample_count() const; private: - std::deque< std::shared_ptr > _snapshots; + std::deque< std::shared_ptr > snapshots_; }; } // namespace data diff --git a/pv/data/analogsnapshot.cpp b/pv/data/analogsnapshot.cpp index 2a14d1ea..df3cb42d 100644 --- a/pv/data/analogsnapshot.cpp +++ b/pv/data/analogsnapshot.cpp @@ -50,27 +50,27 @@ AnalogSnapshot::AnalogSnapshot(const uint64_t expected_num_samples) : { set_capacity(expected_num_samples); - lock_guard lock(_mutex); - memset(_envelope_levels, 0, sizeof(_envelope_levels)); + lock_guard lock(mutex_); + memset(envelope_levels_, 0, sizeof(envelope_levels_)); } AnalogSnapshot::~AnalogSnapshot() { - lock_guard lock(_mutex); - for (Envelope &e : _envelope_levels) + lock_guard lock(mutex_); + for (Envelope &e : envelope_levels_) free(e.samples); } void AnalogSnapshot::append_interleaved_samples(const float *data, size_t sample_count, size_t stride) { - assert(_unit_size == sizeof(float)); + assert(unit_size_ == sizeof(float)); - lock_guard lock(_mutex); + lock_guard lock(mutex_); - _data.resize((_sample_count + sample_count) * sizeof(float)); + data_.resize((sample_count_ + sample_count) * sizeof(float)); - float *dst = (float*)_data.data() + _sample_count; + float *dst = (float*)data_.data() + sample_count_; const float *dst_end = dst + sample_count; while (dst != dst_end) { @@ -78,7 +78,7 @@ void AnalogSnapshot::append_interleaved_samples(const float *data, data += stride; } - _sample_count += sample_count; + sample_count_ += sample_count; // Generate the first mip-map from the data append_payload_to_envelope_levels(); @@ -88,15 +88,15 @@ const float* AnalogSnapshot::get_samples( int64_t start_sample, int64_t end_sample) const { assert(start_sample >= 0); - assert(start_sample < (int64_t)_sample_count); + assert(start_sample < (int64_t)sample_count_); assert(end_sample >= 0); - assert(end_sample < (int64_t)_sample_count); + assert(end_sample < (int64_t)sample_count_); assert(start_sample <= end_sample); - lock_guard lock(_mutex); + lock_guard lock(mutex_); float *const data = new float[end_sample - start_sample]; - memcpy(data, (float*)_data.data() + start_sample, sizeof(float) * + memcpy(data, (float*)data_.data() + start_sample, sizeof(float) * (end_sample - start_sample)); return data; } @@ -108,7 +108,7 @@ void AnalogSnapshot::get_envelope_section(EnvelopeSection &s, assert(start <= end); assert(min_length > 0); - lock_guard lock(_mutex); + lock_guard lock(mutex_); const unsigned int min_level = max((int)floorf(logf(min_length) / LogEnvelopeScaleFactor) - 1, 0); @@ -121,7 +121,7 @@ void AnalogSnapshot::get_envelope_section(EnvelopeSection &s, s.scale = 1 << scale_power; s.length = end - start; s.samples = new EnvelopeSample[s.length]; - memcpy(s.samples, _envelope_levels[min_level].samples + start, + memcpy(s.samples, envelope_levels_[min_level].samples + start, s.length * sizeof(EnvelopeSample)); } @@ -139,13 +139,13 @@ void AnalogSnapshot::reallocate_envelope(Envelope &e) void AnalogSnapshot::append_payload_to_envelope_levels() { - Envelope &e0 = _envelope_levels[0]; + Envelope &e0 = envelope_levels_[0]; uint64_t prev_length; EnvelopeSample *dest_ptr; // Expand the data buffer to fit the new samples prev_length = e0.length; - e0.length = _sample_count / EnvelopeScaleFactor; + e0.length = sample_count_ / EnvelopeScaleFactor; // Break off if there are no new samples to compute if (e0.length == prev_length) @@ -156,9 +156,9 @@ void AnalogSnapshot::append_payload_to_envelope_levels() dest_ptr = e0.samples + prev_length; // Iterate through the samples to populate the first level mipmap - const float *const end_src_ptr = (float*)_data.data() + + const float *const end_src_ptr = (float*)data_.data() + e0.length * EnvelopeScaleFactor; - for (const float *src_ptr = (float*)_data.data() + + for (const float *src_ptr = (float*)data_.data() + prev_length * EnvelopeScaleFactor; src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor) { @@ -173,8 +173,8 @@ void AnalogSnapshot::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]; + Envelope &e = envelope_levels_[level]; + 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/analogsnapshot.h b/pv/data/analogsnapshot.h index 9f0711f2..9e2e782a 100644 --- a/pv/data/analogsnapshot.h +++ b/pv/data/analogsnapshot.h @@ -85,7 +85,7 @@ private: void append_payload_to_envelope_levels(); private: - struct Envelope _envelope_levels[ScaleStepCount]; + struct Envelope envelope_levels_[ScaleStepCount]; friend struct AnalogSnapshotTest::Basic; }; diff --git a/pv/data/decode/annotation.cpp b/pv/data/decode/annotation.cpp index 16895851..9b07efbc 100644 --- a/pv/data/decode/annotation.cpp +++ b/pv/data/decode/annotation.cpp @@ -32,41 +32,41 @@ namespace data { namespace decode { Annotation::Annotation(const srd_proto_data *const pdata) : - _start_sample(pdata->start_sample), - _end_sample(pdata->end_sample) + start_sample_(pdata->start_sample), + end_sample_(pdata->end_sample) { assert(pdata); const srd_proto_data_annotation *const pda = (const srd_proto_data_annotation*)pdata->data; assert(pda); - _format = pda->ann_class; + format_ = pda->ann_class; const char *const *annotations = (char**)pda->ann_text; while(*annotations) { - _annotations.push_back(QString::fromUtf8(*annotations)); + annotations_.push_back(QString::fromUtf8(*annotations)); annotations++; } } uint64_t Annotation::start_sample() const { - return _start_sample; + return start_sample_; } uint64_t Annotation::end_sample() const { - return _end_sample; + return end_sample_; } int Annotation::format() const { - return _format; + return format_; } const std::vector& Annotation::annotations() const { - return _annotations; + return annotations_; } } // namespace decode diff --git a/pv/data/decode/annotation.h b/pv/data/decode/annotation.h index 0d7fd5d5..f1e2ef35 100644 --- a/pv/data/decode/annotation.h +++ b/pv/data/decode/annotation.h @@ -42,10 +42,10 @@ public: const std::vector& annotations() const; private: - uint64_t _start_sample; - uint64_t _end_sample; - int _format; - std::vector _annotations; + uint64_t start_sample_; + uint64_t end_sample_; + int format_; + std::vector annotations_; }; } // namespace decode diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 56ebc7e5..e2db7742 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -37,62 +37,62 @@ namespace data { namespace decode { Decoder::Decoder(const srd_decoder *const dec) : - _decoder(dec), - _shown(true) + decoder_(dec), + shown_(true) { } Decoder::~Decoder() { - for (auto i = _options.begin(); i != _options.end(); i++) + for (auto i = options_.begin(); i != options_.end(); i++) g_variant_unref((*i).second); } const srd_decoder* Decoder::decoder() const { - return _decoder; + return decoder_; } bool Decoder::shown() const { - return _shown; + return shown_; } void Decoder::show(bool show) { - _shown = show; + shown_ = show; } const map >& Decoder::channels() const { - return _channels; + return channels_; } void Decoder::set_channels(std::map > channels) { - _channels = channels; + channels_ = channels; } const std::map& Decoder::options() const { - return _options; + return options_; } void Decoder::set_option(const char *id, GVariant *value) { assert(value); g_variant_ref(value); - _options[id] = value; + options_[id] = value; } bool Decoder::have_required_channels() const { - for (GSList *l = _decoder->channels; l; l = l->next) { + for (GSList *l = decoder_->channels; l; l = l->next) { const srd_channel *const pdch = (const srd_channel*)l->data; assert(pdch); - if (_channels.find(pdch) == _channels.end()) + if (channels_.find(pdch) == channels_.end()) return false; } @@ -102,7 +102,7 @@ bool Decoder::have_required_channels() const set< shared_ptr > Decoder::get_data() { set< shared_ptr > data; - for(auto i = _channels.cbegin(); i != _channels.cend(); i++) { + for(auto i = channels_.cbegin(); i != channels_.cend(); i++) { shared_ptr signal((*i).second); assert(signal); data.insert(signal->logic_data()); @@ -116,7 +116,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - for (auto i = _options.cbegin(); i != _options.cend(); i++) + for (auto i = options_.cbegin(); i != options_.cend(); i++) { GVariant *const value = (*i).second; g_variant_ref(value); @@ -125,7 +125,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si } srd_decoder_inst *const decoder_inst = srd_inst_new( - session, _decoder->id, opt_hash); + session, decoder_->id, opt_hash); g_hash_table_destroy(opt_hash); if(!decoder_inst) @@ -135,7 +135,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session, int unit_si GHashTable *const channels = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - for(auto i = _channels.cbegin(); i != _channels.cend(); i++) + for(auto i = channels_.cbegin(); i != channels_.cend(); i++) { shared_ptr signal((*i).second); GVariant *const gvar = g_variant_new_int32( diff --git a/pv/data/decode/decoder.h b/pv/data/decode/decoder.h index 4eeb09e1..fbe59059 100644 --- a/pv/data/decode/decoder.h +++ b/pv/data/decode/decoder.h @@ -73,13 +73,13 @@ public: std::set< std::shared_ptr > get_data(); private: - const srd_decoder *const _decoder; + const srd_decoder *const decoder_; - bool _shown; + bool shown_; std::map > - _channels; - std::map _options; + channels_; + std::map options_; }; } // namespace decode diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index 2aabf0f9..8e3a6512 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -27,44 +27,44 @@ namespace data { namespace decode { Row::Row() : - _decoder(NULL), - _row(NULL) + decoder_(NULL), + row_(NULL) { } Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row) : - _decoder(decoder), - _row(row) + decoder_(decoder), + row_(row) { } const srd_decoder* Row::decoder() const { - return _decoder; + return decoder_; } const srd_decoder_annotation_row* Row::row() const { - return _row; + return row_; } const QString Row::title() const { - if (_decoder && _decoder->name && _row && _row->desc) + if (decoder_ && decoder_->name && row_ && row_->desc) return QString("%1: %2") - .arg(QString::fromUtf8(_decoder->name)) - .arg(QString::fromUtf8(_row->desc)); - if (_decoder && _decoder->name) - return QString::fromUtf8(_decoder->name); - if (_row && _row->desc) - return QString::fromUtf8(_row->desc); + .arg(QString::fromUtf8(decoder_->name)) + .arg(QString::fromUtf8(row_->desc)); + if (decoder_ && decoder_->name) + return QString::fromUtf8(decoder_->name); + if (row_ && row_->desc) + return QString::fromUtf8(row_->desc); return QString(); } bool Row::operator<(const Row &other) const { - return (_decoder < other._decoder) || - (_decoder == other._decoder && _row < other._row); + return (decoder_ < other.decoder_) || + (decoder_ == other.decoder_ && row_ < other.row_); } } // decode diff --git a/pv/data/decode/row.h b/pv/data/decode/row.h index 6c05ac45..221d9c9b 100644 --- a/pv/data/decode/row.h +++ b/pv/data/decode/row.h @@ -48,8 +48,8 @@ public: bool operator<(const Row &other) const; private: - const srd_decoder *_decoder; - const srd_decoder_annotation_row *_row; + const srd_decoder *decoder_; + const srd_decoder_annotation_row *row_; }; } // decode diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp index 299380c8..b4ccd64d 100644 --- a/pv/data/decode/rowdata.cpp +++ b/pv/data/decode/rowdata.cpp @@ -32,16 +32,16 @@ RowData::RowData() uint64_t RowData::get_max_sample() const { - if (_annotations.empty()) + if (annotations_.empty()) return 0; - return _annotations.back().end_sample(); + return annotations_.back().end_sample(); } void RowData::get_annotation_subset( vector &dest, uint64_t start_sample, uint64_t end_sample) const { - for (auto i = _annotations.cbegin(); i != _annotations.cend(); i++) + for (auto i = annotations_.cbegin(); i != annotations_.cend(); i++) if ((*i).end_sample() > start_sample && (*i).start_sample() <= end_sample) dest.push_back(*i); @@ -49,7 +49,7 @@ void RowData::get_annotation_subset( void RowData::push_annotation(const Annotation &a) { - _annotations.push_back(a); + annotations_.push_back(a); } } // decode diff --git a/pv/data/decode/rowdata.h b/pv/data/decode/rowdata.h index 01c65b6e..265c4e37 100644 --- a/pv/data/decode/rowdata.h +++ b/pv/data/decode/rowdata.h @@ -47,7 +47,7 @@ public: void push_annotation(const Annotation &a); private: - std::vector _annotations; + std::vector annotations_; }; } diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 5c26371b..3d734126 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -57,74 +57,74 @@ const double DecoderStack::DecodeThreshold = 0.2; const int64_t DecoderStack::DecodeChunkLength = 4096; const unsigned int DecoderStack::DecodeNotifyPeriod = 65536; -mutex DecoderStack::_global_decode_mutex; +mutex DecoderStack::global_decode_mutex_; DecoderStack::DecoderStack(pv::SigSession &session, const srd_decoder *const dec) : - _session(session), - _sample_count(0), - _frame_complete(false), - _samples_decoded(0) + session_(session), + sample_count_(0), + frame_complete_(false), + samples_decoded_(0) { - connect(&_session, SIGNAL(frame_began()), + connect(&session_, SIGNAL(frame_began()), this, SLOT(on_new_frame())); - connect(&_session, SIGNAL(data_received()), + connect(&session_, SIGNAL(data_received()), this, SLOT(on_data_received())); - connect(&_session, SIGNAL(frame_ended()), + connect(&session_, SIGNAL(frame_ended()), this, SLOT(on_frame_ended())); - _stack.push_back(shared_ptr( + stack_.push_back(shared_ptr( new decode::Decoder(dec))); } DecoderStack::~DecoderStack() { - if (_decode_thread.joinable()) { - _interrupt = true; - _input_cond.notify_one(); - _decode_thread.join(); + if (decode_thread_.joinable()) { + interrupt_ = true; + input_cond_.notify_one(); + decode_thread_.join(); } } const std::list< std::shared_ptr >& DecoderStack::stack() const { - return _stack; + return stack_; } void DecoderStack::push(std::shared_ptr decoder) { assert(decoder); - _stack.push_back(decoder); + stack_.push_back(decoder); } void DecoderStack::remove(int index) { assert(index >= 0); - assert(index < (int)_stack.size()); + assert(index < (int)stack_.size()); // Find the decoder in the stack - auto iter = _stack.begin(); + auto iter = stack_.begin(); for(int i = 0; i < index; i++, iter++) - assert(iter != _stack.end()); + assert(iter != stack_.end()); // Delete the element - _stack.erase(iter); + stack_.erase(iter); } int64_t DecoderStack::samples_decoded() const { - lock_guard decode_lock(_output_mutex); - return _samples_decoded; + lock_guard decode_lock(output_mutex_); + return samples_decoded_; } std::vector DecoderStack::get_visible_rows() const { - lock_guard lock(_output_mutex); + lock_guard lock(output_mutex_); vector rows; - for (const shared_ptr &dec : _stack) + for (const shared_ptr &dec : stack_) { assert(dec); if (!dec->shown()) @@ -155,28 +155,28 @@ void DecoderStack::get_annotation_subset( const Row &row, uint64_t start_sample, uint64_t end_sample) const { - lock_guard lock(_output_mutex); + lock_guard lock(output_mutex_); - const auto iter = _rows.find(row); - if (iter != _rows.end()) + const auto iter = rows_.find(row); + if (iter != rows_.end()) (*iter).second.get_annotation_subset(dest, start_sample, end_sample); } QString DecoderStack::error_message() { - lock_guard lock(_output_mutex); - return _error_message; + lock_guard lock(output_mutex_); + return error_message_; } void DecoderStack::clear() { - _sample_count = 0; - _frame_complete = false; - _samples_decoded = 0; - _error_message = QString(); - _rows.clear(); - _class_rows.clear(); + sample_count_ = 0; + frame_complete_ = false; + samples_decoded_ = 0; + error_message_ = QString(); + rows_.clear(); + class_rows_.clear(); } void DecoderStack::begin_decode() @@ -184,24 +184,24 @@ void DecoderStack::begin_decode() shared_ptr logic_signal; shared_ptr data; - if (_decode_thread.joinable()) { - _interrupt = true; - _input_cond.notify_one(); - _decode_thread.join(); + if (decode_thread_.joinable()) { + interrupt_ = true; + input_cond_.notify_one(); + decode_thread_.join(); } clear(); // Check that all decoders have the required channels - for (const shared_ptr &dec : _stack) + for (const shared_ptr &dec : stack_) if (!dec->have_required_channels()) { - _error_message = tr("One or more required channels " + error_message_ = tr("One or more required channels " "have not been specified"); return; } // Add classes - for (const shared_ptr &dec : _stack) + for (const shared_ptr &dec : stack_) { assert(dec); const srd_decoder *const decc = dec->decoder(); @@ -209,7 +209,7 @@ void DecoderStack::begin_decode() // Add a row for the decoder if it doesn't have a row list if (!decc->annotation_rows) - _rows[Row(decc)] = decode::RowData(); + rows_[Row(decc)] = decode::RowData(); // Add the decoder rows for (const GSList *l = decc->annotation_rows; l; l = l->next) @@ -221,12 +221,12 @@ void DecoderStack::begin_decode() const Row row(decc, ann_row); // Add a new empty row data object - _rows[row] = decode::RowData(); + rows_[row] = decode::RowData(); // Map out all the classes for (const GSList *ll = ann_row->ann_classes; ll; ll = ll->next) - _class_rows[make_pair(decc, + class_rows_[make_pair(decc, GPOINTER_TO_INT(ll->data))] = row; } } @@ -234,7 +234,7 @@ void DecoderStack::begin_decode() // We get the logic data of the first channel in the list. // This works because we are currently assuming all // LogicSignals have the same data/snapshot - for (const shared_ptr &dec : _stack) + for (const shared_ptr &dec : stack_) if (dec && !dec->channels().empty() && ((logic_signal = (*dec->channels().begin()).second)) && ((data = logic_signal->logic_data()))) @@ -248,23 +248,23 @@ void DecoderStack::begin_decode() data->get_snapshots(); if (snapshots.empty()) return; - _snapshot = snapshots.front(); + snapshot_ = snapshots.front(); // Get the samplerate and start time - _start_time = data->get_start_time(); - _samplerate = data->samplerate(); - if (_samplerate == 0.0) - _samplerate = 1.0; + start_time_ = data->get_start_time(); + samplerate_ = data->samplerate(); + if (samplerate_ == 0.0) + samplerate_ = 1.0; - _interrupt = false; - _decode_thread = std::thread(&DecoderStack::decode_proc, this); + interrupt_ = false; + decode_thread_ = std::thread(&DecoderStack::decode_proc, this); } uint64_t DecoderStack::get_max_sample_count() const { uint64_t max_sample_count = 0; - for (auto i = _rows.cbegin(); i != _rows.end(); i++) + for (auto i = rows_.cbegin(); i != rows_.end(); i++) max_sample_count = max(max_sample_count, (*i).second.get_max_sample()); @@ -273,13 +273,13 @@ uint64_t DecoderStack::get_max_sample_count() const optional DecoderStack::wait_for_data() const { - unique_lock input_lock(_input_mutex); - while(!_interrupt && !_frame_complete && - _samples_decoded >= _sample_count) - _input_cond.wait(input_lock); - return boost::make_optional(!_interrupt && - (_samples_decoded < _sample_count || !_frame_complete), - _sample_count); + unique_lock input_lock(input_mutex_); + while(!interrupt_ && !frame_complete_ && + samples_decoded_ >= sample_count_) + input_cond_.wait(input_lock); + return boost::make_optional(!interrupt_ && + (samples_decoded_ < sample_count_ || !frame_complete_), + sample_count_); } void DecoderStack::decode_data( @@ -289,26 +289,26 @@ void DecoderStack::decode_data( uint8_t chunk[DecodeChunkLength]; const unsigned int chunk_sample_count = - DecodeChunkLength / _snapshot->unit_size(); + DecodeChunkLength / snapshot_->unit_size(); - for (int64_t i = 0; !_interrupt && i < sample_count; + for (int64_t i = 0; !interrupt_ && i < sample_count; i += chunk_sample_count) { - lock_guard decode_lock(_global_decode_mutex); + lock_guard decode_lock(global_decode_mutex_); const int64_t chunk_end = min( i + chunk_sample_count, sample_count); - _snapshot->get_samples(chunk, i, chunk_end); + snapshot_->get_samples(chunk, i, chunk_end); if (srd_session_send(session, i, i + sample_count, chunk, (chunk_end - i) * unit_size) != SRD_OK) { - _error_message = tr("Decoder reported an error"); + error_message_ = tr("Decoder reported an error"); break; } { - lock_guard lock(_output_mutex); - _samples_decoded = chunk_end; + lock_guard lock(output_mutex_); + samples_decoded_ = chunk_end; } if (i % DecodeNotifyPeriod == 0) @@ -324,22 +324,22 @@ void DecoderStack::decode_proc() srd_session *session; srd_decoder_inst *prev_di = NULL; - assert(_snapshot); + assert(snapshot_); // Create the session srd_session_new(&session); assert(session); // Create the decoders - const unsigned int unit_size = _snapshot->unit_size(); + const unsigned int unit_size = snapshot_->unit_size(); - for (const shared_ptr &dec : _stack) + for (const shared_ptr &dec : stack_) { srd_decoder_inst *const di = dec->create_decoder_inst(session, unit_size); if (!di) { - _error_message = tr("Failed to create decoder instance"); + error_message_ = tr("Failed to create decoder instance"); srd_session_destroy(session); return; } @@ -352,13 +352,13 @@ void DecoderStack::decode_proc() // Get the intial sample count { - unique_lock input_lock(_input_mutex); - sample_count = _sample_count = _snapshot->get_sample_count(); + unique_lock input_lock(input_mutex_); + sample_count = sample_count_ = snapshot_->get_sample_count(); } // Start the session srd_session_metadata_set(session, SRD_CONF_SAMPLERATE, - g_variant_new_uint64((uint64_t)_samplerate)); + g_variant_new_uint64((uint64_t)samplerate_)); srd_pd_output_callback_add(session, SRD_OUTPUT_ANN, DecoderStack::annotation_callback, this); @@ -367,7 +367,7 @@ void DecoderStack::decode_proc() do { decode_data(*sample_count, unit_size, session); - } while(_error_message.isEmpty() && (sample_count = wait_for_data())); + } while(error_message_.isEmpty() && (sample_count = wait_for_data())); // Destroy the session srd_session_destroy(session); @@ -381,7 +381,7 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) DecoderStack *const d = (DecoderStack*)decoder; assert(d); - lock_guard lock(d->_output_mutex); + lock_guard lock(d->output_mutex_); const Annotation a(pdata); @@ -391,20 +391,20 @@ void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) const srd_decoder *const decc = pdata->pdo->di->decoder; assert(decc); - auto row_iter = d->_rows.end(); + auto row_iter = d->rows_.end(); // Try looking up the sub-row of this class - const auto r = d->_class_rows.find(make_pair(decc, a.format())); - if (r != d->_class_rows.end()) - row_iter = d->_rows.find((*r).second); + const auto r = d->class_rows_.find(make_pair(decc, a.format())); + if (r != d->class_rows_.end()) + 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()); - if (row_iter == d->_rows.end()) { + assert(row_iter != d->rows_.end()); + if (row_iter == d->rows_.end()) { qDebug() << "Unexpected annotation: decoder = " << decc << ", format = " << a.format(); assert(0); @@ -423,21 +423,21 @@ void DecoderStack::on_new_frame() void DecoderStack::on_data_received() { { - unique_lock lock(_input_mutex); - if (_snapshot) - _sample_count = _snapshot->get_sample_count(); + unique_lock lock(input_mutex_); + if (snapshot_) + sample_count_ = snapshot_->get_sample_count(); } - _input_cond.notify_one(); + input_cond_.notify_one(); } void DecoderStack::on_frame_ended() { { - unique_lock lock(_input_mutex); - if (_snapshot) - _frame_complete = true; + unique_lock lock(input_mutex_); + if (snapshot_) + frame_complete_ = true; } - _input_cond.notify_one(); + input_cond_.notify_one(); } } // namespace data diff --git a/pv/data/decoderstack.h b/pv/data/decoderstack.h index 35f76874..c50f3859 100644 --- a/pv/data/decoderstack.h +++ b/pv/data/decoderstack.h @@ -78,7 +78,7 @@ private: static const unsigned int DecodeNotifyPeriod; public: - DecoderStack(pv::SigSession &_session, + DecoderStack(pv::SigSession &session_, const srd_decoder *const decoder); virtual ~DecoderStack(); @@ -129,7 +129,7 @@ Q_SIGNALS: void new_decode_data(); private: - pv::SigSession &_session; + pv::SigSession &session_; /** * This mutex prevents more than one decode operation occuring @@ -137,28 +137,28 @@ private: * @todo A proper solution should be implemented to allow multiple * decode operations. */ - static std::mutex _global_decode_mutex; + static std::mutex global_decode_mutex_; - std::list< std::shared_ptr > _stack; + std::list< std::shared_ptr > stack_; - std::shared_ptr _snapshot; + std::shared_ptr snapshot_; - mutable std::mutex _input_mutex; - mutable std::condition_variable _input_cond; - int64_t _sample_count; - bool _frame_complete; + mutable std::mutex input_mutex_; + mutable std::condition_variable input_cond_; + int64_t sample_count_; + bool frame_complete_; - mutable std::mutex _output_mutex; - int64_t _samples_decoded; + mutable std::mutex output_mutex_; + int64_t samples_decoded_; - std::map _rows; + std::map rows_; - std::map, decode::Row> _class_rows; + std::map, decode::Row> class_rows_; - QString _error_message; + QString error_message_; - std::thread _decode_thread; - std::atomic _interrupt; + std::thread decode_thread_; + std::atomic interrupt_; friend struct DecoderStackTest::TwoDecoderStack; }; diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index e23283ac..b7b6cace 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -32,36 +32,36 @@ namespace data { Logic::Logic(unsigned int num_channels) : SignalData(), - _num_channels(num_channels) + num_channels_(num_channels) { - assert(_num_channels > 0); + assert(num_channels_ > 0); } int Logic::get_num_channels() const { - return _num_channels; + return num_channels_; } void Logic::push_snapshot( shared_ptr &snapshot) { - _snapshots.push_front(snapshot); + snapshots_.push_front(snapshot); } deque< shared_ptr >& Logic::get_snapshots() { - return _snapshots; + return snapshots_; } void Logic::clear() { - _snapshots.clear(); + snapshots_.clear(); } uint64_t Logic::get_max_sample_count() const { uint64_t l = 0; - for (std::shared_ptr s : _snapshots) { + for (std::shared_ptr s : snapshots_) { assert(s); l = max(l, s->get_sample_count()); } diff --git a/pv/data/logic.h b/pv/data/logic.h index 3756ed9a..d8ee5305 100644 --- a/pv/data/logic.h +++ b/pv/data/logic.h @@ -49,8 +49,8 @@ public: uint64_t get_max_sample_count() const; private: - const unsigned int _num_channels; - std::deque< std::shared_ptr > _snapshots; + const unsigned int num_channels_; + std::deque< std::shared_ptr > snapshots_; }; } // namespace data diff --git a/pv/data/logicsnapshot.cpp b/pv/data/logicsnapshot.cpp index a00a22ed..31093c27 100644 --- a/pv/data/logicsnapshot.cpp +++ b/pv/data/logicsnapshot.cpp @@ -50,19 +50,19 @@ const uint64_t LogicSnapshot::MipMapDataUnit = 64*1024; // bytes LogicSnapshot::LogicSnapshot(shared_ptr logic, const uint64_t expected_num_samples) : Snapshot(logic->unit_size()), - _last_append_sample(0) + last_append_sample_(0) { set_capacity(expected_num_samples); - lock_guard lock(_mutex); - memset(_mip_map, 0, sizeof(_mip_map)); + lock_guard lock(mutex_); + memset(mip_map_, 0, sizeof(mip_map_)); append_payload(logic); } LogicSnapshot::~LogicSnapshot() { - lock_guard lock(_mutex); - for (MipMapLevel &l : _mip_map) + lock_guard lock(mutex_); + for (MipMapLevel &l : mip_map_) free(l.data); } @@ -72,7 +72,7 @@ uint64_t LogicSnapshot::unpack_sample(const uint8_t *ptr) const return *(uint64_t*)ptr; #else uint64_t value = 0; - switch(_unit_size) { + switch(unit_size_) { default: value |= ((uint64_t)ptr[7]) << 56; /* FALLTHRU */ @@ -109,7 +109,7 @@ void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value) #ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS *(uint64_t*)ptr = value; #else - switch(_unit_size) { + switch(unit_size_) { default: ptr[7] = value >> 56; /* FALLTHRU */ @@ -142,13 +142,13 @@ void LogicSnapshot::pack_sample(uint8_t *ptr, uint64_t value) void LogicSnapshot::append_payload(shared_ptr logic) { - assert(_unit_size == logic->unit_size()); - assert((logic->data_length() % _unit_size) == 0); + assert(unit_size_ == logic->unit_size()); + assert((logic->data_length() % unit_size_) == 0); - lock_guard lock(_mutex); + lock_guard lock(mutex_); append_data(logic->data_pointer(), - logic->data_length() / _unit_size); + logic->data_length() / unit_size_); // Generate the first mip-map from the data append_payload_to_mipmap(); @@ -159,15 +159,15 @@ void LogicSnapshot::get_samples(uint8_t *const data, { assert(data); assert(start_sample >= 0); - assert(start_sample <= (int64_t)_sample_count); + assert(start_sample <= (int64_t)sample_count_); assert(end_sample >= 0); - assert(end_sample <= (int64_t)_sample_count); + assert(end_sample <= (int64_t)sample_count_); assert(start_sample <= end_sample); - lock_guard lock(_mutex); + lock_guard lock(mutex_); - const size_t size = (end_sample - start_sample) * _unit_size; - memcpy(data, (const uint8_t*)_data.data() + start_sample * _unit_size, size); + const size_t size = (end_sample - start_sample) * unit_size_; + memcpy(data, (const uint8_t*)data_.data() + start_sample * unit_size_, size); } void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m) @@ -179,14 +179,14 @@ void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m) m.data_length = new_data_length; // Padding is added to allow for the uint64_t write word - m.data = realloc(m.data, new_data_length * _unit_size + + m.data = realloc(m.data, new_data_length * unit_size_ + sizeof(uint64_t)); } } void LogicSnapshot::append_payload_to_mipmap() { - MipMapLevel &m0 = _mip_map[0]; + MipMapLevel &m0 = mip_map_[0]; uint64_t prev_length; const uint8_t *src_ptr; uint8_t *dest_ptr; @@ -195,7 +195,7 @@ void LogicSnapshot::append_payload_to_mipmap() // Expand the data buffer to fit the new samples prev_length = m0.length; - m0.length = _sample_count / MipMapScaleFactor; + m0.length = sample_count_ / MipMapScaleFactor; // Break off if there are no new samples to compute if (m0.length == prev_length) @@ -203,13 +203,13 @@ void LogicSnapshot::append_payload_to_mipmap() reallocate_mipmap_level(m0); - dest_ptr = (uint8_t*)m0.data + prev_length * _unit_size; + dest_ptr = (uint8_t*)m0.data + prev_length * unit_size_; // Iterate through the samples to populate the first level mipmap - const uint8_t *const end_src_ptr = (uint8_t*)_data.data() + - m0.length * _unit_size * MipMapScaleFactor; - for (src_ptr = (uint8_t*)_data.data() + - prev_length * _unit_size * MipMapScaleFactor; + const uint8_t *const end_src_ptr = (uint8_t*)data_.data() + + m0.length * unit_size_ * MipMapScaleFactor; + for (src_ptr = (uint8_t*)data_.data() + + prev_length * unit_size_ * MipMapScaleFactor; src_ptr < end_src_ptr;) { // Accumulate transitions which have occurred in this sample @@ -218,20 +218,20 @@ void LogicSnapshot::append_payload_to_mipmap() while (diff_counter-- > 0) { const uint64_t sample = unpack_sample(src_ptr); - accumulator |= _last_append_sample ^ sample; - _last_append_sample = sample; - src_ptr += _unit_size; + accumulator |= last_append_sample_ ^ sample; + last_append_sample_ = sample; + src_ptr += unit_size_; } pack_sample(dest_ptr, accumulator); - dest_ptr += _unit_size; + dest_ptr += unit_size_; } // Compute higher level mipmaps for (unsigned int level = 1; level < ScaleStepCount; level++) { - MipMapLevel &m = _mip_map[level]; - const MipMapLevel &ml = _mip_map[level-1]; + MipMapLevel &m = mip_map_[level]; + const MipMapLevel &ml = mip_map_[level-1]; // Expand the data buffer to fit the new samples prev_length = m.length; @@ -245,20 +245,20 @@ void LogicSnapshot::append_payload_to_mipmap() // Subsample the level lower level src_ptr = (uint8_t*)ml.data + - _unit_size * prev_length * MipMapScaleFactor; + unit_size_ * prev_length * MipMapScaleFactor; const uint8_t *const end_dest_ptr = - (uint8_t*)m.data + _unit_size * m.length; + (uint8_t*)m.data + unit_size_ * m.length; for (dest_ptr = (uint8_t*)m.data + - _unit_size * prev_length; + unit_size_ * prev_length; dest_ptr < end_dest_ptr; - dest_ptr += _unit_size) + dest_ptr += unit_size_) { accumulator = 0; diff_counter = MipMapScaleFactor; while (diff_counter-- > 0) { accumulator |= unpack_sample(src_ptr); - src_ptr += _unit_size; + src_ptr += unit_size_; } pack_sample(dest_ptr, accumulator); @@ -268,9 +268,9 @@ void LogicSnapshot::append_payload_to_mipmap() uint64_t LogicSnapshot::get_sample(uint64_t index) const { - assert(index < _sample_count); + assert(index < sample_count_); - return unpack_sample((uint8_t*)_data.data() + index * _unit_size); + return unpack_sample((uint8_t*)data_.data() + index * unit_size_); } void LogicSnapshot::get_subsampled_edges( @@ -289,7 +289,7 @@ void LogicSnapshot::get_subsampled_edges( assert(sig_index >= 0); assert(sig_index < 64); - lock_guard lock(_mutex); + lock_guard lock(mutex_); const uint64_t block_length = (uint64_t)max(min_length, 1.0f); const unsigned int min_level = max((int)floorf(logf(min_length) / @@ -307,7 +307,7 @@ void LogicSnapshot::get_subsampled_edges( // We cannot fast-forward if there is no mip-map data at // at the minimum level. - fast_forward = (_mip_map[level].data != NULL); + fast_forward = (mip_map_[level].data != NULL); if (min_length < MipMapScaleFactor) { @@ -365,7 +365,7 @@ void LogicSnapshot::get_subsampled_edges( // Check if we reached the last block at this // level, or if there was a change in this block - if (offset >= _mip_map[level].length || + if (offset >= mip_map_[level].length || (get_subsample(level, offset) & sig_mask)) break; @@ -375,7 +375,7 @@ void LogicSnapshot::get_subsampled_edges( // higher level mip-map block ascend one // level if (level + 1 >= ScaleStepCount || - !_mip_map[level + 1].data) + !mip_map_[level + 1].data) break; level++; @@ -390,7 +390,7 @@ void LogicSnapshot::get_subsampled_edges( // Zoom in, and slide right until we encounter a change, // and repeat until we reach min_level while (1) { - assert(_mip_map[level].data); + assert(mip_map_[level].data); const int level_scale_power = (level + 1) * MipMapScalePower; @@ -399,7 +399,7 @@ void LogicSnapshot::get_subsampled_edges( // Check if we reached the last block at this // level, or if there was a change in this block - if (offset >= _mip_map[level].length || + if (offset >= mip_map_[level].length || (get_subsample(level, offset) & sig_mask)) { // Zoom in unless we reached the minimum @@ -455,9 +455,9 @@ void LogicSnapshot::get_subsampled_edges( uint64_t LogicSnapshot::get_subsample(int level, uint64_t offset) const { assert(level >= 0); - assert(_mip_map[level].data); - return unpack_sample((uint8_t*)_mip_map[level].data + - _unit_size * offset); + assert(mip_map_[level].data); + return unpack_sample((uint8_t*)mip_map_[level].data + + unit_size_ * offset); } uint64_t LogicSnapshot::pow2_ceil(uint64_t x, unsigned int power) diff --git a/pv/data/logicsnapshot.h b/pv/data/logicsnapshot.h index a215f928..db4d97b3 100644 --- a/pv/data/logicsnapshot.h +++ b/pv/data/logicsnapshot.h @@ -103,8 +103,8 @@ private: static uint64_t pow2_ceil(uint64_t x, unsigned int power); private: - struct MipMapLevel _mip_map[ScaleStepCount]; - uint64_t _last_append_sample; + struct MipMapLevel mip_map_[ScaleStepCount]; + uint64_t last_append_sample_; friend struct LogicSnapshotTest::Pow2; friend struct LogicSnapshotTest::Basic; diff --git a/pv/data/signaldata.cpp b/pv/data/signaldata.cpp index 04f1d3f5..456edf14 100644 --- a/pv/data/signaldata.cpp +++ b/pv/data/signaldata.cpp @@ -24,25 +24,25 @@ namespace pv { namespace data { SignalData::SignalData() : - _start_time(0), - _samplerate(0) + start_time_(0), + samplerate_(0) { } double SignalData::samplerate() const { - return _samplerate; + return samplerate_; } void SignalData::set_samplerate(double samplerate) { - _samplerate = samplerate; + samplerate_ = samplerate; clear(); } double SignalData::get_start_time() const { - return _start_time; + return start_time_; } } // namespace data diff --git a/pv/data/signaldata.h b/pv/data/signaldata.h index 280874c4..885f8435 100644 --- a/pv/data/signaldata.h +++ b/pv/data/signaldata.h @@ -43,8 +43,8 @@ public: virtual uint64_t get_max_sample_count() const = 0; protected: - double _start_time; - double _samplerate; + double start_time_; + double samplerate_; }; } // namespace data diff --git a/pv/data/snapshot.cpp b/pv/data/snapshot.cpp index c02475b7..80b9fb37 100644 --- a/pv/data/snapshot.cpp +++ b/pv/data/snapshot.cpp @@ -31,62 +31,62 @@ namespace pv { namespace data { Snapshot::Snapshot(unsigned int unit_size) : - _sample_count(0), - _capacity(0), - _unit_size(unit_size) + sample_count_(0), + capacity_(0), + unit_size_(unit_size) { - lock_guard lock(_mutex); - assert(_unit_size > 0); + lock_guard lock(mutex_); + assert(unit_size_ > 0); } Snapshot::~Snapshot() { - lock_guard lock(_mutex); + lock_guard lock(mutex_); } uint64_t Snapshot::get_sample_count() const { - lock_guard lock(_mutex); - return _sample_count; + lock_guard lock(mutex_); + return sample_count_; } unsigned int Snapshot::unit_size() const { - return _unit_size; + return unit_size_; } void Snapshot::set_capacity(const uint64_t new_capacity) { - lock_guard lock(_mutex); + lock_guard lock(mutex_); - assert(_capacity >= _sample_count); - if (new_capacity > _capacity) { - _capacity = new_capacity; - _data.resize((new_capacity * _unit_size) + sizeof(uint64_t)); + assert(capacity_ >= sample_count_); + if (new_capacity > capacity_) { + capacity_ = new_capacity; + data_.resize((new_capacity * unit_size_) + sizeof(uint64_t)); } } uint64_t Snapshot::capacity() const { - lock_guard lock(_mutex); - return _data.size(); + lock_guard lock(mutex_); + return data_.size(); } void Snapshot::append_data(void *data, uint64_t samples) { - lock_guard lock(_mutex); + lock_guard lock(mutex_); - assert(_capacity >= _sample_count); + assert(capacity_ >= sample_count_); // Ensure there's enough capacity to copy. - const uint64_t free_space = _capacity - _sample_count; + const uint64_t free_space = capacity_ - sample_count_; if (free_space < samples) { - set_capacity(_sample_count + samples); + set_capacity(sample_count_ + samples); } - memcpy((uint8_t*)_data.data() + _sample_count * _unit_size, - data, samples * _unit_size); - _sample_count += samples; + memcpy((uint8_t*)data_.data() + sample_count_ * unit_size_, + data, samples * unit_size_); + sample_count_ += samples; } } // namespace data diff --git a/pv/data/snapshot.h b/pv/data/snapshot.h index 48879991..29d0eed4 100644 --- a/pv/data/snapshot.h +++ b/pv/data/snapshot.h @@ -70,11 +70,11 @@ protected: void append_data(void *data, uint64_t samples); protected: - mutable std::recursive_mutex _mutex; - std::vector _data; - uint64_t _sample_count; - uint64_t _capacity; - unsigned int _unit_size; + mutable std::recursive_mutex mutex_; + std::vector data_; + uint64_t sample_count_; + uint64_t capacity_; + unsigned int unit_size_; }; } // namespace data diff --git a/pv/devicemanager.cpp b/pv/devicemanager.cpp index ee6a0123..2f446c45 100644 --- a/pv/devicemanager.cpp +++ b/pv/devicemanager.cpp @@ -53,7 +53,7 @@ using sigrok::SessionDevice; namespace pv { DeviceManager::DeviceManager(shared_ptr context) : - _context(context) + context_(context) { for (auto entry : context->drivers()) driver_scan(entry.second, map()); @@ -65,12 +65,12 @@ DeviceManager::~DeviceManager() shared_ptr DeviceManager::context() { - return _context; + return context_; } const list< shared_ptr >& DeviceManager::devices() const { - return _devices; + return devices_; } list< shared_ptr > DeviceManager::driver_scan( @@ -82,7 +82,7 @@ list< shared_ptr > DeviceManager::driver_scan( // Remove any device instances from this driver from the device // list. They will not be valid after the scan. - _devices.remove_if([&](shared_ptr device) { + devices_.remove_if([&](shared_ptr device) { return device->driver() == driver; }); // Do the scan @@ -90,21 +90,21 @@ list< shared_ptr > DeviceManager::driver_scan( driver_devices.insert(driver_devices.end(), devices.begin(), devices.end()); // Add the scanned devices to the main list, set display names and sort. - _devices.insert(_devices.end(), driver_devices.begin(), + devices_.insert(devices_.end(), driver_devices.begin(), driver_devices.end()); - for (shared_ptr device : _devices) - _display_names[device] = build_display_name(device); + for (shared_ptr device : devices_) + display_names_[device] = build_display_name(device); - _devices.sort([&](shared_ptr a, shared_ptr b) + devices_.sort([&](shared_ptr a, shared_ptr b) { return compare_devices(a, b); }); - // As the display names depend on the complete _devices list, + // As the display names depend on the complete devices_ list, // we need to recompute them. However, there is no need to - // recomute all names of the _devices list since only the + // recomute all names of the devices_ list since only the // devices that use the given driver can be affected. for (shared_ptr device : driver_devices) - _display_names[device] = build_display_name(device); + display_names_[device] = build_display_name(device); driver_devices.sort([&](shared_ptr a, shared_ptr b) { return compare_devices(a, b); }); @@ -141,7 +141,7 @@ const shared_ptr DeviceManager::find_device_from_info( last_resort_dev = NULL; - for (shared_ptr dev : _devices) { + for (shared_ptr dev : devices_) { assert(dev); dev_info = get_device_info(dev); @@ -200,7 +200,7 @@ const string DeviceManager::build_display_name(shared_ptr device) // If we can find another device with the same model/vendor then // we have at least two such devices and need to distinguish them. if (hardware_device) - multiple_dev = any_of(_devices.begin(), _devices.end(), + multiple_dev = any_of(devices_.begin(), devices_.end(), [&](shared_ptr dev) { return (dev->vendor() == hardware_device->vendor() && dev->model() == hardware_device->model()) && @@ -233,12 +233,12 @@ const string DeviceManager::build_display_name(shared_ptr device) const std::string DeviceManager::get_display_name(std::shared_ptr dev) { - return _display_names[dev]; + return display_names_[dev]; } void DeviceManager::update_display_name(std::shared_ptr dev) { - _display_names[dev] = build_display_name(dev); + display_names_[dev] = build_display_name(dev); } bool DeviceManager::compare_devices(shared_ptr a, @@ -247,7 +247,7 @@ bool DeviceManager::compare_devices(shared_ptr a, assert(a); assert(b); - return _display_names[a].compare(_display_names[b]) < 0; + return display_names_[a].compare(display_names_[b]) < 0; } } // namespace pv diff --git a/pv/devicemanager.h b/pv/devicemanager.h index 511ba760..823cb2bc 100644 --- a/pv/devicemanager.h +++ b/pv/devicemanager.h @@ -75,9 +75,9 @@ private: std::shared_ptr b); protected: - std::shared_ptr _context; - std::list< std::shared_ptr > _devices; - std::map< std::shared_ptr, std::string > _display_names; + std::shared_ptr context_; + std::list< std::shared_ptr > devices_; + std::map< std::shared_ptr, std::string > display_names_; }; } // namespace pv diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index e4a22bd3..5535f46d 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -45,46 +45,46 @@ namespace dialogs { Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) : QDialog(parent), - _device_manager(device_manager), - _layout(this), - _form(this), - _form_layout(&_form), - _drivers(&_form), - _serial_device(&_form), - _scan_button(tr("Scan for Devices"), this), - _device_list(this), - _button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, + device_manager_(device_manager), + layout_(this), + form_(this), + form_layout_(&form_), + drivers_(&form_), + serial_device_(&form_), + scan_button_(tr("Scan for Devices"), this), + device_list_(this), + button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this) { setWindowTitle(tr("Connect to Device")); - connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept())); - connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject())); + connect(&button_box_, SIGNAL(accepted()), this, SLOT(accept())); + connect(&button_box_, SIGNAL(rejected()), this, SLOT(reject())); populate_drivers(); - connect(&_drivers, SIGNAL(activated(int)), + connect(&drivers_, SIGNAL(activated(int)), this, SLOT(device_selected(int))); - _form.setLayout(&_form_layout); - _form_layout.addRow(tr("Driver"), &_drivers); + form_.setLayout(&form_layout_); + form_layout_.addRow(tr("Driver"), &drivers_); - _form_layout.addRow(tr("Serial Port"), &_serial_device); + form_layout_.addRow(tr("Serial Port"), &serial_device_); unset_connection(); - connect(&_scan_button, SIGNAL(pressed()), + connect(&scan_button_, SIGNAL(pressed()), this, SLOT(scan_pressed())); - setLayout(&_layout); - _layout.addWidget(&_form); - _layout.addWidget(&_scan_button); - _layout.addWidget(&_device_list); - _layout.addWidget(&_button_box); + setLayout(&layout_); + layout_.addWidget(&form_); + layout_.addWidget(&scan_button_); + layout_.addWidget(&device_list_); + layout_.addWidget(&button_box_); } shared_ptr Connect::get_selected_device() const { - const QListWidgetItem *const item = _device_list.currentItem(); + const QListWidgetItem *const item = device_list_.currentItem(); if (!item) return shared_ptr(); @@ -93,7 +93,7 @@ shared_ptr Connect::get_selected_device() const void Connect::populate_drivers() { - for (auto entry : _device_manager.context()->drivers()) { + for (auto entry : device_manager_.context()->drivers()) { auto name = entry.first; auto driver = entry.second; /** @@ -107,7 +107,7 @@ void Connect::populate_drivers() ConfigKey::SAMPLERATE, ConfigKey::DEVICE_OPTIONS); if (supported_device) - _drivers.addItem(QString("%1 (%2)").arg( + drivers_.addItem(QString("%1 (%2)").arg( driver->long_name().c_str()).arg(name.c_str()), qVariantFromValue(driver)); } @@ -115,62 +115,62 @@ void Connect::populate_drivers() void Connect::unset_connection() { - _device_list.clear(); - _serial_device.hide(); - _form_layout.labelForField(&_serial_device)->hide(); - _button_box.button(QDialogButtonBox::Ok)->setDisabled(true); + device_list_.clear(); + serial_device_.hide(); + form_layout_.labelForField(&serial_device_)->hide(); + button_box_.button(QDialogButtonBox::Ok)->setDisabled(true); } void Connect::set_serial_connection() { - _serial_device.show(); - _form_layout.labelForField(&_serial_device)->show(); + serial_device_.show(); + form_layout_.labelForField(&serial_device_)->show(); } void Connect::scan_pressed() { - _device_list.clear(); + device_list_.clear(); - const int index = _drivers.currentIndex(); + const int index = drivers_.currentIndex(); if (index == -1) return; shared_ptr driver = - _drivers.itemData(index).value>(); + drivers_.itemData(index).value>(); assert(driver); map drvopts; - if (_serial_device.isVisible()) + if (serial_device_.isVisible()) drvopts[ConfigKey::CONN] = Variant::create( - _serial_device.text().toUtf8().constData()); + serial_device_.text().toUtf8().constData()); list< shared_ptr > devices = - _device_manager.driver_scan(driver, drvopts); + device_manager_.driver_scan(driver, drvopts); for (shared_ptr device : devices) { assert(device); QString text = QString::fromStdString( - _device_manager.get_display_name(device)); + device_manager_.get_display_name(device)); text += QString(" with %1 channels").arg(device->channels().size()); QListWidgetItem *const item = new QListWidgetItem(text, - &_device_list); + &device_list_); item->setData(Qt::UserRole, qVariantFromValue(device)); - _device_list.addItem(item); + device_list_.addItem(item); } - _device_list.setCurrentRow(0); - _button_box.button(QDialogButtonBox::Ok)->setDisabled(_device_list.count() == 0); + device_list_.setCurrentRow(0); + button_box_.button(QDialogButtonBox::Ok)->setDisabled(device_list_.count() == 0); } void Connect::device_selected(int index) { shared_ptr driver = - _drivers.itemData(index).value>(); + drivers_.itemData(index).value>(); unset_connection(); diff --git a/pv/dialogs/connect.h b/pv/dialogs/connect.h index fbac9e3e..b46da06f 100644 --- a/pv/dialogs/connect.h +++ b/pv/dialogs/connect.h @@ -68,21 +68,21 @@ private Q_SLOTS: void scan_pressed(); private: - pv::DeviceManager &_device_manager; + pv::DeviceManager &device_manager_; - QVBoxLayout _layout; + QVBoxLayout layout_; - QWidget _form; - QFormLayout _form_layout; + QWidget form_; + QFormLayout form_layout_; - QComboBox _drivers; + QComboBox drivers_; - QLineEdit _serial_device; + QLineEdit serial_device_; - QPushButton _scan_button; - QListWidget _device_list; + QPushButton scan_button_; + QListWidget device_list_; - QDialogButtonBox _button_box; + QDialogButtonBox button_box_; }; } // namespace dialogs diff --git a/pv/dialogs/storeprogress.cpp b/pv/dialogs/storeprogress.cpp index 5c2d8bc1..6c264096 100644 --- a/pv/dialogs/storeprogress.cpp +++ b/pv/dialogs/storeprogress.cpp @@ -30,20 +30,20 @@ namespace dialogs { StoreProgress::StoreProgress(const QString &file_name, const SigSession &session, QWidget *parent) : QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent), - _session(file_name.toStdString(), session) + session_(file_name.toStdString(), session) { - connect(&_session, SIGNAL(progress_updated()), + connect(&session_, SIGNAL(progress_updated()), this, SLOT(on_progress_updated())); } StoreProgress::~StoreProgress() { - _session.wait(); + session_.wait(); } void StoreProgress::run() { - if (_session.start()) + if (session_.start()) show(); else show_error(); @@ -53,7 +53,7 @@ void StoreProgress::show_error() { QMessageBox msg(parentWidget()); msg.setText(tr("Failed to save session.")); - msg.setInformativeText(_session.error()); + msg.setInformativeText(session_.error()); msg.setStandardButtons(QMessageBox::Ok); msg.setIcon(QMessageBox::Warning); msg.exec(); @@ -61,19 +61,19 @@ void StoreProgress::show_error() void StoreProgress::closeEvent(QCloseEvent*) { - _session.cancel(); + session_.cancel(); } void StoreProgress::on_progress_updated() { - const std::pair p = _session.progress(); + const std::pair p = session_.progress(); assert(p.first <= p.second); if (p.second) { setValue(p.first); setMaximum(p.second); } else { - const QString err = _session.error(); + const QString err = session_.error(); if (!err.isEmpty()) show_error(); close(); diff --git a/pv/dialogs/storeprogress.h b/pv/dialogs/storeprogress.h index eaf235f3..497099e9 100644 --- a/pv/dialogs/storeprogress.h +++ b/pv/dialogs/storeprogress.h @@ -55,7 +55,7 @@ private Q_SLOTS: void on_progress_updated(); private: - pv::StoreSession _session; + pv::StoreSession session_; }; } // dialogs diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 170d14e7..d1418b59 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -82,8 +82,8 @@ MainWindow::MainWindow(DeviceManager &device_manager, const char *open_file_name, QWidget *parent) : QMainWindow(parent), - _device_manager(device_manager), - _session(device_manager) + device_manager_(device_manager), + session_(device_manager) { setup_ui(); restore_ui_settings(); @@ -106,15 +106,15 @@ void MainWindow::setup_ui() setWindowIcon(icon); // Setup the central widget - _central_widget = new QWidget(this); - _vertical_layout = new QVBoxLayout(_central_widget); - _vertical_layout->setSpacing(6); - _vertical_layout->setContentsMargins(0, 0, 0, 0); - setCentralWidget(_central_widget); + central_widget_ = new QWidget(this); + vertical_layout_ = new QVBoxLayout(central_widget_); + vertical_layout_->setSpacing(6); + vertical_layout_->setContentsMargins(0, 0, 0, 0); + setCentralWidget(central_widget_); - _view = new pv::view::View(_session, this); + view_ = new pv::view::View(session_, this); - _vertical_layout->addWidget(_view); + vertical_layout_->addWidget(view_); // Setup the menu bar QMenuBar *const menu_bar = new QMenuBar(this); @@ -202,7 +202,7 @@ void MainWindow::setup_ui() QAction *action_view_show_cursors = new QAction(this); action_view_show_cursors->setCheckable(true); - action_view_show_cursors->setChecked(_view->cursors_shown()); + action_view_show_cursors->setChecked(view_->cursors_shown()); action_view_show_cursors->setShortcut(QKeySequence(Qt::Key_C)); action_view_show_cursors->setObjectName( QString::fromUtf8("actionViewShowCursors")); @@ -255,20 +255,20 @@ void MainWindow::setup_ui() addToolBar(toolbar); // Setup the sampling bar - _sampling_bar = new toolbars::SamplingBar(_session, this); + sampling_bar_ = new toolbars::SamplingBar(session_, this); // Populate the device list and select the initially selected device update_device_list(); - connect(_sampling_bar, SIGNAL(run_stop()), this, + connect(sampling_bar_, SIGNAL(run_stop()), this, SLOT(run_stop())); - addToolBar(_sampling_bar); + addToolBar(sampling_bar_); // Set the title setWindowTitle(tr("PulseView")); - // Setup _session events - connect(&_session, SIGNAL(capture_state_changed(int)), this, + // Setup session_ events + connect(&session_, SIGNAL(capture_state_changed(int)), this, SLOT(capture_state_changed(int))); } @@ -284,7 +284,7 @@ void MainWindow::save_ui_settings() settings.setValue("geometry", saveGeometry()); settings.endGroup(); - if (_session.device()) { + if (session_.device()) { settings.beginGroup("Device"); key_list.push_back("vendor"); key_list.push_back("model"); @@ -292,8 +292,8 @@ void MainWindow::save_ui_settings() key_list.push_back("serial_num"); key_list.push_back("connection_id"); - dev_info = _device_manager.get_device_info( - _session.device()); + dev_info = device_manager_.get_device_info( + session_.device()); for (string key : key_list) { @@ -346,10 +346,10 @@ void MainWindow::restore_ui_settings() dev_info.insert(std::make_pair(key, value)); } - device = _device_manager.find_device_from_info(dev_info); + device = device_manager_.find_device_from_info(dev_info); if (device) { - _session.set_device(device); + session_.set_device(device); update_device_list(); } @@ -366,16 +366,16 @@ void MainWindow::session_error( void MainWindow::update_device_list() { - assert(_sampling_bar); + assert(sampling_bar_); - shared_ptr selected_device = _session.device(); + shared_ptr selected_device = session_.device(); list< shared_ptr > devices; - if (_device_manager.devices().size() == 0) + if (device_manager_.devices().size() == 0) return; - std::copy(_device_manager.devices().begin(), - _device_manager.devices().end(), std::back_inserter(devices)); + std::copy(device_manager_.devices().begin(), + device_manager_.devices().end(), std::back_inserter(devices)); if (std::find(devices.begin(), devices.end(), selected_device) == devices.end()) @@ -386,9 +386,9 @@ void MainWindow::update_device_list() for (auto device : devices) device_list.push_back(make_pair( - device, _device_manager.get_display_name(device))); + device, device_manager_.get_display_name(device))); - _sampling_bar->set_device_list(device_list, selected_device); + sampling_bar_->set_device_list(device_list, selected_device); } void MainWindow::closeEvent(QCloseEvent *event) @@ -404,17 +404,17 @@ void MainWindow::load_file(QString file_name) const QString infoMessage; try { - _session.set_file(file_name.toStdString()); + session_.set_file(file_name.toStdString()); } catch(Error e) { show_session_error(tr("Failed to load ") + file_name, e.what()); - _session.set_default_device(); + session_.set_default_device(); update_device_list(); return; } update_device_list(); - _session.start_capture([&, errorMessage, infoMessage](QString) { + session_.start_capture([&, errorMessage, infoMessage](QString) { session_error(errorMessage, infoMessage); }); } @@ -453,7 +453,7 @@ void MainWindow::on_actionSaveAs_triggered() using pv::dialogs::StoreProgress; // Stop any currently running capture session - _session.stop_capture(); + session_.stop_capture(); QSettings settings; const QString dir = settings.value(SettingSaveDirectory).toString(); @@ -468,21 +468,21 @@ void MainWindow::on_actionSaveAs_triggered() const QString abs_path = QFileInfo(file_name).absolutePath(); settings.setValue(SettingSaveDirectory, abs_path); - StoreProgress *dlg = new StoreProgress(file_name, _session, this); + StoreProgress *dlg = new StoreProgress(file_name, session_, this); dlg->run(); } void MainWindow::on_actionConnect_triggered() { // Stop any currently running capture session - _session.stop_capture(); + session_.stop_capture(); - dialogs::Connect dlg(this, _device_manager); + dialogs::Connect dlg(this, device_manager_); // If the user selected a device, select it in the device list. Select the // current device otherwise. if (dlg.exec()) - _session.set_device(dlg.get_selected_device()); + session_.set_device(dlg.get_selected_device()); update_device_list(); } @@ -494,38 +494,38 @@ void MainWindow::on_actionQuit_triggered() void MainWindow::on_actionViewZoomIn_triggered() { - _view->zoom(1); + view_->zoom(1); } void MainWindow::on_actionViewZoomOut_triggered() { - _view->zoom(-1); + view_->zoom(-1); } void MainWindow::on_actionViewZoomFit_triggered() { - _view->zoom_fit(); + view_->zoom_fit(); } void MainWindow::on_actionViewZoomOneToOne_triggered() { - _view->zoom_one_to_one(); + view_->zoom_one_to_one(); } void MainWindow::on_actionViewShowCursors_triggered() { - assert(_view); + assert(view_); - const bool show = !_view->cursors_shown(); + const bool show = !view_->cursors_shown(); if(show) - _view->centre_cursors(); + view_->centre_cursors(); - _view->show_cursors(show); + view_->show_cursors(show); } void MainWindow::on_actionAbout_triggered() { - dialogs::About dlg(_device_manager.context(), this); + dialogs::About dlg(device_manager_.context(), this); dlg.exec(); } @@ -533,7 +533,7 @@ void MainWindow::add_decoder(srd_decoder *decoder) { #ifdef ENABLE_DECODE assert(decoder); - _session.add_decoder(decoder); + session_.add_decoder(decoder); #else (void)decoder; #endif @@ -541,22 +541,22 @@ void MainWindow::add_decoder(srd_decoder *decoder) void MainWindow::run_stop() { - switch(_session.get_capture_state()) { + switch(session_.get_capture_state()) { case SigSession::Stopped: - _session.start_capture([&](QString message) { + session_.start_capture([&](QString message) { session_error("Capture failed", message); }); break; case SigSession::AwaitingTrigger: case SigSession::Running: - _session.stop_capture(); + session_.stop_capture(); break; } } void MainWindow::capture_state_changed(int state) { - _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); + sampling_bar_->set_capture_state((pv::SigSession::capture_state)state); } } // namespace pv diff --git a/pv/mainwindow.h b/pv/mainwindow.h index b9fc3e0e..94a6c42e 100644 --- a/pv/mainwindow.h +++ b/pv/mainwindow.h @@ -117,16 +117,16 @@ private: */ static const char *SettingSaveDirectory; - DeviceManager &_device_manager; + DeviceManager &device_manager_; - SigSession _session; + SigSession session_; - pv::view::View *_view; + pv::view::View *view_; - QWidget *_central_widget; - QVBoxLayout *_vertical_layout; + QWidget *central_widget_; + QVBoxLayout *vertical_layout_; - toolbars::SamplingBar *_sampling_bar; + toolbars::SamplingBar *sampling_bar_; }; } // namespace pv diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index ee0daedf..beacfb43 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -55,23 +55,23 @@ namespace popups { Channels::Channels(SigSession &session, QWidget *parent) : Popup(parent), - _session(session), - _updating_channels(false), - _enable_all_channels(tr("Enable All"), this), - _disable_all_channels(tr("Disable All"), this), - _check_box_mapper(this) + session_(session), + updating_channels_(false), + enable_all_channels_(tr("Enable All"), this), + disable_all_channels_(tr("Disable All"), this), + check_box_mapper_(this) { // Create the layout - setLayout(&_layout); + setLayout(&layout_); - shared_ptr device = _session.device(); + shared_ptr device = session_.device(); assert(device); // Collect a set of signals map, shared_ptr > signal_map; - shared_lock lock(_session.signals_mutex()); - const vector< shared_ptr > &sigs(_session.signals()); + shared_lock lock(session_.signals_mutex()); + const vector< shared_ptr > &sigs(session_.signals()); for (const shared_ptr &sig : sigs) signal_map[sig->channel()] = sig; @@ -111,32 +111,32 @@ Channels::Channels(SigSession &session, QWidget *parent) : populate_group(NULL, global_sigs); // Create the enable/disable all buttons - connect(&_enable_all_channels, SIGNAL(clicked()), + connect(&enable_all_channels_, SIGNAL(clicked()), this, SLOT(enable_all_channels())); - connect(&_disable_all_channels, SIGNAL(clicked()), + connect(&disable_all_channels_, SIGNAL(clicked()), this, SLOT(disable_all_channels())); - _enable_all_channels.setFlat(true); - _disable_all_channels.setFlat(true); + enable_all_channels_.setFlat(true); + disable_all_channels_.setFlat(true); - _buttons_bar.addWidget(&_enable_all_channels); - _buttons_bar.addWidget(&_disable_all_channels); - _buttons_bar.addStretch(1); + buttons_bar_.addWidget(&enable_all_channels_); + buttons_bar_.addWidget(&disable_all_channels_); + buttons_bar_.addStretch(1); - _layout.addRow(&_buttons_bar); + layout_.addRow(&buttons_bar_); // Connect the check-box signal mapper - connect(&_check_box_mapper, SIGNAL(mapped(QWidget*)), + connect(&check_box_mapper_, SIGNAL(mapped(QWidget*)), this, SLOT(on_channel_checked(QWidget*))); } void Channels::set_all_channels(bool set) { - _updating_channels = true; + updating_channels_ = true; for (map >::const_iterator i = - _check_box_signal_map.begin(); - i != _check_box_signal_map.end(); i++) + check_box_signal_map_.begin(); + i != check_box_signal_map_.end(); i++) { const shared_ptr sig = (*i).second; assert(sig); @@ -145,7 +145,7 @@ void Channels::set_all_channels(bool set) (*i).first->setChecked(set); } - _updating_channels = false; + updating_channels_ = false; } void Channels::populate_group(shared_ptr group, @@ -163,19 +163,19 @@ void Channels::populate_group(shared_ptr group, // Create a title if the group is going to have any content if ((!sigs.empty() || (binding && !binding->properties().empty())) && group) - _layout.addRow(new QLabel( + layout_.addRow(new QLabel( QString("

%1

").arg(group->name().c_str()))); // Create the channel group grid QGridLayout *const channel_grid = create_channel_group_grid(sigs); - _layout.addRow(channel_grid); + layout_.addRow(channel_grid); // Create the channel group options if (binding) { - binding->add_properties_to_form(&_layout, true); - _group_bindings.push_back(binding); + binding->add_properties_to_form(&layout_, true); + group_bindings_.push_back(binding); } } @@ -190,13 +190,13 @@ QGridLayout* Channels::create_channel_group_grid( assert(sig); QCheckBox *const checkbox = new QCheckBox(sig->name()); - _check_box_mapper.setMapping(checkbox, checkbox); + check_box_mapper_.setMapping(checkbox, checkbox); connect(checkbox, SIGNAL(toggled(bool)), - &_check_box_mapper, SLOT(map())); + &check_box_mapper_, SLOT(map())); grid->addWidget(checkbox, row, col); - _check_box_signal_map[checkbox] = sig; + check_box_signal_map_[checkbox] = sig; if(++col >= 8) col = 0, row++; @@ -209,11 +209,11 @@ void Channels::showEvent(QShowEvent *e) { pv::widgets::Popup::showEvent(e); - _updating_channels = true; + updating_channels_ = true; for (map >::const_iterator i = - _check_box_signal_map.begin(); - i != _check_box_signal_map.end(); i++) + check_box_signal_map_.begin(); + i != check_box_signal_map_.end(); i++) { const shared_ptr sig = (*i).second; assert(sig); @@ -221,12 +221,12 @@ void Channels::showEvent(QShowEvent *e) (*i).first->setChecked(sig->enabled()); } - _updating_channels = false; + updating_channels_ = false; } void Channels::on_channel_checked(QWidget *widget) { - if (_updating_channels) + if (updating_channels_) return; QCheckBox *const check_box = (QCheckBox*)widget; @@ -234,8 +234,8 @@ void Channels::on_channel_checked(QWidget *widget) // Look up the signal of this check-box map< QCheckBox*, shared_ptr >::const_iterator iter = - _check_box_signal_map.find((QCheckBox*)check_box); - assert(iter != _check_box_signal_map.end()); + check_box_signal_map_.find((QCheckBox*)check_box); + assert(iter != check_box_signal_map_.end()); const shared_ptr s = (*iter).second; assert(s); diff --git a/pv/popups/channels.h b/pv/popups/channels.h index 97475a57..667db937 100644 --- a/pv/popups/channels.h +++ b/pv/popups/channels.h @@ -60,7 +60,7 @@ class Channels : public pv::widgets::Popup Q_OBJECT public: - Channels(SigSession &_session, QWidget *parent); + Channels(SigSession &session_, QWidget *parent); private: void set_all_channels(bool set); @@ -81,22 +81,22 @@ private Q_SLOTS: void disable_all_channels(); private: - pv::SigSession &_session; + pv::SigSession &session_; - QFormLayout _layout; + QFormLayout layout_; - bool _updating_channels; + bool updating_channels_; std::vector< std::shared_ptr > - _group_bindings; + group_bindings_; std::map< QCheckBox*, std::shared_ptr > - _check_box_signal_map; + check_box_signal_map_; - QHBoxLayout _buttons_bar; - QPushButton _enable_all_channels; - QPushButton _disable_all_channels; + QHBoxLayout buttons_bar_; + QPushButton enable_all_channels_; + QPushButton disable_all_channels_; - QSignalMapper _check_box_mapper; + QSignalMapper check_box_mapper_; }; } // popups diff --git a/pv/popups/deviceoptions.cpp b/pv/popups/deviceoptions.cpp index 3d069f79..bdc0ab23 100644 --- a/pv/popups/deviceoptions.cpp +++ b/pv/popups/deviceoptions.cpp @@ -36,18 +36,18 @@ namespace popups { DeviceOptions::DeviceOptions(shared_ptr device, QWidget *parent) : Popup(parent), - _device(device), - _layout(this), - _binding(device) + device_(device), + layout_(this), + binding_(device) { - setLayout(&_layout); + setLayout(&layout_); - _layout.addWidget(_binding.get_property_form(this, true)); + layout_.addWidget(binding_.get_property_form(this, true)); } pv::prop::binding::DeviceOptions& DeviceOptions::binding() { - return _binding; + return binding_; } } // namespace popups diff --git a/pv/popups/deviceoptions.h b/pv/popups/deviceoptions.h index 6d260a4d..5fb60fc7 100644 --- a/pv/popups/deviceoptions.h +++ b/pv/popups/deviceoptions.h @@ -45,11 +45,11 @@ public: pv::prop::binding::DeviceOptions& binding(); private: - std::shared_ptr _device; + std::shared_ptr device_; - QVBoxLayout _layout; + QVBoxLayout layout_; - pv::prop::binding::DeviceOptions _binding; + pv::prop::binding::DeviceOptions binding_; }; } // namespace popups diff --git a/pv/prop/binding/binding.cpp b/pv/prop/binding/binding.cpp index 86318139..0bc9854c 100644 --- a/pv/prop/binding/binding.cpp +++ b/pv/prop/binding/binding.cpp @@ -34,12 +34,12 @@ namespace binding { const std::vector< std::shared_ptr >& Binding::properties() { - return _properties; + return properties_; } void Binding::commit() { - for (shared_ptr p : _properties) { + for (shared_ptr p : properties_) { assert(p); p->commit(); } @@ -50,7 +50,7 @@ void Binding::add_properties_to_form(QFormLayout *layout, { assert(layout); - for (shared_ptr p : _properties) + for (shared_ptr p : properties_) { assert(p); diff --git a/pv/prop/binding/binding.h b/pv/prop/binding/binding.h index 9d52731d..7d216e2d 100644 --- a/pv/prop/binding/binding.h +++ b/pv/prop/binding/binding.h @@ -54,7 +54,7 @@ public: static QString print_gvariant(Glib::VariantBase gvar); protected: - std::vector< std::shared_ptr > _properties; + std::vector< std::shared_ptr > properties_; }; } // binding diff --git a/pv/prop/binding/decoderoptions.cpp b/pv/prop/binding/decoderoptions.cpp index a01d722f..a46f0df1 100644 --- a/pv/prop/binding/decoderoptions.cpp +++ b/pv/prop/binding/decoderoptions.cpp @@ -46,12 +46,12 @@ namespace binding { DecoderOptions::DecoderOptions( shared_ptr decoder_stack, shared_ptr decoder) : - _decoder_stack(decoder_stack), - _decoder(decoder) + decoder_stack_(decoder_stack), + decoder_(decoder) { - assert(_decoder); + assert(decoder_); - const srd_decoder *const dec = _decoder->decoder(); + const srd_decoder *const dec = decoder_->decoder(); assert(dec); for (GSList *l = dec->options; l; l = l->next) @@ -82,7 +82,7 @@ DecoderOptions::DecoderOptions( else continue; - _properties.push_back(prop); + properties_.push_back(prop); } } @@ -103,20 +103,20 @@ Glib::VariantBase DecoderOptions::getter(const char *id) { GVariant *val = NULL; - assert(_decoder); + assert(decoder_); // Get the value from the hash table if it is already present - const map& options = _decoder->options(); + const map& options = decoder_->options(); const auto iter = options.find(id); if (iter != options.end()) val = (*iter).second; else { - assert(_decoder->decoder()); + assert(decoder_->decoder()); // Get the default value if not - for (GSList *l = _decoder->decoder()->options; l; l = l->next) + for (GSList *l = decoder_->decoder()->options; l; l = l->next) { const srd_decoder_option *const opt = (srd_decoder_option*)l->data; @@ -135,11 +135,11 @@ Glib::VariantBase DecoderOptions::getter(const char *id) void DecoderOptions::setter(const char *id, Glib::VariantBase value) { - assert(_decoder); - _decoder->set_option(id, value.gobj()); + assert(decoder_); + decoder_->set_option(id, value.gobj()); - assert(_decoder_stack); - _decoder_stack->begin_decode(); + assert(decoder_stack_); + decoder_stack_->begin_decode(); } } // binding diff --git a/pv/prop/binding/decoderoptions.h b/pv/prop/binding/decoderoptions.h index a95bc33f..7f14d0fd 100644 --- a/pv/prop/binding/decoderoptions.h +++ b/pv/prop/binding/decoderoptions.h @@ -55,8 +55,8 @@ private: void setter(const char *id, Glib::VariantBase value); private: - std::shared_ptr _decoder_stack; - std::shared_ptr _decoder; + std::shared_ptr decoder_stack_; + std::shared_ptr decoder_; }; } // binding diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index 0023eb2e..e112bb12 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -49,7 +49,7 @@ namespace prop { namespace binding { DeviceOptions::DeviceOptions(shared_ptr configurable) : - _configurable(configurable) + configurable_(configurable) { assert(configurable); @@ -76,9 +76,9 @@ DeviceOptions::DeviceOptions(shared_ptr configurable) : const QString name = QString::fromStdString(name_str); const Property::Getter get = [&, key]() { - return _configurable->config_get(key); }; + return configurable_->config_get(key); }; const Property::Setter set = [&, key](Glib::VariantBase value) { - _configurable->config_set(key, value); + configurable_->config_set(key, value); config_changed(); }; @@ -130,8 +130,8 @@ DeviceOptions::DeviceOptions(shared_ptr configurable) : void DeviceOptions::bind_bool(const QString &name, Property::Getter getter, Property::Setter setter) { - assert(_configurable); - _properties.push_back(shared_ptr(new Bool( + assert(configurable_); + properties_.push_back(shared_ptr(new Bool( name, getter, setter))); } @@ -142,13 +142,13 @@ void DeviceOptions::bind_enum(const QString &name, Glib::VariantBase gvar; vector< pair > values; - assert(_configurable); + assert(configurable_); Glib::VariantIter iter(gvar_list); while ((iter.next_value(gvar))) values.push_back(make_pair(gvar, printer(gvar))); - _properties.push_back(shared_ptr(new Enum(name, values, + properties_.push_back(shared_ptr(new Enum(name, values, getter, setter))); } @@ -156,9 +156,9 @@ void DeviceOptions::bind_int(const QString &name, QString suffix, optional< std::pair > range, Property::Getter getter, Property::Setter setter) { - assert(_configurable); + assert(configurable_); - _properties.push_back(shared_ptr(new Int(name, suffix, range, + properties_.push_back(shared_ptr(new Int(name, suffix, range, getter, setter))); } diff --git a/pv/prop/binding/deviceoptions.h b/pv/prop/binding/deviceoptions.h index a7fffa30..0ca55e0e 100644 --- a/pv/prop/binding/deviceoptions.h +++ b/pv/prop/binding/deviceoptions.h @@ -64,7 +64,7 @@ private: static QString print_voltage_threshold(Glib::VariantBase gvar); protected: - std::shared_ptr _configurable; + std::shared_ptr configurable_; }; } // binding diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index 699656f7..c057d61e 100644 --- a/pv/prop/bool.cpp +++ b/pv/prop/bool.cpp @@ -29,7 +29,7 @@ namespace prop { Bool::Bool(QString name, Getter getter, Setter setter) : Property(name, getter, setter), - _check_box(NULL) + check_box_(NULL) { } @@ -39,27 +39,27 @@ Bool::~Bool() QWidget* Bool::get_widget(QWidget *parent, bool auto_commit) { - if (_check_box) - return _check_box; + if (check_box_) + return check_box_; - if (!_getter) + if (!getter_) return NULL; - Glib::VariantBase variant = _getter(); + Glib::VariantBase variant = getter_(); if (!variant.gobj()) return NULL; bool value = Glib::VariantBase::cast_dynamic>( variant).get(); - _check_box = new QCheckBox(name(), parent); - _check_box->setCheckState(value ? Qt::Checked : Qt::Unchecked); + check_box_ = new QCheckBox(name(), parent); + check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked); if (auto_commit) - connect(_check_box, SIGNAL(stateChanged(int)), + connect(check_box_, SIGNAL(stateChanged(int)), this, SLOT(on_state_changed(int))); - return _check_box; + return check_box_; } bool Bool::labeled_widget() const @@ -69,13 +69,13 @@ bool Bool::labeled_widget() const void Bool::commit() { - assert(_setter); + assert(setter_); - if (!_check_box) + if (!check_box_) return; - _setter(Glib::Variant::create( - _check_box->checkState() == Qt::Checked)); + setter_(Glib::Variant::create( + check_box_->checkState() == Qt::Checked)); } void Bool::on_state_changed(int) diff --git a/pv/prop/bool.h b/pv/prop/bool.h index c96c87af..d7f8877b 100644 --- a/pv/prop/bool.h +++ b/pv/prop/bool.h @@ -46,7 +46,7 @@ private Q_SLOTS: void on_state_changed(int); private: - QCheckBox *_check_box; + QCheckBox *check_box_; }; } // prop diff --git a/pv/prop/double.cpp b/pv/prop/double.cpp index 54540bc6..d8a7a292 100644 --- a/pv/prop/double.cpp +++ b/pv/prop/double.cpp @@ -38,11 +38,11 @@ Double::Double(QString name, Getter getter, Setter setter) : Property(name, getter, setter), - _decimals(decimals), - _suffix(suffix), - _range(range), - _step(step), - _spin_box(NULL) + decimals_(decimals), + suffix_(suffix), + range_(range), + step_(step), + spin_box_(NULL) { } @@ -52,44 +52,44 @@ Double::~Double() QWidget* Double::get_widget(QWidget *parent, bool auto_commit) { - if (_spin_box) - return _spin_box; + if (spin_box_) + return spin_box_; - if (!_getter) + if (!getter_) return NULL; - Glib::VariantBase variant = _getter(); + Glib::VariantBase variant = getter_(); if (!variant.gobj()) return NULL; double value = Glib::VariantBase::cast_dynamic>( variant).get(); - _spin_box = new QDoubleSpinBox(parent); - _spin_box->setDecimals(_decimals); - _spin_box->setSuffix(_suffix); - if (_range) - _spin_box->setRange(_range->first, _range->second); - if (_step) - _spin_box->setSingleStep(*_step); + spin_box_ = new QDoubleSpinBox(parent); + spin_box_->setDecimals(decimals_); + spin_box_->setSuffix(suffix_); + if (range_) + spin_box_->setRange(range_->first, range_->second); + if (step_) + spin_box_->setSingleStep(*step_); - _spin_box->setValue(value); + spin_box_->setValue(value); if (auto_commit) - connect(_spin_box, SIGNAL(valueChanged(double)), + connect(spin_box_, SIGNAL(valueChanged(double)), this, SLOT(on_value_changed(double))); - return _spin_box; + return spin_box_; } void Double::commit() { - assert(_setter); + assert(setter_); - if (!_spin_box) + if (!spin_box_) return; - _setter(Glib::Variant::create(_spin_box->value())); + setter_(Glib::Variant::create(spin_box_->value())); } void Double::on_value_changed(double) diff --git a/pv/prop/double.h b/pv/prop/double.h index 0dd0ba37..dc4c6ec9 100644 --- a/pv/prop/double.h +++ b/pv/prop/double.h @@ -53,12 +53,12 @@ private Q_SLOTS: void on_value_changed(double); private: - const int _decimals; - const QString _suffix; - const boost::optional< std::pair > _range; - const boost::optional _step; + const int decimals_; + const QString suffix_; + const boost::optional< std::pair > range_; + const boost::optional step_; - QDoubleSpinBox *_spin_box; + QDoubleSpinBox *spin_box_; }; } // prop diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index 03524344..473e3d5f 100644 --- a/pv/prop/enum.cpp +++ b/pv/prop/enum.cpp @@ -34,8 +34,8 @@ Enum::Enum(QString name, vector > values, Getter getter, Setter setter) : Property(name, getter, setter), - _values(values), - _selector(NULL) + values_(values), + selector_(NULL) { } @@ -45,43 +45,43 @@ Enum::~Enum() QWidget* Enum::get_widget(QWidget *parent, bool auto_commit) { - if (_selector) - return _selector; + if (selector_) + return selector_; - if (!_getter) + if (!getter_) return NULL; - Glib::VariantBase variant = _getter(); + Glib::VariantBase variant = getter_(); if (!variant.gobj()) return NULL; - _selector = new QComboBox(parent); - for (unsigned int i = 0; i < _values.size(); i++) { - const pair &v = _values[i]; - _selector->addItem(v.second, qVariantFromValue(v.first)); + selector_ = new QComboBox(parent); + for (unsigned int i = 0; i < values_.size(); i++) { + const pair &v = values_[i]; + selector_->addItem(v.second, qVariantFromValue(v.first)); if (v.first.equal(variant)) - _selector->setCurrentIndex(i); + selector_->setCurrentIndex(i); } if (auto_commit) - connect(_selector, SIGNAL(currentIndexChanged(int)), + connect(selector_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_current_item_changed(int))); - return _selector; + return selector_; } void Enum::commit() { - assert(_setter); + assert(setter_); - if (!_selector) + if (!selector_) return; - const int index = _selector->currentIndex(); + const int index = selector_->currentIndex(); if (index < 0) return; - _setter(_selector->itemData(index).value()); + setter_(selector_->itemData(index).value()); } void Enum::on_current_item_changed(int) diff --git a/pv/prop/enum.h b/pv/prop/enum.h index 6ff785a3..45454fde 100644 --- a/pv/prop/enum.h +++ b/pv/prop/enum.h @@ -53,9 +53,9 @@ private Q_SLOTS: void on_current_item_changed(int); private: - const std::vector< std::pair > _values; + const std::vector< std::pair > values_; - QComboBox *_selector; + QComboBox *selector_; }; } // prop diff --git a/pv/prop/int.cpp b/pv/prop/int.cpp index 45113ac7..ef962e5a 100644 --- a/pv/prop/int.cpp +++ b/pv/prop/int.cpp @@ -39,9 +39,9 @@ Int::Int(QString name, Getter getter, Setter setter) : Property(name, getter, setter), - _suffix(suffix), - _range(range), - _spin_box(NULL) + suffix_(suffix), + range_(range), + spin_box_(NULL) { } @@ -53,20 +53,20 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit) { int64_t int_val = 0, range_min = 0, range_max = 0; - if (_spin_box) - return _spin_box; + if (spin_box_) + return spin_box_; - if (!_getter) + if (!getter_) return NULL; - _value = _getter(); + value_ = getter_(); - GVariant *value = _value.gobj(); + GVariant *value = value_.gobj(); if (!value) return NULL; - _spin_box = new QSpinBox(parent); - _spin_box->setSuffix(_suffix); + spin_box_ = new QSpinBox(parent); + spin_box_->setSuffix(suffix_); const GVariantType *const type = g_variant_get_type(value); assert(type); @@ -120,45 +120,45 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit) range_min = max(range_min, (int64_t)INT_MIN); range_max = min(range_max, (int64_t)INT_MAX); - if (_range) - _spin_box->setRange((int)_range->first, (int)_range->second); + if (range_) + spin_box_->setRange((int)range_->first, (int)range_->second); else - _spin_box->setRange((int)range_min, (int)range_max); + spin_box_->setRange((int)range_min, (int)range_max); - _spin_box->setValue((int)int_val); + spin_box_->setValue((int)int_val); if (auto_commit) - connect(_spin_box, SIGNAL(valueChanged(int)), + connect(spin_box_, SIGNAL(valueChanged(int)), this, SLOT(on_value_changed(int))); - return _spin_box; + return spin_box_; } void Int::commit() { - assert(_setter); + assert(setter_); - if (!_spin_box) + if (!spin_box_) return; GVariant *new_value = NULL; - const GVariantType *const type = g_variant_get_type(_value.gobj()); + const GVariantType *const type = g_variant_get_type(value_.gobj()); assert(type); if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) - new_value = g_variant_new_byte(_spin_box->value()); + new_value = g_variant_new_byte(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) - new_value = g_variant_new_int16(_spin_box->value()); + new_value = g_variant_new_int16(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) - new_value = g_variant_new_uint16(_spin_box->value()); + new_value = g_variant_new_uint16(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) - new_value = g_variant_new_int32(_spin_box->value()); + new_value = g_variant_new_int32(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) - new_value = g_variant_new_int32(_spin_box->value()); + new_value = g_variant_new_int32(spin_box_->value()); else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) - new_value = g_variant_new_int64(_spin_box->value()); + 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()); + new_value = g_variant_new_uint64(spin_box_->value()); else { // Unexpected value type. @@ -167,9 +167,9 @@ void Int::commit() assert(new_value); - _value = Glib::VariantBase(new_value); + value_ = Glib::VariantBase(new_value); - _setter(_value); + setter_(value_); } void Int::on_value_changed(int) diff --git a/pv/prop/int.h b/pv/prop/int.h index 1de99d67..5779b37b 100644 --- a/pv/prop/int.h +++ b/pv/prop/int.h @@ -51,11 +51,11 @@ private Q_SLOTS: void on_value_changed(int); private: - const QString _suffix; - const boost::optional< std::pair > _range; + const QString suffix_; + const boost::optional< std::pair > range_; - Glib::VariantBase _value; - QSpinBox *_spin_box; + Glib::VariantBase value_; + QSpinBox *spin_box_; }; } // prop diff --git a/pv/prop/property.cpp b/pv/prop/property.cpp index 798b5f10..26740ba0 100644 --- a/pv/prop/property.cpp +++ b/pv/prop/property.cpp @@ -24,15 +24,15 @@ namespace pv { namespace prop { Property::Property(QString name, Getter getter, Setter setter) : - _getter(getter), - _setter(setter), - _name(name) + getter_(getter), + setter_(setter), + name_(name) { } const QString& Property::name() const { - return _name; + return name_; } bool Property::labeled_widget() const diff --git a/pv/prop/property.h b/pv/prop/property.h index 0d1b5316..dd6d25ba 100644 --- a/pv/prop/property.h +++ b/pv/prop/property.h @@ -53,11 +53,11 @@ public: virtual void commit() = 0; protected: - const Getter _getter; - const Setter _setter; + const Getter getter_; + const Setter setter_; private: - QString _name; + QString name_; }; } // prop diff --git a/pv/prop/string.cpp b/pv/prop/string.cpp index 511fe6c4..ebad62ba 100644 --- a/pv/prop/string.cpp +++ b/pv/prop/string.cpp @@ -36,44 +36,44 @@ String::String(QString name, Getter getter, Setter setter) : Property(name, getter, setter), - _line_edit(NULL) + line_edit_(NULL) { } QWidget* String::get_widget(QWidget *parent, bool auto_commit) { - if (_line_edit) - return _line_edit; + if (line_edit_) + return line_edit_; - if (!_getter) + if (!getter_) return NULL; - Glib::VariantBase variant = _getter(); + Glib::VariantBase variant = getter_(); if (!variant.gobj()) return NULL; string value = Glib::VariantBase::cast_dynamic>( variant).get(); - _line_edit = new QLineEdit(parent); - _line_edit->setText(QString::fromStdString(value)); + line_edit_ = new QLineEdit(parent); + line_edit_->setText(QString::fromStdString(value)); if (auto_commit) - connect(_line_edit, SIGNAL(textEdited(const QString&)), + connect(line_edit_, SIGNAL(textEdited(const QString&)), this, SLOT(on_text_edited(const QString&))); - return _line_edit; + return line_edit_; } void String::commit() { - assert(_setter); + assert(setter_); - if (!_line_edit) + if (!line_edit_) return; - QByteArray ba = _line_edit->text().toLocal8Bit(); - _setter(Glib::Variant::create(ba.data())); + QByteArray ba = line_edit_->text().toLocal8Bit(); + setter_(Glib::Variant::create(ba.data())); } void String::on_text_edited(const QString&) diff --git a/pv/prop/string.h b/pv/prop/string.h index 01c7e78b..793a23cb 100644 --- a/pv/prop/string.h +++ b/pv/prop/string.h @@ -43,7 +43,7 @@ private Q_SLOTS: void on_text_edited(const QString&); private: - QLineEdit *_line_edit; + QLineEdit *line_edit_; }; } // prop diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 11c89e09..a2eba967 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -83,9 +83,9 @@ using Glib::Variant; namespace pv { SigSession::SigSession(DeviceManager &device_manager) : - _device_manager(device_manager), - _session(device_manager.context()->create_session()), - _capture_state(Stopped) + device_manager_(device_manager), + session_(device_manager.context()->create_session()), + capture_state_(Stopped) { set_default_device(); } @@ -98,22 +98,22 @@ SigSession::~SigSession() DeviceManager& SigSession::device_manager() { - return _device_manager; + return device_manager_; } const DeviceManager& SigSession::device_manager() const { - return _device_manager; + return device_manager_; } const shared_ptr& SigSession::session() const { - return _session; + return session_; } shared_ptr SigSession::device() const { - return _device; + return device_; } void SigSession::set_device(shared_ptr device) @@ -124,30 +124,30 @@ void SigSession::set_device(shared_ptr device) // Are we setting a session device? auto session_device = dynamic_pointer_cast(device); // Did we have a session device selected previously? - auto prev_session_device = dynamic_pointer_cast(_device); + auto prev_session_device = dynamic_pointer_cast(device_); - if (_device) { - _session->remove_datafeed_callbacks(); + if (device_) { + session_->remove_datafeed_callbacks(); if (!prev_session_device) { - _device->close(); - _session->remove_devices(); + device_->close(); + session_->remove_devices(); } } if (session_device) - _session = session_device->parent(); + session_ = session_device->parent(); - _device = device; - _decode_traces.clear(); + device_ = device; + decode_traces_.clear(); if (device) { if (!session_device) { - _session = _device_manager.context()->create_session(); + session_ = device_manager_.context()->create_session(); device->open(); - _session->add_device(device); + session_->add_device(device); } - _session->add_datafeed_callback([=] + session_->add_datafeed_callback([=] (shared_ptr device, shared_ptr packet) { data_feed_in(device, packet); }); @@ -157,22 +157,22 @@ void SigSession::set_device(shared_ptr device) void SigSession::set_file(const string &name) { - _session = _device_manager.context()->load_session(name); - _device = _session->devices()[0]; - _decode_traces.clear(); - _session->add_datafeed_callback([=] + session_ = device_manager_.context()->load_session(name); + device_ = session_->devices()[0]; + decode_traces_.clear(); + session_->add_datafeed_callback([=] (shared_ptr device, shared_ptr packet) { data_feed_in(device, packet); }); - _device_manager.update_display_name(_device); - update_signals(_device); + device_manager_.update_display_name(device_); + update_signals(device_); } void SigSession::set_default_device() { shared_ptr default_device; const list< shared_ptr > &devices = - _device_manager.devices(); + device_manager_.devices(); if (!devices.empty()) { // Fall back to the first device in the list. @@ -191,8 +191,8 @@ void SigSession::set_default_device() SigSession::capture_state SigSession::get_capture_state() const { - lock_guard lock(_sampling_mutex); - return _capture_state; + lock_guard lock(sampling_mutex_); + return capture_state_; } void SigSession::start_capture(function error_handler) @@ -200,13 +200,13 @@ void SigSession::start_capture(function error_handler) stop_capture(); // Check that a device instance has been selected. - if (!_device) { + if (!device_) { qDebug() << "No device selected"; return; } // Check that at least one channel is enabled - auto channels = _device->channels(); + auto channels = device_->channels(); bool enabled = std::any_of(channels.begin(), channels.end(), [](shared_ptr channel) { return channel->enabled(); }); @@ -216,26 +216,26 @@ void SigSession::start_capture(function error_handler) } // Begin the session - _sampling_thread = std::thread( - &SigSession::sample_thread_proc, this, _device, + sampling_thread_ = std::thread( + &SigSession::sample_thread_proc, this, device_, error_handler); } void SigSession::stop_capture() { if (get_capture_state() != Stopped) - _session->stop(); + session_->stop(); // Check that sampling stopped - if (_sampling_thread.joinable()) - _sampling_thread.join(); + if (sampling_thread_.joinable()) + sampling_thread_.join(); } set< shared_ptr > SigSession::get_data() const { - shared_lock lock(_signals_mutex); + shared_lock lock(signals_mutex_); set< shared_ptr > data; - for (const shared_ptr sig : _signals) { + for (const shared_ptr sig : signals_) { assert(sig); data.insert(sig->data()); } @@ -245,12 +245,12 @@ set< shared_ptr > SigSession::get_data() const boost::shared_mutex& SigSession::signals_mutex() const { - return _signals_mutex; + return signals_mutex_; } const vector< shared_ptr >& SigSession::signals() const { - return _signals; + return signals_; } #ifdef ENABLE_DECODE @@ -261,7 +261,7 @@ bool SigSession::add_decoder(srd_decoder *const dec) try { - lock_guard lock(_signals_mutex); + lock_guard lock(signals_mutex_); // Create the decoder decoder_stack = shared_ptr( @@ -276,7 +276,7 @@ bool SigSession::add_decoder(srd_decoder *const dec) // Auto select the initial channels for (const srd_channel *pdch : all_channels) - for (shared_ptr s : _signals) + for (shared_ptr s : signals_) { shared_ptr l = dynamic_pointer_cast(s); @@ -294,8 +294,8 @@ bool SigSession::add_decoder(srd_decoder *const dec) // Create the decode signal shared_ptr d( new view::DecodeTrace(*this, decoder_stack, - _decode_traces.size())); - _decode_traces.push_back(d); + decode_traces_.size())); + decode_traces_.push_back(d); } catch(std::runtime_error e) { @@ -312,16 +312,16 @@ bool SigSession::add_decoder(srd_decoder *const dec) vector< shared_ptr > SigSession::get_decode_signals() const { - shared_lock lock(_signals_mutex); - return _decode_traces; + shared_lock lock(signals_mutex_); + return decode_traces_; } void SigSession::remove_decode_signal(view::DecodeTrace *signal) { - for (auto i = _decode_traces.begin(); i != _decode_traces.end(); i++) + for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++) if ((*i).get() == signal) { - _decode_traces.erase(i); + decode_traces_.erase(i); signals_changed(); return; } @@ -330,9 +330,9 @@ void SigSession::remove_decode_signal(view::DecodeTrace *signal) void SigSession::set_capture_state(capture_state state) { - lock_guard lock(_sampling_mutex); - const bool changed = _capture_state != state; - _capture_state = state; + lock_guard lock(sampling_mutex_); + const bool changed = capture_state_ != state; + capture_state_ = state; if(changed) capture_state_changed(state); } @@ -340,10 +340,10 @@ void SigSession::set_capture_state(capture_state state) void SigSession::update_signals(shared_ptr device) { assert(device); - assert(_capture_state == Stopped); + assert(capture_state_ == Stopped); // Clear the decode traces - _decode_traces.clear(); + decode_traces_.clear(); // Detect what data types we will receive auto channels = device->channels(); @@ -354,21 +354,21 @@ void SigSession::update_signals(shared_ptr device) // Create data containers for the logic data snapshots { - lock_guard data_lock(_data_mutex); + lock_guard data_lock(data_mutex_); - _logic_data.reset(); + logic_data_.reset(); if (logic_channel_count != 0) { - _logic_data.reset(new data::Logic( + logic_data_.reset(new data::Logic( logic_channel_count)); - assert(_logic_data); + assert(logic_data_); } } // Make the Signals list { - unique_lock lock(_signals_mutex); + unique_lock lock(signals_mutex_); - _signals.clear(); + signals_.clear(); for (auto channel : device->channels()) { shared_ptr signal; @@ -377,7 +377,7 @@ void SigSession::update_signals(shared_ptr device) case SR_CHANNEL_LOGIC: signal = shared_ptr( new view::LogicSignal(*this, device, - channel, _logic_data)); + channel, logic_data_)); break; case SR_CHANNEL_ANALOG: @@ -396,7 +396,7 @@ void SigSession::update_signals(shared_ptr device) } assert(signal); - _signals.push_back(signal); + signals_.push_back(signal); } } @@ -407,8 +407,8 @@ void SigSession::update_signals(shared_ptr device) shared_ptr SigSession::signal_from_channel( shared_ptr channel) const { - lock_guard lock(_signals_mutex); - for (shared_ptr sig : _signals) { + lock_guard lock(signals_mutex_); + for (shared_ptr sig : signals_) { assert(sig); if (sig->channel() == channel) return sig; @@ -438,20 +438,20 @@ void SigSession::sample_thread_proc(shared_ptr device, read_sample_rate(device); try { - _session->start(); + session_->start(); } catch(Error e) { error_handler(e.what()); return; } - set_capture_state(_session->trigger() ? + set_capture_state(session_->trigger() ? AwaitingTrigger : Running); - _session->run(); + session_->run(); set_capture_state(Stopped); // Confirm that SR_DF_END was received - if (_cur_logic_snapshot) + if (cur_logic_snapshot_) { qDebug("SR_DF_END was not received."); assert(0); @@ -484,21 +484,21 @@ void SigSession::feed_in_meta(shared_ptr device, void SigSession::feed_in_frame_begin() { - if (_cur_logic_snapshot || !_cur_analog_snapshots.empty()) + if (cur_logic_snapshot_ || !cur_analog_snapshots_.empty()) frame_began(); } void SigSession::feed_in_logic(shared_ptr logic) { - lock_guard lock(_data_mutex); + lock_guard lock(data_mutex_); - if (!_logic_data) + if (!logic_data_) { qDebug() << "Unexpected logic packet"; return; } - if (!_cur_logic_snapshot) + if (!cur_logic_snapshot_) { // This could be the first packet after a trigger set_capture_state(Running); @@ -507,15 +507,15 @@ void SigSession::feed_in_logic(shared_ptr logic) uint64_t sample_limit; try { sample_limit = VariantBase::cast_dynamic>( - _device->config_get(ConfigKey::LIMIT_SAMPLES)).get(); + device_->config_get(ConfigKey::LIMIT_SAMPLES)).get(); } catch (Error) { sample_limit = 0; } // Create a new data snapshot - _cur_logic_snapshot = shared_ptr( + cur_logic_snapshot_ = shared_ptr( new data::LogicSnapshot(logic, sample_limit)); - _logic_data->push_snapshot(_cur_logic_snapshot); + logic_data_->push_snapshot(cur_logic_snapshot_); // @todo Putting this here means that only listeners querying // for logic will be notified. Currently the only user of @@ -526,7 +526,7 @@ void SigSession::feed_in_logic(shared_ptr logic) else { // Append to the existing data snapshot - _cur_logic_snapshot->append_payload(logic); + cur_logic_snapshot_->append_payload(logic); } data_received(); @@ -534,7 +534,7 @@ void SigSession::feed_in_logic(shared_ptr logic) void SigSession::feed_in_analog(shared_ptr analog) { - lock_guard lock(_data_mutex); + lock_guard lock(data_mutex_); const vector> channels = analog->channels(); const unsigned int channel_count = channels.size(); @@ -548,8 +548,8 @@ void SigSession::feed_in_analog(shared_ptr analog) // Try to get the snapshot of the channel const map< shared_ptr, shared_ptr >:: - iterator iter = _cur_analog_snapshots.find(channel); - if (iter != _cur_analog_snapshots.end()) + iterator iter = cur_analog_snapshots_.find(channel); + if (iter != cur_analog_snapshots_.end()) snapshot = (*iter).second; else { @@ -562,7 +562,7 @@ void SigSession::feed_in_analog(shared_ptr analog) uint64_t sample_limit; try { sample_limit = VariantBase::cast_dynamic>( - _device->config_get(ConfigKey::LIMIT_SAMPLES)).get(); + device_->config_get(ConfigKey::LIMIT_SAMPLES)).get(); } catch (Error) { sample_limit = 0; } @@ -570,7 +570,7 @@ void SigSession::feed_in_analog(shared_ptr analog) // Create a snapshot, keep it in the maps of channels snapshot = shared_ptr( new data::AnalogSnapshot(sample_limit)); - _cur_analog_snapshots[channel] = snapshot; + cur_analog_snapshots_[channel] = snapshot; // Find the annalog data associated with the channel shared_ptr sig = @@ -629,9 +629,9 @@ void SigSession::data_feed_in(shared_ptr device, shared_ptr pack case SR_DF_END: { { - lock_guard lock(_data_mutex); - _cur_logic_snapshot.reset(); - _cur_analog_snapshots.clear(); + lock_guard lock(data_mutex_); + cur_logic_snapshot_.reset(); + cur_analog_snapshots_.clear(); } frame_ended(); break; diff --git a/pv/sigsession.h b/pv/sigsession.h index 62994256..513177be 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -148,29 +148,29 @@ private: std::shared_ptr packet); private: - DeviceManager &_device_manager; - std::shared_ptr _session; + DeviceManager &device_manager_; + std::shared_ptr session_; /** * The device instance that will be used in the next capture session. */ - std::shared_ptr _device; + std::shared_ptr device_; - std::vector< std::shared_ptr > _decode_traces; + std::vector< std::shared_ptr > decode_traces_; - mutable std::mutex _sampling_mutex; - capture_state _capture_state; + mutable std::mutex sampling_mutex_; + capture_state capture_state_; - mutable boost::shared_mutex _signals_mutex; - std::vector< std::shared_ptr > _signals; + mutable boost::shared_mutex signals_mutex_; + std::vector< std::shared_ptr > signals_; - mutable std::mutex _data_mutex; - std::shared_ptr _logic_data; - std::shared_ptr _cur_logic_snapshot; + mutable std::mutex data_mutex_; + std::shared_ptr logic_data_; + std::shared_ptr cur_logic_snapshot_; std::map< std::shared_ptr, std::shared_ptr > - _cur_analog_snapshots; + cur_analog_snapshots_; - std::thread _sampling_thread; + std::thread sampling_thread_; Q_SIGNALS: void capture_state_changed(int state); diff --git a/pv/storesession.cpp b/pv/storesession.cpp index ef1c6aad..dbe04b2c 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -54,11 +54,11 @@ const size_t StoreSession::BlockSize = 1024 * 1024; StoreSession::StoreSession(const std::string &file_name, const SigSession &session) : - _file_name(file_name), - _session(session), - _interrupt(false), - _units_stored(0), - _unit_count(0) + file_name_(file_name), + session_(session), + interrupt_(false), + units_stored_(0), + unit_count_(0) { } @@ -69,31 +69,31 @@ StoreSession::~StoreSession() pair StoreSession::progress() const { - return make_pair(_units_stored.load(), _unit_count.load()); + return make_pair(units_stored_.load(), unit_count_.load()); } const QString& StoreSession::error() const { - lock_guard lock(_mutex); - return _error; + lock_guard lock(mutex_); + return error_; } bool StoreSession::start() { set< shared_ptr > data_set = - _session.get_data(); + session_.get_data(); - shared_lock lock(_session.signals_mutex()); - const vector< shared_ptr > &sigs(_session.signals()); + shared_lock lock(session_.signals_mutex()); + const vector< shared_ptr > &sigs(session_.signals()); // Check we have logic data if (data_set.empty() || sigs.empty()) { - _error = tr("No data to save."); + error_ = tr("No data to save."); return false; } if (data_set.size() > 1) { - _error = tr("PulseView currently only has support for " + error_ = tr("PulseView currently only has support for " "storing a single data stream."); return false; } @@ -101,7 +101,7 @@ bool StoreSession::start() // Get the logic data shared_ptr data; if (!(data = dynamic_pointer_cast(*data_set.begin()))) { - _error = tr("PulseView currently only has support for " + error_ = tr("PulseView currently only has support for " "storing a logic data."); return false; } @@ -111,7 +111,7 @@ bool StoreSession::start() data->get_snapshots(); if (snapshots.empty()) { - _error = tr("No snapshots to save."); + error_ = tr("No snapshots to save."); return false; } @@ -120,34 +120,34 @@ bool StoreSession::start() // Begin storing try { - auto context = _session.session()->context(); + auto context = session_.session()->context(); auto output_format = context->output_formats()["srzip"]; - auto device = _session.device(); - _output = output_format->create_output(device, + auto device = session_.device(); + output_ = output_format->create_output(device, {{"filename", - Glib::Variant::create(_file_name)}}); + Glib::Variant::create(file_name_)}}); auto meta = context->create_meta_packet( {{ConfigKey::SAMPLERATE, Glib::Variant::create(data->samplerate())}}); - _output->receive(meta); + output_->receive(meta); } catch (Error error) { - _error = tr("Error while saving."); + error_ = tr("Error while saving."); return false; } - _thread = std::thread(&StoreSession::store_proc, this, snapshot); + thread_ = std::thread(&StoreSession::store_proc, this, snapshot); return true; } void StoreSession::wait() { - if (_thread.joinable()) - _thread.join(); + if (thread_.joinable()) + thread_.join(); } void StoreSession::cancel() { - _interrupt = true; + interrupt_ = true; } void StoreSession::store_proc(shared_ptr snapshot) @@ -171,11 +171,11 @@ void StoreSession::store_proc(shared_ptr snapshot) while ((sample_count >> progress_scale) > INT_MAX) progress_scale ++; - _unit_count = sample_count >> progress_scale; + unit_count_ = sample_count >> progress_scale; const unsigned int samples_per_block = BlockSize / unit_size; - while (!_interrupt && start_sample < sample_count) + while (!interrupt_ && start_sample < sample_count) { progress_updated(); @@ -186,21 +186,21 @@ void StoreSession::store_proc(shared_ptr snapshot) size_t length = end_sample - start_sample; try { - auto context = _session.session()->context(); + auto context = session_.session()->context(); auto logic = context->create_logic_packet(data, length, unit_size); - _output->receive(logic); + output_->receive(logic); } catch (Error error) { - _error = tr("Error while saving."); + error_ = tr("Error while saving."); break; } start_sample = end_sample; - _units_stored = start_sample >> progress_scale; + units_stored_ = start_sample >> progress_scale; } progress_updated(); - _output.reset(); + output_.reset(); delete[] data; } diff --git a/pv/storesession.h b/pv/storesession.h index d365730e..8eaddaa6 100644 --- a/pv/storesession.h +++ b/pv/storesession.h @@ -72,19 +72,19 @@ Q_SIGNALS: void progress_updated(); private: - const std::string _file_name; - const SigSession &_session; + const std::string file_name_; + const SigSession &session_; - std::shared_ptr _output; + std::shared_ptr output_; - std::thread _thread; + std::thread thread_; - std::atomic _interrupt; + std::atomic interrupt_; - std::atomic _units_stored, _unit_count; + std::atomic units_stored_, unit_count_; - mutable std::mutex _mutex; - QString _error; + mutable std::mutex mutex_; + QString error_; }; } // pv diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 21421bca..13c57d6c 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -57,55 +57,55 @@ const uint64_t SamplingBar::DefaultSampleCount = 1000000; SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : QToolBar("Sampling Bar", parent), - _session(session), - _device_selector(this), - _updating_device_selector(false), - _configure_button(this), - _configure_button_action(NULL), - _channels_button(this), - _sample_count(" samples", this), - _sample_rate("Hz", this), - _updating_sample_rate(false), - _updating_sample_count(false), - _sample_count_supported(false), - _icon_red(":/icons/status-red.svg"), - _icon_green(":/icons/status-green.svg"), - _icon_grey(":/icons/status-grey.svg"), - _run_stop_button(this) + session_(session), + device_selector_(this), + updating_device_selector_(false), + configure_button_(this), + configure_button_action_(NULL), + channels_button_(this), + sample_count_(" samples", this), + sample_rate_("Hz", this), + updating_sample_rate_(false), + updating_sample_count_(false), + sample_count_supported_(false), + icon_red_(":/icons/status-red.svg"), + icon_green_(":/icons/status-green.svg"), + icon_grey_(":/icons/status-grey.svg"), + run_stop_button_(this) { setObjectName(QString::fromUtf8("SamplingBar")); - connect(&_run_stop_button, SIGNAL(clicked()), + connect(&run_stop_button_, SIGNAL(clicked()), this, SLOT(on_run_stop())); - connect(&_device_selector, SIGNAL(currentIndexChanged (int)), + connect(&device_selector_, SIGNAL(currentIndexChanged (int)), this, SLOT(on_device_selected())); - connect(&_sample_count, SIGNAL(value_changed()), + connect(&sample_count_, SIGNAL(value_changed()), this, SLOT(on_sample_count_changed())); - connect(&_sample_rate, SIGNAL(value_changed()), + connect(&sample_rate_, SIGNAL(value_changed()), this, SLOT(on_sample_rate_changed())); - _sample_count.show_min_max_step(0, UINT64_MAX, 1); + sample_count_.show_min_max_step(0, UINT64_MAX, 1); set_capture_state(pv::SigSession::Stopped); - _configure_button.setIcon(QIcon::fromTheme("configure", + configure_button_.setIcon(QIcon::fromTheme("configure", QIcon(":/icons/configure.png"))); - _channels_button.setIcon(QIcon::fromTheme("channels", + channels_button_.setIcon(QIcon::fromTheme("channels", QIcon(":/icons/channels.svg"))); - _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + run_stop_button_.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - addWidget(&_device_selector); - _configure_button_action = addWidget(&_configure_button); - addWidget(&_channels_button); - addWidget(&_sample_count); - addWidget(&_sample_rate); + addWidget(&device_selector_); + configure_button_action_ = addWidget(&configure_button_); + addWidget(&channels_button_); + addWidget(&sample_count_); + addWidget(&sample_rate_); - addWidget(&_run_stop_button); + addWidget(&run_stop_button_); - _sample_count.installEventFilter(this); - _sample_rate.installEventFilter(this); + sample_count_.installEventFilter(this); + sample_rate_.installEventFilter(this); } void SamplingBar::set_device_list( @@ -116,9 +116,9 @@ void SamplingBar::set_device_list( assert(selected); - _updating_device_selector = true; + updating_device_selector_ = true; - _device_selector.clear(); + device_selector_.clear(); for (auto entry : devices) { auto device = entry.first; @@ -127,37 +127,37 @@ void SamplingBar::set_device_list( assert(device); if (selected == device) - selected_index = _device_selector.count(); + selected_index = device_selector_.count(); - _device_selector.addItem(display_name.c_str(), + device_selector_.addItem(display_name.c_str(), qVariantFromValue(device)); } // The selected device should have been in the list assert(selected_index != -1); - _device_selector.setCurrentIndex(selected_index); + device_selector_.setCurrentIndex(selected_index); update_device_config_widgets(); - _updating_device_selector = false; + updating_device_selector_ = false; } shared_ptr SamplingBar::get_selected_device() const { - const int index = _device_selector.currentIndex(); + const int index = device_selector_.currentIndex(); if (index < 0) return shared_ptr(); - return _device_selector.itemData(index).value>(); + return device_selector_.itemData(index).value>(); } void SamplingBar::set_capture_state(pv::SigSession::capture_state state) { - const QIcon *icons[] = {&_icon_grey, &_icon_red, &_icon_green}; - _run_stop_button.setIcon(*icons[state]); - _run_stop_button.setText((state == pv::SigSession::Stopped) ? + const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_}; + run_stop_button_.setIcon(*icons[state]); + run_stop_button_.setText((state == pv::SigSession::Stopped) ? tr("Run") : tr("Stop")); - _run_stop_button.setShortcut(QKeySequence(Qt::Key_Space)); + run_stop_button_.setShortcut(QKeySequence(Qt::Key_Space)); } void SamplingBar::update_sample_rate_selector() @@ -167,21 +167,21 @@ void SamplingBar::update_sample_rate_selector() const uint64_t *elements = NULL; gsize num_elements; - if (_updating_sample_rate) + if (updating_sample_rate_) return; const shared_ptr device = get_selected_device(); if (!device) return; - assert(!_updating_sample_rate); - _updating_sample_rate = true; + assert(!updating_sample_rate_); + updating_sample_rate_ = true; try { gvar_dict = device->config_list(ConfigKey::SAMPLERATE); } catch (Error error) { - _sample_rate.show_none(); - _updating_sample_rate = false; + sample_rate_.show_none(); + updating_sample_rate_ = false; return; } @@ -203,14 +203,14 @@ void SamplingBar::update_sample_rate_selector() assert(step > 0); if (step == 1) - _sample_rate.show_125_list(min, max); + sample_rate_.show_125_list(min, max); else { // When the step is not 1, we cam't make a 1-2-5-10 // list of sample rates, because we may not be able to // make round numbers. Therefore in this case, show a // spin box. - _sample_rate.show_min_max_step(min, max, step); + sample_rate_.show_min_max_step(min, max, step); } } else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(), @@ -218,17 +218,17 @@ void SamplingBar::update_sample_rate_selector() { elements = (const uint64_t *)g_variant_get_fixed_array( gvar_list, &num_elements, sizeof(uint64_t)); - _sample_rate.show_list(elements, num_elements); + sample_rate_.show_list(elements, num_elements); g_variant_unref(gvar_list); } - _updating_sample_rate = false; + updating_sample_rate_ = false; update_sample_rate_selector_value(); } void SamplingBar::update_sample_rate_selector_value() { - if (_updating_sample_rate) + if (updating_sample_rate_) return; const shared_ptr device = get_selected_device(); @@ -239,10 +239,10 @@ void SamplingBar::update_sample_rate_selector_value() auto gvar = device->config_get(ConfigKey::SAMPLERATE); uint64_t samplerate = Glib::VariantBase::cast_dynamic>(gvar).get(); - assert(!_updating_sample_rate); - _updating_sample_rate = true; - _sample_rate.set_value(samplerate); - _updating_sample_rate = false; + assert(!updating_sample_rate_); + updating_sample_rate_ = true; + sample_rate_.set_value(samplerate); + updating_sample_rate_ = false; } catch (Error error) { qDebug() << "WARNING: Failed to get value of sample rate"; return; @@ -251,19 +251,19 @@ void SamplingBar::update_sample_rate_selector_value() void SamplingBar::update_sample_count_selector() { - if (_updating_sample_count) + if (updating_sample_count_) return; const shared_ptr device = get_selected_device(); if (!device) return; - assert(!_updating_sample_count); - _updating_sample_count = true; + assert(!updating_sample_count_); + updating_sample_count_ = true; - if (_sample_count_supported) + if (sample_count_supported_) { - uint64_t sample_count = _sample_count.value(); + uint64_t sample_count = sample_count_.value(); uint64_t min_sample_count = 0; uint64_t max_sample_count = MaxSampleCount; @@ -279,7 +279,7 @@ void SamplingBar::update_sample_count_selector() min_sample_count = min(max(min_sample_count, MinSampleCount), max_sample_count); - _sample_count.show_125_list( + sample_count_.show_125_list( min_sample_count, max_sample_count); try { @@ -291,12 +291,12 @@ void SamplingBar::update_sample_count_selector() max_sample_count); } catch (Error error) {} - _sample_count.set_value(sample_count); + sample_count_.set_value(sample_count); } else - _sample_count.show_none(); + sample_count_.show_none(); - _updating_sample_count = false; + updating_sample_count_ = false; } void SamplingBar::update_device_config_widgets() @@ -309,16 +309,16 @@ void SamplingBar::update_device_config_widgets() // Update the configure popup DeviceOptions *const opts = new DeviceOptions(device, this); - _configure_button_action->setVisible( + configure_button_action_->setVisible( !opts->binding().properties().empty()); - _configure_button.set_popup(opts); + configure_button_.set_popup(opts); // Update the channels popup - Channels *const channels = new Channels(_session, this); - _channels_button.set_popup(channels); + Channels *const channels = new Channels(session_, this); + channels_button_.set_popup(channels); // Update supported options. - _sample_count_supported = false; + sample_count_supported_ = false; try { for (auto entry : device->config_keys(ConfigKey::DEVICE_OPTIONS)) @@ -328,7 +328,7 @@ void SamplingBar::update_device_config_widgets() switch (key->id()) { case SR_CONF_LIMIT_SAMPLES: if (capabilities.count(Capability::SET)) - _sample_count_supported = true; + sample_count_supported_ = true; break; case SR_CONF_LIMIT_FRAMES: if (capabilities.count(Capability::SET)) @@ -358,19 +358,19 @@ void SamplingBar::commit_sample_count() { uint64_t sample_count = 0; - if (_updating_sample_count) + if (updating_sample_count_) return; const shared_ptr device = get_selected_device(); if (!device) return; - sample_count = _sample_count.value(); + sample_count = sample_count_.value(); // Set the sample count - assert(!_updating_sample_count); - _updating_sample_count = true; - if (_sample_count_supported) + assert(!updating_sample_count_); + updating_sample_count_ = true; + if (sample_count_supported_) { try { device->config_set(ConfigKey::LIMIT_SAMPLES, @@ -381,27 +381,27 @@ void SamplingBar::commit_sample_count() return; } } - _updating_sample_count = false; + updating_sample_count_ = false; } void SamplingBar::commit_sample_rate() { uint64_t sample_rate = 0; - if (_updating_sample_rate) + if (updating_sample_rate_) return; const shared_ptr device = get_selected_device(); if (!device) return; - sample_rate = _sample_rate.value(); + sample_rate = sample_rate_.value(); if (sample_rate == 0) return; // Set the samplerate - assert(!_updating_sample_rate); - _updating_sample_rate = true; + assert(!updating_sample_rate_); + updating_sample_rate_ = true; try { device->config_set(ConfigKey::SAMPLERATE, Glib::Variant::create(sample_rate)); @@ -410,19 +410,19 @@ void SamplingBar::commit_sample_rate() qDebug() << "Failed to configure samplerate."; return; } - _updating_sample_rate = false; + updating_sample_rate_ = false; } void SamplingBar::on_device_selected() { - if (_updating_device_selector) + if (updating_device_selector_) return; shared_ptr device = get_selected_device(); if (!device) return; - _session.set_device(device); + session_.set_device(device); update_device_config_widgets(); } @@ -454,9 +454,9 @@ void SamplingBar::on_config_changed() bool SamplingBar::eventFilter(QObject *watched, QEvent *event) { - if ((watched == &_sample_count || watched == &_sample_rate) && + if ((watched == &sample_count_ || watched == &sample_rate_) && (event->type() == QEvent::ToolTip)) { - double sec = (double)_sample_count.value() / _sample_rate.value(); + double sec = (double)sample_count_.value() / sample_rate_.value(); QHelpEvent *help_event = static_cast(event); QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec)); diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index d8d81219..2397e2aa 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -92,27 +92,27 @@ protected: bool eventFilter(QObject *watched, QEvent *event); private: - SigSession &_session; + SigSession &session_; - QComboBox _device_selector; - bool _updating_device_selector; + QComboBox device_selector_; + bool updating_device_selector_; - pv::widgets::PopupToolButton _configure_button; - QAction *_configure_button_action; + pv::widgets::PopupToolButton configure_button_; + QAction *configure_button_action_; - pv::widgets::PopupToolButton _channels_button; + pv::widgets::PopupToolButton channels_button_; - pv::widgets::SweepTimingWidget _sample_count; - pv::widgets::SweepTimingWidget _sample_rate; - bool _updating_sample_rate; - bool _updating_sample_count; + pv::widgets::SweepTimingWidget sample_count_; + pv::widgets::SweepTimingWidget sample_rate_; + bool updating_sample_rate_; + bool updating_sample_count_; - bool _sample_count_supported; + bool sample_count_supported_; - QIcon _icon_red; - QIcon _icon_green; - QIcon _icon_grey; - QToolButton _run_stop_button; + QIcon icon_red_; + QIcon icon_green_; + QIcon icon_grey_; + QToolButton run_stop_button_; }; } // namespace toolbars diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index a8d7b3e8..3509a040 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -57,10 +57,10 @@ AnalogSignal::AnalogSignal( shared_ptr channel, shared_ptr data) : Signal(session, channel), - _data(data), - _scale(1.0f) + data_(data), + scale_(1.0f) { - _colour = SignalColours[_channel->index() % countof(SignalColours)]; + colour_ = SignalColours[channel_->index() % countof(SignalColours)]; } AnalogSignal::~AnalogSignal() @@ -69,17 +69,17 @@ AnalogSignal::~AnalogSignal() shared_ptr AnalogSignal::data() const { - return _data; + return data_; } shared_ptr AnalogSignal::analog_data() const { - return _data; + return data_; } void AnalogSignal::set_scale(float scale) { - _scale = scale; + scale_ = scale; } std::pair AnalogSignal::v_extents() const @@ -89,19 +89,19 @@ std::pair AnalogSignal::v_extents() const void AnalogSignal::paint_back(QPainter &p, int left, int right) { - if (_channel->enabled()) + if (channel_->enabled()) paint_axis(p, get_visual_y(), left, right); } void AnalogSignal::paint_mid(QPainter &p, int left, int right) { - assert(_data); + assert(data_); assert(right >= left); - assert(_owner); + assert(owner_); const int y = get_visual_y(); - const View *const view = _owner->view(); + const View *const view = owner_->view(); assert(view); const double scale = view->scale(); @@ -109,11 +109,11 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right) const double offset = view->offset(); - if (!_channel->enabled()) + if (!channel_->enabled()) return; const deque< shared_ptr > &snapshots = - _data->get_snapshots(); + data_->get_snapshots(); if (snapshots.empty()) return; @@ -121,8 +121,8 @@ void AnalogSignal::paint_mid(QPainter &p, int left, int right) snapshots.front(); const double pixels_offset = offset / scale; - const double samplerate = _data->samplerate(); - const double start_time = _data->get_start_time(); + const double samplerate = data_->samplerate(); + const double start_time = data_->get_start_time(); const int64_t last_sample = snapshot->get_sample_count() - 1; const double samples_per_pixel = samplerate * scale; const double start = samplerate * (offset - start_time); @@ -153,7 +153,7 @@ void AnalogSignal::paint_trace(QPainter &p, const float *const samples = snapshot->get_samples(start, end); assert(samples); - p.setPen(_colour); + p.setPen(colour_); QPointF *points = new QPointF[sample_count]; QPointF *point = points; @@ -162,7 +162,7 @@ void AnalogSignal::paint_trace(QPainter &p, const float x = (sample / samples_per_pixel - pixels_offset) + left; *point++ = QPointF(x, - y - samples[sample - start] * _scale); + y - samples[sample - start] * scale_); } p.drawPolyline(points, point - points); @@ -185,7 +185,7 @@ void AnalogSignal::paint_envelope(QPainter &p, return; p.setPen(QPen(Qt::NoPen)); - p.setBrush(_colour); + p.setBrush(colour_); QRectF *const rects = new QRectF[e.length]; QRectF *rect = rects; @@ -198,8 +198,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/analogsignal.h b/pv/view/analogsignal.h index 71063900..326e6fbc 100644 --- a/pv/view/analogsignal.h +++ b/pv/view/analogsignal.h @@ -89,8 +89,8 @@ private: const double pixels_offset, const double samples_per_pixel); private: - std::shared_ptr _data; - float _scale; + std::shared_ptr data_; + float scale_; }; } // namespace view diff --git a/pv/view/cursor.cpp b/pv/view/cursor.cpp index 98b7289f..0cc63142 100644 --- a/pv/view/cursor.cpp +++ b/pv/view/cursor.cpp @@ -58,16 +58,16 @@ QRectF Cursor::get_label_rect(const QRect &rect) const const shared_ptr other(get_other_cursor()); assert(other); - const float x = (_time - _view.offset()) / _view.scale(); + const float x = (time_ - view_.offset()) / view_.scale(); const QSizeF label_size( - _text_size.width() + View::LabelPadding.width() * 2, - _text_size.height() + View::LabelPadding.height() * 2); + text_size_.width() + View::LabelPadding.width() * 2, + text_size_.height() + View::LabelPadding.height() * 2); const float top = rect.height() - label_size.height() - Cursor::Offset - Cursor::ArrowSize - 0.5f; const float height = label_size.height(); - if (_time > other->time()) + if (time_ > other->time()) return QRectF(x, top, label_size.width(), height); else return QRectF(x - label_size.width(), top, @@ -115,9 +115,9 @@ void Cursor::paint_label(QPainter &p, const QRect &rect, QPointF(r.right() - 1, rect.bottom() - 1), }; - const QPointF *const points = (_time > other->time()) ? + const QPointF *const points = (time_ > other->time()) ? left_points : right_points; - const QPointF *const highlight_points = (_time > other->time()) ? + const QPointF *const highlight_points = (time_ > other->time()) ? left_highlight_points : right_highlight_points; if (selected()) { @@ -140,18 +140,18 @@ void Cursor::paint_label(QPainter &p, const QRect &rect, p.setPen(TextColour); p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter, - pv::util::format_time(_time, prefix, 2)); + pv::util::format_time(time_, prefix, 2)); } void Cursor::compute_text_size(QPainter &p, unsigned int prefix) { - _text_size = p.boundingRect(QRectF(), 0, - pv::util::format_time(_time, prefix, 2)).size(); + text_size_ = p.boundingRect(QRectF(), 0, + pv::util::format_time(time_, prefix, 2)).size(); } shared_ptr Cursor::get_other_cursor() const { - const CursorPair &cursors = _view.cursors(); + const CursorPair &cursors = view_.cursors(); return (cursors.first().get() == this) ? cursors.second() : cursors.first(); } diff --git a/pv/view/cursor.h b/pv/view/cursor.h index 16e8298b..649230ce 100644 --- a/pv/view/cursor.h +++ b/pv/view/cursor.h @@ -77,7 +77,7 @@ private: std::shared_ptr get_other_cursor() const; private: - QSizeF _text_size; + QSizeF text_size_; }; } // namespace view diff --git a/pv/view/cursorheader.cpp b/pv/view/cursorheader.cpp index a9b709f2..3f25e212 100644 --- a/pv/view/cursorheader.cpp +++ b/pv/view/cursorheader.cpp @@ -46,20 +46,20 @@ int CursorHeader::calculateTextHeight() CursorHeader::CursorHeader(View &parent) : MarginWidget(parent), - _dragging(false), - _textHeight(calculateTextHeight()) + dragging_(false), + textHeight_(calculateTextHeight()) { setMouseTracking(true); } QSize CursorHeader::sizeHint() const { - return QSize(0, _textHeight + Padding + BaselineOffset); + return QSize(0, textHeight_ + Padding + BaselineOffset); } void CursorHeader::clear_selection() { - CursorPair &cursors = _view.cursors(); + CursorPair &cursors = view_.cursors(); cursors.first()->select(false); cursors.second()->select(false); update(); @@ -71,15 +71,15 @@ void CursorHeader::paintEvent(QPaintEvent*) p.setRenderHint(QPainter::Antialiasing); unsigned int prefix = pv::view::Ruler::calculate_tick_spacing( - p, _view.scale(), _view.offset()).second; + p, view_.scale(), view_.offset()).second; // Draw the cursors - if (_view.cursors_shown()) { + if (view_.cursors_shown()) { // The cursor labels are not drawn with the arrows exactly on the // bottom line of the widget, because then the selection shadow // would be clipped away. const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset); - _view.cursors().draw_markers(p, r, prefix); + view_.cursors().draw_markers(p, r, prefix); } } @@ -88,37 +88,37 @@ void CursorHeader::mouseMoveEvent(QMouseEvent *e) if (!(e->buttons() & Qt::LeftButton)) return; - if ((e->pos() - _mouse_down_point).manhattanLength() < + if ((e->pos() - mouse_down_point_).manhattanLength() < QApplication::startDragDistance()) return; - _dragging = true; + dragging_ = true; - if (shared_ptr m = _grabbed_marker.lock()) - m->set_time(_view.offset() + - ((double)e->x() + 0.5) * _view.scale()); + if (shared_ptr m = grabbed_marker_.lock()) + m->set_time(view_.offset() + + ((double)e->x() + 0.5) * view_.scale()); } void CursorHeader::mousePressEvent(QMouseEvent *e) { if (e->buttons() & Qt::LeftButton) { - _mouse_down_point = e->pos(); + mouse_down_point_ = e->pos(); - _grabbed_marker.reset(); + grabbed_marker_.reset(); clear_selection(); - if (_view.cursors_shown()) { - CursorPair &cursors = _view.cursors(); + if (view_.cursors_shown()) { + CursorPair &cursors = view_.cursors(); if (cursors.first()->get_label_rect( rect()).contains(e->pos())) - _grabbed_marker = cursors.first(); + grabbed_marker_ = cursors.first(); else if (cursors.second()->get_label_rect( rect()).contains(e->pos())) - _grabbed_marker = cursors.second(); + grabbed_marker_ = cursors.second(); } - if (shared_ptr m = _grabbed_marker.lock()) + if (shared_ptr m = grabbed_marker_.lock()) m->select(); selection_changed(); @@ -129,16 +129,16 @@ void CursorHeader::mouseReleaseEvent(QMouseEvent *) { using pv::widgets::Popup; - if (!_dragging) - if (shared_ptr m = _grabbed_marker.lock()) { - Popup *const p = m->create_popup(&_view); + if (!dragging_) + if (shared_ptr m = grabbed_marker_.lock()) { + Popup *const p = m->create_popup(&view_); const QPoint arrpos(m->get_x(), height() - BaselineOffset); p->set_position(mapToGlobal(arrpos), Popup::Bottom); p->show(); } - _dragging = false; - _grabbed_marker.reset(); + dragging_ = false; + grabbed_marker_.reset(); } } // namespace view diff --git a/pv/view/cursorheader.h b/pv/view/cursorheader.h index d3124be9..e6552265 100644 --- a/pv/view/cursorheader.h +++ b/pv/view/cursorheader.h @@ -61,10 +61,10 @@ private: int calculateTextHeight(); - std::weak_ptr _grabbed_marker; - QPoint _mouse_down_point; - bool _dragging; - const int _textHeight; + std::weak_ptr grabbed_marker_; + QPoint mouse_down_point_; + bool dragging_; + const int textHeight_; }; } // namespace view diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index d319a7b1..0b5363f1 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -38,27 +38,27 @@ namespace view { const int CursorPair::DeltaPadding = 8; CursorPair::CursorPair(View &view) : - _first(new Cursor(view, 0.0)), - _second(new Cursor(view, 1.0)), - _view(view) + first_(new Cursor(view, 0.0)), + second_(new Cursor(view, 1.0)), + view_(view) { } shared_ptr CursorPair::first() const { - return _first; + return first_; } shared_ptr CursorPair::second() const { - return _second; + return second_; } QRectF CursorPair::get_label_rect(const QRect &rect) const { const QSizeF label_size( - _text_size.width() + View::LabelPadding.width() * 2, - _text_size.height() + View::LabelPadding.height() * 2); + text_size_.width() + View::LabelPadding.width() * 2, + text_size_.height() + View::LabelPadding.height() * 2); const pair offsets(get_cursor_offsets()); const pair normal_offsets( (offsets.first < offsets.second) ? offsets : @@ -77,8 +77,8 @@ QRectF CursorPair::get_label_rect(const QRect &rect) const void CursorPair::draw_markers(QPainter &p, const QRect &rect, unsigned int prefix) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); compute_text_size(p, prefix); QRectF delta_rect(get_label_rect(rect)); @@ -86,7 +86,7 @@ void CursorPair::draw_markers(QPainter &p, const int radius = delta_rect.height() / 2; const QRectF text_rect(delta_rect.intersected( rect).adjusted(radius, 0, -radius, 0)); - if(text_rect.width() >= _text_size.width()) + if(text_rect.width() >= text_size_.width()) { const int highlight_radius = delta_rect.height() / 2 - 2; @@ -100,12 +100,12 @@ void CursorPair::draw_markers(QPainter &p, p.setPen(Cursor::TextColour); p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter, - pv::util::format_time(_second->time() - _first->time(), prefix, 2)); + pv::util::format_time(second_->time() - first_->time(), prefix, 2)); } // Paint the cursor markers - _first->paint_label(p, rect, prefix); - _second->paint_label(p, rect, prefix); + first_->paint_label(p, rect, prefix); + second_->paint_label(p, rect, prefix); } void CursorPair::draw_viewport_background(QPainter &p, @@ -126,30 +126,30 @@ void CursorPair::draw_viewport_background(QPainter &p, void CursorPair::draw_viewport_foreground(QPainter &p, const QRect &rect) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); - _first->paint(p, rect); - _second->paint(p, rect); + first_->paint(p, rect); + second_->paint(p, rect); } void CursorPair::compute_text_size(QPainter &p, unsigned int prefix) { - assert(_first); - assert(_second); + assert(first_); + assert(second_); - _text_size = p.boundingRect(QRectF(), 0, pv::util::format_time( - _second->time() - _first->time(), prefix, 2)).size(); + text_size_ = p.boundingRect(QRectF(), 0, pv::util::format_time( + second_->time() - first_->time(), prefix, 2)).size(); } pair CursorPair::get_cursor_offsets() const { - assert(_first); - assert(_second); + assert(first_); + assert(second_); return pair( - (_first->time() - _view.offset()) / _view.scale(), - (_second->time() - _view.offset()) / _view.scale()); + (first_->time() - view_.offset()) / view_.scale(), + (second_->time() - view_.offset()) / view_.scale()); } } // namespace view diff --git a/pv/view/cursorpair.h b/pv/view/cursorpair.h index 6c56dcd7..f7eb51ca 100644 --- a/pv/view/cursorpair.h +++ b/pv/view/cursorpair.h @@ -69,10 +69,10 @@ public: std::pair get_cursor_offsets() const; private: - std::shared_ptr _first, _second; - const View &_view; + std::shared_ptr first_, second_; + const View &view_; - QSizeF _text_size; + QSizeF text_size_; }; } // namespace view diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 3b27cda3..005d98b8 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -127,22 +127,22 @@ DecodeTrace::DecodeTrace(pv::SigSession &session, std::shared_ptr decoder_stack, int index) : Trace(QString::fromUtf8( decoder_stack->stack().front()->decoder()->name)), - _session(session), - _decoder_stack(decoder_stack), - _text_height(0), - _row_height(0), - _delete_mapper(this), - _show_hide_mapper(this) + session_(session), + decoder_stack_(decoder_stack), + text_height_(0), + row_height_(0), + delete_mapper_(this), + show_hide_mapper_(this) { - assert(_decoder_stack); + assert(decoder_stack_); - _colour = DecodeColours[index % countof(DecodeColours)]; + colour_ = DecodeColours[index % countof(DecodeColours)]; - connect(_decoder_stack.get(), SIGNAL(new_decode_data()), + connect(decoder_stack_.get(), SIGNAL(new_decode_data()), this, SLOT(on_new_decode_data())); - connect(&_delete_mapper, SIGNAL(mapped(int)), + connect(&delete_mapper_, SIGNAL(mapped(int)), this, SLOT(on_delete_decoder(int))); - connect(&_show_hide_mapper, SIGNAL(mapped(int)), + connect(&show_hide_mapper_, SIGNAL(mapped(int)), this, SLOT(on_show_hide_decoder(int))); } @@ -153,7 +153,7 @@ bool DecodeTrace::enabled() const const std::shared_ptr& DecodeTrace::decoder() const { - return _decoder_stack; + return decoder_stack_; } pair DecodeTrace::v_extents() const @@ -177,12 +177,12 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) using namespace pv::data::decode; QFontMetrics m(QApplication::font()); - _text_height = m.boundingRect(QRect(), 0, "Tg").height(); - _row_height = (_text_height * 6) / 4; - const int annotation_height = (_text_height * 5) / 4; + text_height_ = m.boundingRect(QRect(), 0, "Tg").height(); + row_height_ = (text_height_ * 6) / 4; + const int annotation_height = (text_height_ * 5) / 4; - assert(_decoder_stack); - const QString err = _decoder_stack->error_message(); + assert(decoder_stack_); + const QString err = decoder_stack_->error_message(); if (!err.isEmpty()) { draw_unresolved_period(p, annotation_height, left, right); @@ -194,10 +194,10 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) int y = get_visual_y(); pair sample_range = get_sample_range(left, right); - assert(_decoder_stack); - const vector rows(_decoder_stack->get_visible_rows()); + assert(decoder_stack_); + const vector rows(decoder_stack_->get_visible_rows()); - _visible_rows.clear(); + visible_rows_.clear(); for (size_t i = 0; i < rows.size(); i++) { const Row &row = rows[i]; @@ -209,16 +209,16 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) base_colour >>= 16; vector annotations; - _decoder_stack->get_annotation_subset(annotations, row, + decoder_stack_->get_annotation_subset(annotations, row, sample_range.first, sample_range.second); if (!annotations.empty()) { for (const Annotation &a : annotations) draw_annotation(a, p, get_text_colour(), annotation_height, left, right, y, base_colour); - y += _row_height; + y += row_height_; - _visible_rows.push_back(rows[i]); + visible_rows_.push_back(rows[i]); } } @@ -232,11 +232,11 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) (void)right; - assert(_row_height); + assert(row_height_); - for (size_t i = 0; i < _visible_rows.size(); i++) + for (size_t i = 0; i < visible_rows_.size(); i++) { - const int y = i * _row_height + get_visual_y(); + const int y = i * row_height_ + get_visual_y(); p.setPen(QPen(Qt::NoPen)); p.setBrush(QApplication::palette().brush(QPalette::WindowText)); @@ -251,9 +251,9 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) p.drawPolygon(points, countof(points)); } - const QRect r(left + ArrowSize * 2, y - _row_height / 2, - right - left, _row_height); - const QString h(_visible_rows[i].title()); + const QRect r(left + ArrowSize * 2, y - row_height_ / 2, + right - left, row_height_); + const QString h(visible_rows_[i].title()); const int f = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip; @@ -276,17 +276,17 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) assert(form); assert(parent); - assert(_decoder_stack); + assert(decoder_stack_); // Add the standard options Trace::populate_popup_form(parent, form); // Add the decoder options - _bindings.clear(); - _channel_selectors.clear(); - _decoder_forms.clear(); + bindings_.clear(); + channel_selectors_.clear(); + decoder_forms_.clear(); - const list< shared_ptr >& stack = _decoder_stack->stack(); + const list< shared_ptr >& stack = decoder_stack_->stack(); if (stack.empty()) { @@ -469,12 +469,12 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, double samples_per_pixel, pixels_offset; - assert(_decoder_stack); + assert(decoder_stack_); shared_ptr data; shared_ptr logic_signal; - const list< shared_ptr > &stack = _decoder_stack->stack(); + const list< shared_ptr > &stack = decoder_stack_->stack(); // We get the logic data of the first channel in the list. // This works because we are currently assuming all @@ -495,7 +495,7 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, if (sample_count == 0) return; - const int64_t samples_decoded = _decoder_stack->samples_decoded(); + const int64_t samples_decoded = decoder_stack_->samples_decoded(); if (sample_count == samples_decoded) return; @@ -521,19 +521,19 @@ void DecodeTrace::draw_unresolved_period(QPainter &p, int h, int left, pair DecodeTrace::get_pixels_offset_samples_per_pixel() const { - assert(_owner); - assert(_decoder_stack); + assert(owner_); + assert(decoder_stack_); - const View *view = _owner->view(); + const View *view = owner_->view(); assert(view); const double scale = view->scale(); assert(scale > 0); const double pixels_offset = - (view->offset() - _decoder_stack->get_start_time()) / scale; + (view->offset() - decoder_stack_->get_start_time()) / scale; - double samplerate = _decoder_stack->samplerate(); + double samplerate = decoder_stack_->samplerate(); // Show sample rate as 1Hz when it is unknown if (samplerate == 0.0) @@ -559,12 +559,12 @@ pair DecodeTrace::get_sample_range( int DecodeTrace::get_row_at_point(const QPoint &point) { - if (!_row_height) + if (!row_height_) return -1; - const int row = (point.y() - get_visual_y() + _row_height / 2) / - _row_height; - if (row < 0 || row >= (int)_visible_rows.size()) + const int row = (point.y() - get_visual_y() + row_height_ / 2) / + row_height_; + if (row < 0 || row >= (int)visible_rows_.size()) return -1; return row; @@ -585,8 +585,8 @@ const QString DecodeTrace::get_annotation_at_point(const QPoint &point) vector annotations; - assert(_decoder_stack); - _decoder_stack->get_annotation_subset(annotations, _visible_rows[row], + assert(decoder_stack_); + decoder_stack_->get_annotation_subset(annotations, visible_rows_[row], sample_range.first, sample_range.second); return (annotations.empty()) ? @@ -600,16 +600,16 @@ void DecodeTrace::hide_hover_annotation() void DecodeTrace::hover_point_changed() { - assert(_owner); + assert(owner_); - const View *const view = _owner->view(); + const View *const view = owner_->view(); assert(view); QPoint hp = view->hover_point(); QString ann = get_annotation_at_point(hp); assert(view); - assert(_row_height); + assert(row_height_); if (ann.isEmpty()) { hide_hover_annotation(); @@ -631,9 +631,9 @@ void DecodeTrace::hover_point_changed() // decode trace, not below. hp.setX(hp.x() - (text_size.width() / 2) - padding); - hp.setY(get_visual_y() - (_row_height / 2) + - (hover_row * _row_height) - - _row_height - text_size.height()); + hp.setY(get_visual_y() - (row_height_ / 2) + + (hover_row * row_height_) - + row_height_ - text_size.height()); QToolTip::showText(view->viewport()->mapToGlobal(hp), ann); } @@ -653,12 +653,12 @@ void DecodeTrace::create_decoder_form(int index, QString::fromUtf8(decoder->name)); group->set_decoder_visible(dec->shown()); - _delete_mapper.setMapping(group, index); - connect(group, SIGNAL(delete_decoder()), &_delete_mapper, SLOT(map())); + delete_mapper_.setMapping(group, index); + connect(group, SIGNAL(delete_decoder()), &delete_mapper_, SLOT(map())); - _show_hide_mapper.setMapping(group, index); + show_hide_mapper_.setMapping(group, index); connect(group, SIGNAL(show_hide_decoder()), - &_show_hide_mapper, SLOT(map())); + &show_hide_mapper_, SLOT(map())); QFormLayout *const decoder_form = new QFormLayout; group->add_layout(decoder_form); @@ -675,7 +675,7 @@ void DecodeTrace::create_decoder_form(int index, .arg(QString::fromUtf8(pdch->desc)), combo); const ChannelSelector s = {combo, dec, pdch}; - _channel_selectors.push_back(s); + channel_selectors_.push_back(s); } // Add the optional channels @@ -690,18 +690,18 @@ void DecodeTrace::create_decoder_form(int index, .arg(QString::fromUtf8(pdch->desc)), combo); const ChannelSelector s = {combo, dec, pdch}; - _channel_selectors.push_back(s); + channel_selectors_.push_back(s); } // Add the options shared_ptr binding( - new prop::binding::DecoderOptions(_decoder_stack, dec)); + new prop::binding::DecoderOptions(decoder_stack_, dec)); binding->add_properties_to_form(decoder_form, true); - _bindings.push_back(binding); + bindings_.push_back(binding); form->addRow(group); - _decoder_forms.push_back(group); + decoder_forms_.push_back(group); } QComboBox* DecodeTrace::create_channel_selector( @@ -710,10 +710,10 @@ QComboBox* DecodeTrace::create_channel_selector( { assert(dec); - shared_lock lock(_session.signals_mutex()); - const vector< shared_ptr > &sigs(_session.signals()); + shared_lock lock(session_.signals_mutex()); + const vector< shared_ptr > &sigs(session_.signals()); - assert(_decoder_stack); + assert(decoder_stack_); const auto channel_iter = dec->channels().find(pdch); QComboBox *selector = new QComboBox(parent); @@ -745,21 +745,21 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec map > channel_map; - shared_lock lock(_session.signals_mutex()); - const vector< shared_ptr > &sigs(_session.signals()); + shared_lock lock(session_.signals_mutex()); + const vector< shared_ptr > &sigs(session_.signals()); - for (const ChannelSelector &s : _channel_selectors) + for (const ChannelSelector &s : channel_selectors_) { - if(s._decoder != dec) + if(s.decoder_ != dec) break; const LogicSignal *const selection = - (LogicSignal*)s._combo->itemData( - s._combo->currentIndex()).value(); + (LogicSignal*)s.combo_->itemData( + s.combo_->currentIndex()).value(); for (shared_ptr sig : sigs) if(sig.get() == selection) { - channel_map[s._pdch] = + channel_map[s.pdch_] = dynamic_pointer_cast(sig); break; } @@ -770,17 +770,17 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec void DecodeTrace::commit_channels() { - assert(_decoder_stack); - for (shared_ptr dec : _decoder_stack->stack()) + assert(decoder_stack_); + for (shared_ptr dec : decoder_stack_->stack()) commit_decoder_channels(dec); - _decoder_stack->begin_decode(); + decoder_stack_->begin_decode(); } void DecodeTrace::on_new_decode_data() { - if (_owner) - _owner->appearance_changed(false, true); + if (owner_) + owner_->appearance_changed(false, true); } void DecodeTrace::delete_pressed() @@ -790,7 +790,7 @@ void DecodeTrace::delete_pressed() void DecodeTrace::on_delete() { - _session.remove_decode_signal(this); + session_.remove_decode_signal(this); } void DecodeTrace::on_channel_selected(int) @@ -801,29 +801,29 @@ void DecodeTrace::on_channel_selected(int) void DecodeTrace::on_stack_decoder(srd_decoder *decoder) { assert(decoder); - assert(_decoder_stack); - _decoder_stack->push(shared_ptr( + assert(decoder_stack_); + decoder_stack_->push(shared_ptr( new data::decode::Decoder(decoder))); - _decoder_stack->begin_decode(); + decoder_stack_->begin_decode(); create_popup_form(); } void DecodeTrace::on_delete_decoder(int index) { - _decoder_stack->remove(index); + decoder_stack_->remove(index); // Update the popup create_popup_form(); - _decoder_stack->begin_decode(); + decoder_stack_->begin_decode(); } void DecodeTrace::on_show_hide_decoder(int index) { using pv::data::decode::Decoder; - const list< shared_ptr > stack(_decoder_stack->stack()); + const list< shared_ptr > stack(decoder_stack_->stack()); // Find the decoder in the stack auto iter = stack.cbegin(); @@ -836,11 +836,11 @@ void DecodeTrace::on_show_hide_decoder(int index) const bool show = !dec->shown(); dec->show(show); - assert(index < (int)_decoder_forms.size()); - _decoder_forms[index]->set_decoder_visible(show); + assert(index < (int)decoder_forms_.size()); + decoder_forms_[index]->set_decoder_visible(show); - if (_owner) - _owner->appearance_changed(false, true); + if (owner_) + owner_->appearance_changed(false, true); } } // namespace view diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index 2bb11541..9704f69a 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -64,9 +64,9 @@ class DecodeTrace : public Trace private: struct ChannelSelector { - const QComboBox *_combo; - const std::shared_ptr _decoder; - const srd_channel *_pdch; + const QComboBox *combo_; + const std::shared_ptr decoder_; + const srd_channel *pdch_; }; private: @@ -192,21 +192,21 @@ private Q_SLOTS: void on_show_hide_decoder(int index); private: - pv::SigSession &_session; - std::shared_ptr _decoder_stack; + pv::SigSession &session_; + std::shared_ptr decoder_stack_; - uint64_t _decode_start, _decode_end; + uint64_t decode_start_, decode_end_; std::list< std::shared_ptr > - _bindings; + bindings_; - std::list _channel_selectors; - std::vector _decoder_forms; + std::list channel_selectors_; + std::vector decoder_forms_; - std::vector _visible_rows; - int _text_height, _row_height; + std::vector visible_rows_; + int text_height_, row_height_; - QSignalMapper _delete_mapper, _show_hide_mapper; + QSignalMapper delete_mapper_, show_hide_mapper_; }; } // namespace view diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 7be491a9..1dee05f4 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -61,19 +61,19 @@ static bool item_selected(shared_ptr r) Header::Header(View &parent) : MarginWidget(parent), - _dragging(false) + dragging_(false) { setFocusPolicy(Qt::ClickFocus); setMouseTracking(true); - connect(&_view, SIGNAL(signals_moved()), + connect(&view_, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); } QSize Header::sizeHint() const { QRectF max_rect(-Padding, 0, Padding, 0); - for (auto &i : _view) + for (auto &i : view_) if (i->enabled()) max_rect = max_rect.united(i->label_rect(0)); return QSize(max_rect.width() + Padding + BaselineOffset, 0); @@ -82,7 +82,7 @@ QSize Header::sizeHint() const shared_ptr Header::get_mouse_over_row_item(const QPoint &pt) { const int w = width() - BaselineOffset; - for (auto &i : _view) + for (auto &i : view_) if (i->enabled() && i->label_rect(w).contains(pt)) return i; return shared_ptr(); @@ -90,7 +90,7 @@ shared_ptr Header::get_mouse_over_row_item(const QPoint &pt) void Header::clear_selection() { - for (auto &i : _view) + for (auto &i : view_) i->select(false); update(); } @@ -99,7 +99,7 @@ void Header::show_popup(const shared_ptr &item) { using pv::widgets::Popup; - Popup *const p = item->create_popup(&_view); + Popup *const p = item->create_popup(&view_); if (!p) return; @@ -116,7 +116,7 @@ void Header::paintEvent(QPaintEvent*) const int w = width() - BaselineOffset; vector< shared_ptr > row_items( - _view.begin(), _view.end()); + view_.begin(), view_.end()); stable_sort(row_items.begin(), row_items.end(), [](const shared_ptr &a, const shared_ptr &b) { @@ -129,8 +129,8 @@ void Header::paintEvent(QPaintEvent*) { assert(r); - const bool highlight = !_dragging && - r->label_rect(w).contains(_mouse_point); + const bool highlight = !dragging_ && + r->label_rect(w).contains(mouse_point_); r->paint_label(painter, w, highlight); } @@ -145,21 +145,21 @@ void Header::mouseLeftPressEvent(QMouseEvent *event) QApplication::keyboardModifiers() & Qt::ControlModifier; // Clear selection if control is not pressed and this item is unselected - if ((!_mouse_down_item || !_mouse_down_item->selected()) && + if ((!mouse_down_item_ || !mouse_down_item_->selected()) && !ctrl_pressed) - for (shared_ptr r : _view) + for (shared_ptr r : view_) r->select(false); // Set the signal selection state if the item has been clicked - if (_mouse_down_item) { + if (mouse_down_item_) { if (ctrl_pressed) - _mouse_down_item->select(!_mouse_down_item->selected()); + mouse_down_item_->select(!mouse_down_item_->selected()); else - _mouse_down_item->select(true); + mouse_down_item_->select(true); } // Save the offsets of any signals which will be dragged - for (const shared_ptr r : _view) + for (const shared_ptr r : view_) if (r->selected()) r->drag(); @@ -171,8 +171,8 @@ void Header::mousePressEvent(QMouseEvent *event) { assert(event); - _mouse_down_point = event->pos(); - _mouse_down_item = get_mouse_over_row_item(event->pos()); + mouse_down_point_ = event->pos(); + mouse_down_item_ = get_mouse_over_row_item(event->pos()); if (event->button() & Qt::LeftButton) mouseLeftPressEvent(event); @@ -189,24 +189,24 @@ void Header::mouseLeftReleaseEvent(QMouseEvent *event) const shared_ptr mouse_over = get_mouse_over_row_item(event->pos()); - for (auto &r : _view) + for (auto &r : view_) r->drag_release(); - if (_dragging) - _view.restack_all_row_items(); + if (dragging_) + view_.restack_all_row_items(); else { if (!ctrl_pressed) { - for (shared_ptr r : _view) - if (_mouse_down_item != r) + for (shared_ptr r : view_) + if (mouse_down_item_ != r) r->select(false); - if (_mouse_down_item) - show_popup(_mouse_down_item); + if (mouse_down_item_) + show_popup(mouse_down_item_); } } - _dragging = false; + dragging_ = false; } void Header::mouseReleaseEvent(QMouseEvent *event) @@ -215,24 +215,24 @@ void Header::mouseReleaseEvent(QMouseEvent *event) if (event->button() & Qt::LeftButton) mouseLeftReleaseEvent(event); - _mouse_down_item = nullptr; + mouse_down_item_ = nullptr; } void Header::mouseMoveEvent(QMouseEvent *event) { assert(event); - _mouse_point = event->pos(); + mouse_point_ = event->pos(); if (!(event->buttons() & Qt::LeftButton)) return; - if ((event->pos() - _mouse_down_point).manhattanLength() < + if ((event->pos() - mouse_down_point_).manhattanLength() < QApplication::startDragDistance()) return; // Check all the drag items share a common owner RowItemOwner *item_owner = nullptr; - for (shared_ptr r : _view) + for (shared_ptr r : view_) if (r->dragging()) { if (!item_owner) item_owner = r->owner(); @@ -244,11 +244,11 @@ void Header::mouseMoveEvent(QMouseEvent *event) return; // Do the drag - _dragging = true; + dragging_ = true; - const int delta = event->pos().y() - _mouse_down_point.y(); + const int delta = event->pos().y() - mouse_down_point_.y(); - for (std::shared_ptr r : _view) + for (std::shared_ptr r : view_) if (r->dragging()) { r->force_to_v_offset(r->drag_point().y() + delta); @@ -266,13 +266,13 @@ void Header::mouseMoveEvent(QMouseEvent *event) void Header::leaveEvent(QEvent*) { - _mouse_point = QPoint(-1, -1); + mouse_point_ = QPoint(-1, -1); update(); } void Header::contextMenuEvent(QContextMenuEvent *event) { - const shared_ptr r = get_mouse_over_row_item(_mouse_point); + const shared_ptr r = get_mouse_over_row_item(mouse_point_); if (!r) return; @@ -280,7 +280,7 @@ void Header::contextMenuEvent(QContextMenuEvent *event) if (!menu) menu = new QMenu(this); - if (std::count_if(_view.begin(), _view.end(), item_selected) > 1) + if (std::count_if(view_.begin(), view_.end(), item_selected) > 1) { menu->addSeparator(); @@ -301,7 +301,7 @@ void Header::keyPressEvent(QKeyEvent *e) if (e->key() == Qt::Key_Delete) { - for (const shared_ptr r : _view) + for (const shared_ptr r : view_) if (r->selected()) r->delete_pressed(); } @@ -319,15 +319,15 @@ void Header::on_signals_moved() void Header::on_group() { vector< shared_ptr > selected_items( - make_filter_iterator(item_selected, _view.begin(), _view.end()), - make_filter_iterator(item_selected, _view.end(), _view.end())); + make_filter_iterator(item_selected, view_.begin(), view_.end()), + make_filter_iterator(item_selected, view_.end(), view_.end())); stable_sort(selected_items.begin(), selected_items.end(), [](const shared_ptr &a, const shared_ptr &b) { return a->visual_v_offset() < b->visual_v_offset(); }); shared_ptr group(new TraceGroup()); shared_ptr focus_item( - _mouse_down_item ? _mouse_down_item : selected_items.front()); + mouse_down_item_ ? mouse_down_item_ : selected_items.front()); assert(focus_item); assert(focus_item->owner()); @@ -354,7 +354,7 @@ void Header::on_ungroup() bool restart; do { restart = false; - for (const shared_ptr r : _view) { + for (const shared_ptr r : view_) { const shared_ptr tg = dynamic_pointer_cast(r); if (tg && tg->selected()) { diff --git a/pv/view/header.h b/pv/view/header.h index 541430ab..49a95bb7 100644 --- a/pv/view/header.h +++ b/pv/view/header.h @@ -88,10 +88,10 @@ Q_SIGNALS: void signals_moved(); private: - QPoint _mouse_point; - QPoint _mouse_down_point; - std::shared_ptr _mouse_down_item; - bool _dragging; + QPoint mouse_point_; + QPoint mouse_down_point_; + std::shared_ptr mouse_down_item_; + bool dragging_; }; } // namespace view diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 75a125a7..1b873e24 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -87,27 +87,27 @@ LogicSignal::LogicSignal( shared_ptr channel, shared_ptr data) : Signal(session, channel), - _device(device), - _data(data), - _trigger_none(NULL), - _trigger_rising(NULL), - _trigger_high(NULL), - _trigger_falling(NULL), - _trigger_low(NULL), - _trigger_change(NULL) + device_(device), + data_(data), + trigger_none_(NULL), + trigger_rising_(NULL), + trigger_high_(NULL), + trigger_falling_(NULL), + trigger_low_(NULL), + trigger_change_(NULL) { shared_ptr trigger; - _colour = SignalColours[channel->index() % countof(SignalColours)]; + colour_ = SignalColours[channel->index() % countof(SignalColours)]; /* Populate this channel's trigger setting with whatever we * find in the current session trigger, if anything. */ - _trigger_match = nullptr; - if ((trigger = _session.session()->trigger())) + trigger_match_ = nullptr; + if ((trigger = session_.session()->trigger())) for (auto stage : trigger->stages()) for (auto match : stage->matches()) - if (match->channel() == _channel) - _trigger_match = match->type(); + if (match->channel() == channel_) + trigger_match_ = match->type(); } LogicSignal::~LogicSignal() @@ -116,12 +116,12 @@ LogicSignal::~LogicSignal() shared_ptr LogicSignal::data() const { - return _data; + return data_; } shared_ptr LogicSignal::logic_data() const { - return _data; + return data_; } std::pair LogicSignal::v_extents() const @@ -131,7 +131,7 @@ std::pair LogicSignal::v_extents() const void LogicSignal::paint_back(QPainter &p, int left, int right) { - if (_channel->enabled()) + if (channel_->enabled()) paint_axis(p, get_visual_y(), left, right); } @@ -143,14 +143,14 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) vector< pair > edges; - assert(_channel); - assert(_data); + assert(channel_); + assert(data_); assert(right >= left); - assert(_owner); + assert(owner_); const int y = get_visual_y(); - const View *const view = _owner->view(); + const View *const view = owner_->view(); assert(view); const double scale = view->scale(); @@ -158,28 +158,28 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) const double offset = view->offset(); - if (!_channel->enabled()) + if (!channel_->enabled()) return; const float high_offset = y - SignalHeight + 0.5f; const float low_offset = y + 0.5f; const deque< shared_ptr > &snapshots = - _data->get_snapshots(); + data_->get_snapshots(); if (snapshots.empty()) return; const shared_ptr &snapshot = snapshots.front(); - double samplerate = _data->samplerate(); + double samplerate = data_->samplerate(); // Show sample rate as 1Hz when it is unknown if (samplerate == 0.0) samplerate = 1.0; const double pixels_offset = offset / scale; - const double start_time = _data->get_start_time(); + const double start_time = data_->get_start_time(); const int64_t last_sample = snapshot->get_sample_count() - 1; const double samples_per_pixel = samplerate * scale; const double start = samplerate * (offset - start_time); @@ -188,7 +188,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right) snapshot->get_subsampled_edges(edges, min(max((int64_t)floor(start), (int64_t)0), last_sample), min(max((int64_t)ceil(end), (int64_t)0), last_sample), - samples_per_pixel / Oversampling, _channel->index()); + samples_per_pixel / Oversampling, channel_->index()); assert(edges.size() >= 2); // Paint the edges @@ -241,58 +241,58 @@ void LogicSignal::paint_caps(QPainter &p, QLineF *const lines, void LogicSignal::init_trigger_actions(QWidget *parent) { - _trigger_none = new QAction(QIcon(":/icons/trigger-none.svg"), + trigger_none_ = new QAction(QIcon(":/icons/trigger-none.svg"), tr("No trigger"), parent); - _trigger_none->setCheckable(true); - connect(_trigger_none, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_none_->setCheckable(true); + connect(trigger_none_, SIGNAL(triggered()), this, SLOT(on_trigger())); - _trigger_rising = new QAction(QIcon(":/icons/trigger-rising.svg"), + trigger_rising_ = new QAction(QIcon(":/icons/trigger-rising.svg"), tr("Trigger on rising edge"), parent); - _trigger_rising->setCheckable(true); - connect(_trigger_rising, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_rising_->setCheckable(true); + connect(trigger_rising_, SIGNAL(triggered()), this, SLOT(on_trigger())); - _trigger_high = new QAction(QIcon(":/icons/trigger-high.svg"), + trigger_high_ = new QAction(QIcon(":/icons/trigger-high.svg"), tr("Trigger on high level"), parent); - _trigger_high->setCheckable(true); - connect(_trigger_high, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_high_->setCheckable(true); + connect(trigger_high_, SIGNAL(triggered()), this, SLOT(on_trigger())); - _trigger_falling = new QAction(QIcon(":/icons/trigger-falling.svg"), + trigger_falling_ = new QAction(QIcon(":/icons/trigger-falling.svg"), tr("Trigger on falling edge"), parent); - _trigger_falling->setCheckable(true); - connect(_trigger_falling, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_falling_->setCheckable(true); + connect(trigger_falling_, SIGNAL(triggered()), this, SLOT(on_trigger())); - _trigger_low = new QAction(QIcon(":/icons/trigger-low.svg"), + trigger_low_ = new QAction(QIcon(":/icons/trigger-low.svg"), tr("Trigger on low level"), parent); - _trigger_low->setCheckable(true); - connect(_trigger_low, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_low_->setCheckable(true); + connect(trigger_low_, SIGNAL(triggered()), this, SLOT(on_trigger())); - _trigger_change = new QAction(QIcon(":/icons/trigger-change.svg"), + trigger_change_ = new QAction(QIcon(":/icons/trigger-change.svg"), tr("Trigger on rising or falling edge"), parent); - _trigger_change->setCheckable(true); - connect(_trigger_change, SIGNAL(triggered()), this, SLOT(on_trigger())); + trigger_change_->setCheckable(true); + connect(trigger_change_, SIGNAL(triggered()), this, SLOT(on_trigger())); } QAction* LogicSignal::match_action(const TriggerMatchType *type) { QAction *action; - action = _trigger_none; + action = trigger_none_; if (type) { switch (type->id()) { case SR_TRIGGER_ZERO: - action = _trigger_low; + action = trigger_low_; break; case SR_TRIGGER_ONE: - action = _trigger_high; + action = trigger_high_; break; case SR_TRIGGER_RISING: - action = _trigger_rising; + action = trigger_rising_; break; case SR_TRIGGER_FALLING: - action = _trigger_falling; + action = trigger_falling_; break; case SR_TRIGGER_EDGE: - action = _trigger_change; + action = trigger_change_; break; default: assert(0); @@ -304,15 +304,15 @@ QAction* LogicSignal::match_action(const TriggerMatchType *type) const TriggerMatchType *LogicSignal::action_match(QAction *action) { - if (action == _trigger_low) + if (action == trigger_low_) return TriggerMatchType::ZERO; - else if (action == _trigger_high) + else if (action == trigger_high_) return TriggerMatchType::ONE; - else if (action == _trigger_rising) + else if (action == trigger_rising_) return TriggerMatchType::RISING; - else if (action == _trigger_falling) + else if (action == trigger_falling_) return TriggerMatchType::FALLING; - else if (action == _trigger_change) + else if (action == trigger_change_) return TriggerMatchType::EDGE; else return nullptr; @@ -326,53 +326,53 @@ void LogicSignal::populate_popup_form(QWidget *parent, QFormLayout *form) Signal::populate_popup_form(parent, form); try { - gvar = _device->config_list(ConfigKey::TRIGGER_MATCH); + gvar = device_->config_list(ConfigKey::TRIGGER_MATCH); } catch (Error e) { return; } - _trigger_bar = new QToolBar(parent); - init_trigger_actions(_trigger_bar); - _trigger_bar->addAction(_trigger_none); - _trigger_none->setChecked(!_trigger_match); + trigger_bar_ = new QToolBar(parent); + init_trigger_actions(trigger_bar_); + trigger_bar_->addAction(trigger_none_); + trigger_none_->setChecked(!trigger_match_); trig_types = Glib::VariantBase::cast_dynamic>>( gvar).get(); for (auto type_id : trig_types) { auto type = TriggerMatchType::get(type_id); - _trigger_bar->addAction(match_action(type)); - match_action(type)->setChecked(_trigger_match == type); + trigger_bar_->addAction(match_action(type)); + match_action(type)->setChecked(trigger_match_ == type); } - form->addRow(tr("Trigger"), _trigger_bar); + form->addRow(tr("Trigger"), trigger_bar_); } void LogicSignal::modify_trigger() { - auto trigger = _session.session()->trigger(); - auto new_trigger = _session.device_manager().context()->create_trigger("pulseview"); + auto trigger = session_.session()->trigger(); + auto new_trigger = session_.device_manager().context()->create_trigger("pulseview"); if (trigger) { for (auto stage : trigger->stages()) { const auto &matches = stage->matches(); if (std::none_of(begin(matches), end(matches), [&](shared_ptr match) { - return match->channel() != _channel; })) + return match->channel() != channel_; })) continue; auto new_stage = new_trigger->add_stage(); for (auto match : stage->matches()) { - if (match->channel() == _channel) + if (match->channel() == channel_) continue; new_stage->add_match(match->channel(), match->type()); } } } - if (_trigger_match) - new_trigger->add_stage()->add_match(_channel, _trigger_match); + if (trigger_match_) + new_trigger->add_stage()->add_match(channel_, trigger_match_); - _session.session()->set_trigger( + session_.session()->set_trigger( new_trigger->stages().empty() ? nullptr : new_trigger); } @@ -380,11 +380,11 @@ void LogicSignal::on_trigger() { QAction *action; - match_action(_trigger_match)->setChecked(false); + match_action(trigger_match_)->setChecked(false); action = (QAction *)sender(); action->setChecked(true); - _trigger_match = action_match(action); + trigger_match_ = action_match(action); modify_trigger(); } diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h index a275f177..79bbe396 100644 --- a/pv/view/logicsignal.h +++ b/pv/view/logicsignal.h @@ -107,17 +107,17 @@ private Q_SLOTS: void on_trigger(); private: - std::shared_ptr _device; - std::shared_ptr _data; - - const sigrok::TriggerMatchType *_trigger_match; - QToolBar *_trigger_bar; - QAction *_trigger_none; - QAction *_trigger_rising; - QAction *_trigger_high; - QAction *_trigger_falling; - QAction *_trigger_low; - QAction *_trigger_change; + std::shared_ptr device_; + std::shared_ptr data_; + + const sigrok::TriggerMatchType *trigger_match_; + QToolBar *trigger_bar_; + QAction *trigger_none_; + QAction *trigger_rising_; + QAction *trigger_high_; + QAction *trigger_falling_; + QAction *trigger_low_; + QAction *trigger_change_; }; } // namespace view diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index 7df80308..179e82b9 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -27,7 +27,7 @@ namespace view { MarginWidget::MarginWidget(View &parent) : QWidget(&parent), - _view(parent) + view_(parent) { setAttribute(Qt::WA_NoSystemBackground, true); } diff --git a/pv/view/marginwidget.h b/pv/view/marginwidget.h index 88014c76..9ff4276b 100644 --- a/pv/view/marginwidget.h +++ b/pv/view/marginwidget.h @@ -42,7 +42,7 @@ Q_SIGNALS: void selection_changed(); protected: - pv::view::View &_view; + pv::view::View &view_; }; } // namespace view diff --git a/pv/view/rowitem.cpp b/pv/view/rowitem.cpp index 7bf52124..29346023 100644 --- a/pv/view/rowitem.cpp +++ b/pv/view/rowitem.cpp @@ -28,91 +28,91 @@ namespace pv { namespace view { RowItem::RowItem() : - _owner(NULL), - _layout_v_offset(0), - _visual_v_offset(0), - _v_offset_animation(this, "visual_v_offset") + owner_(NULL), + layout_v_offset_(0), + visual_v_offset_(0), + v_offset_animation_(this, "visual_v_offset") { } int RowItem::layout_v_offset() const { - return _layout_v_offset; + return layout_v_offset_; } void RowItem::set_layout_v_offset(int v_offset) { - if (_layout_v_offset == v_offset) + if (layout_v_offset_ == v_offset) return; - _layout_v_offset = v_offset; + layout_v_offset_ = v_offset; - if (_owner) - _owner->extents_changed(false, true); + if (owner_) + owner_->extents_changed(false, true); } int RowItem::visual_v_offset() const { - return _visual_v_offset; + return visual_v_offset_; } void RowItem::set_visual_v_offset(int v_offset) { - _visual_v_offset = v_offset; + visual_v_offset_ = v_offset; - if (_owner) - _owner->appearance_changed(true, true); + if (owner_) + owner_->appearance_changed(true, true); } void RowItem::force_to_v_offset(int v_offset) { - _v_offset_animation.stop(); - _layout_v_offset = _visual_v_offset = v_offset; + v_offset_animation_.stop(); + layout_v_offset_ = visual_v_offset_ = v_offset; } void RowItem::animate_to_layout_v_offset() { - if (_visual_v_offset == _layout_v_offset || - (_v_offset_animation.endValue() == _layout_v_offset && - _v_offset_animation.state() == QAbstractAnimation::Running)) + if (visual_v_offset_ == layout_v_offset_ || + (v_offset_animation_.endValue() == layout_v_offset_ && + v_offset_animation_.state() == QAbstractAnimation::Running)) return; - _v_offset_animation.setDuration(100); - _v_offset_animation.setStartValue(_visual_v_offset); - _v_offset_animation.setEndValue(_layout_v_offset); - _v_offset_animation.setEasingCurve(QEasingCurve::OutQuad); - _v_offset_animation.start(); + v_offset_animation_.setDuration(100); + v_offset_animation_.setStartValue(visual_v_offset_); + v_offset_animation_.setEndValue(layout_v_offset_); + v_offset_animation_.setEasingCurve(QEasingCurve::OutQuad); + v_offset_animation_.start(); } RowItemOwner* RowItem::owner() const { - return _owner; + return owner_; } void RowItem::set_owner(RowItemOwner *owner) { - assert(_owner || owner); - _v_offset_animation.stop(); + assert(owner_ || owner); + v_offset_animation_.stop(); - if (_owner) { - const int owner_offset = _owner->owner_visual_v_offset(); - _layout_v_offset += owner_offset; - _visual_v_offset += owner_offset; + if (owner_) { + const int owner_offset = owner_->owner_visual_v_offset(); + layout_v_offset_ += owner_offset; + visual_v_offset_ += owner_offset; } - _owner = owner; + owner_ = owner; - if (_owner) { - const int owner_offset = _owner->owner_visual_v_offset(); - _layout_v_offset -= owner_offset; - _visual_v_offset -= owner_offset; + if (owner_) { + const int owner_offset = owner_->owner_visual_v_offset(); + layout_v_offset_ -= owner_offset; + visual_v_offset_ -= owner_offset; } } int RowItem::get_visual_y() const { - assert(_owner); - return _visual_v_offset + _owner->owner_visual_v_offset(); + assert(owner_); + return visual_v_offset_ + owner_->owner_visual_v_offset(); } QPoint RowItem::point() const diff --git a/pv/view/rowitem.h b/pv/view/rowitem.h index f2e6a66e..db6e580d 100644 --- a/pv/view/rowitem.h +++ b/pv/view/rowitem.h @@ -154,13 +154,13 @@ public: virtual void hover_point_changed(); protected: - pv::view::RowItemOwner *_owner; + pv::view::RowItemOwner *owner_; - int _layout_v_offset; - int _visual_v_offset; + int layout_v_offset_; + int visual_v_offset_; private: - QPropertyAnimation _v_offset_animation; + QPropertyAnimation v_offset_animation_; }; } // namespace view diff --git a/pv/view/rowitemiterator.h b/pv/view/rowitemiterator.h index 256cdd09..178677a2 100644 --- a/pv/view/rowitemiterator.h +++ b/pv/view/rowitemiterator.h @@ -51,24 +51,24 @@ public: public: RowItemIterator(Owner *owner) : - _owner(owner), - _lock(owner->session().signals_mutex()) {} + owner_(owner), + lock_(owner->session().signals_mutex()) {} RowItemIterator(Owner *owner, child_iterator iter) : - _owner(owner), - _lock(owner->session().signals_mutex()) { + owner_(owner), + lock_(owner->session().signals_mutex()) { assert(owner); if (iter != owner->child_items().end()) - _iter_stack.push(iter); + iter_stack_.push(iter); } RowItemIterator(const RowItemIterator &o) : - _owner(o._owner), - _lock(*o._lock.mutex()), - _iter_stack(o._iter_stack) {} + owner_(o.owner_), + lock_(*o.lock_.mutex()), + iter_stack_(o.iter_stack_) {} reference operator*() const { - return *_iter_stack.top(); + return *iter_stack_.top(); } reference operator->() const { @@ -79,21 +79,21 @@ public: using std::dynamic_pointer_cast; using std::shared_ptr; - assert(_owner); - assert(!_iter_stack.empty()); + assert(owner_); + assert(!iter_stack_.empty()); shared_ptr owner(dynamic_pointer_cast( - *_iter_stack.top())); + *iter_stack_.top())); if (owner && !owner->child_items().empty()) { - _owner = owner.get(); - _iter_stack.push(owner->child_items().begin()); + owner_ = owner.get(); + iter_stack_.push(owner->child_items().begin()); } else { - ++_iter_stack.top(); - while (_owner && _iter_stack.top() == - _owner->child_items().end()) { - _iter_stack.pop(); - _owner = _iter_stack.empty() ? nullptr : - (*_iter_stack.top()++)->owner(); + ++iter_stack_.top(); + while (owner_ && iter_stack_.top() == + owner_->child_items().end()) { + iter_stack_.pop(); + owner_ = iter_stack_.empty() ? nullptr : + (*iter_stack_.top()++)->owner(); } } @@ -107,13 +107,13 @@ public: } bool operator==(const RowItemIterator &o) const { - return (_iter_stack.empty() && o._iter_stack.empty()) || - (_owner == o._owner && - _iter_stack.size() == o._iter_stack.size() && + return (iter_stack_.empty() && o.iter_stack_.empty()) || + (owner_ == o.owner_ && + iter_stack_.size() == o.iter_stack_.size() && std::equal( - _owner->child_items().cbegin(), - _owner->child_items().cend(), - o._owner->child_items().cbegin())); + owner_->child_items().cbegin(), + owner_->child_items().cend(), + o.owner_->child_items().cbegin())); } bool operator!=(const RowItemIterator &o) const { @@ -121,14 +121,14 @@ public: } void swap(RowItemIterator& other) { - swap(_owner, other._owner); - swap(_iter_stack, other._iter_stack); + swap(owner_, other.owner_); + swap(iter_stack_, other.iter_stack_); } private: - Owner *_owner; - boost::shared_lock _lock; - std::stack _iter_stack; + Owner *owner_; + boost::shared_lock lock_; + std::stack iter_stack_; }; template diff --git a/pv/view/rowitemowner.cpp b/pv/view/rowitemowner.cpp index a8bdadfa..6f7cbb26 100644 --- a/pv/view/rowitemowner.cpp +++ b/pv/view/rowitemowner.cpp @@ -35,28 +35,28 @@ namespace view { vector< shared_ptr >& RowItemOwner::child_items() { - return _items; + return items_; } const vector< shared_ptr >& RowItemOwner::child_items() const { - return _items; + return items_; } void RowItemOwner::clear_child_items() { - for (auto &i : _items) { + for (auto &i : items_) { assert(i->owner() == this); i->set_owner(nullptr); } - _items.clear(); + items_.clear(); } void RowItemOwner::add_child_item(std::shared_ptr item) { assert(!item->owner()); item->set_owner(this); - _items.push_back(item); + items_.push_back(item); extents_changed(true, true); } @@ -65,16 +65,16 @@ void RowItemOwner::remove_child_item(std::shared_ptr item) { assert(item->owner() == this); item->set_owner(nullptr); - auto iter = std::find(_items.begin(), _items.end(), item); - assert(iter != _items.end()); - _items.erase(iter); + auto iter = std::find(items_.begin(), items_.end(), item); + assert(iter != items_.end()); + items_.erase(iter); extents_changed(true, true); } RowItemOwner::iterator RowItemOwner::begin() { - return iterator(this, _items.begin()); + return iterator(this, items_.begin()); } RowItemOwner::iterator RowItemOwner::end() @@ -84,7 +84,7 @@ RowItemOwner::iterator RowItemOwner::end() RowItemOwner::const_iterator RowItemOwner::begin() const { - return const_iterator(this, _items.cbegin()); + return const_iterator(this, items_.cbegin()); } RowItemOwner::const_iterator RowItemOwner::end() const diff --git a/pv/view/rowitemowner.h b/pv/view/rowitemowner.h index 2295e963..3c568da4 100644 --- a/pv/view/rowitemowner.h +++ b/pv/view/rowitemowner.h @@ -132,7 +132,7 @@ public: virtual void extents_changed(bool horz, bool vert) = 0; private: - item_list _items; + item_list items_; }; } // view diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 3cc2eb17..d3e42df6 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -41,7 +41,7 @@ Ruler::Ruler(View &parent) : { setMouseTracking(true); - connect(&_view, SIGNAL(hover_point_changed()), + connect(&view_, SIGNAL(hover_point_changed()), this, SLOT(hover_point_changed())); } @@ -58,7 +58,7 @@ void Ruler::paintEvent(QPaintEvent*) p.setRenderHint(QPainter::Antialiasing); std::pair spacing = - calculate_tick_spacing(p, _view.scale(), _view.offset()); + calculate_tick_spacing(p, view_.scale(), view_.offset()); double tick_period = spacing.first; unsigned int prefix = spacing.second; @@ -71,9 +71,9 @@ void Ruler::paintEvent(QPaintEvent*) const double minor_tick_period = tick_period / MinorTickSubdivision; const double first_major_division = - floor(_view.offset() / tick_period); + floor(view_.offset() / tick_period); const double first_minor_division = - ceil(_view.offset() / minor_tick_period); + ceil(view_.offset() / minor_tick_period); const double t0 = first_major_division * tick_period; int division = (int)round(first_minor_division - @@ -87,7 +87,7 @@ void Ruler::paintEvent(QPaintEvent*) do { const double t = t0 + division * minor_tick_period; - x = (t - _view.offset()) / _view.scale(); + x = (t - view_.offset()) / view_.scale(); if (division % MinorTickSubdivision == 0) { @@ -115,7 +115,7 @@ void Ruler::paintEvent(QPaintEvent*) void Ruler::draw_hover_mark(QPainter &p) { - const int x = _view.hover_point().x(); + const int x = view_.hover_point().x(); if (x == -1) return; diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp index 6331575a..5987b3ec 100644 --- a/pv/view/selectableitem.cpp +++ b/pv/view/selectableitem.cpp @@ -32,45 +32,45 @@ namespace view { const int SelectableItem::HighlightRadius = 6; SelectableItem::SelectableItem() : - _context_parent(NULL), - _selected(false), - _drag_point(INT_MIN, INT_MIN) + context_parent_(NULL), + selected_(false), + drag_point_(INT_MIN, INT_MIN) { } bool SelectableItem::selected() const { - return _selected; + return selected_; } void SelectableItem::select(bool select) { - _selected = select; + selected_ = select; } bool SelectableItem::dragging() const { - return _drag_point.x() != INT_MIN && _drag_point.y() != INT_MIN; + return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN; } QPoint SelectableItem::drag_point() const { - return _drag_point; + return drag_point_; } void SelectableItem::drag() { - _drag_point = point(); + drag_point_ = point(); } void SelectableItem::drag_release() { - _drag_point = QPoint(INT_MIN, INT_MIN); + drag_point_ = QPoint(INT_MIN, INT_MIN); } QMenu* SelectableItem::create_context_menu(QWidget *parent) { - _context_parent = parent; + context_parent_ = parent; return new QMenu(parent); } diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h index d815bc70..36ff0dbc 100644 --- a/pv/view/selectableitem.h +++ b/pv/view/selectableitem.h @@ -94,11 +94,11 @@ protected: static QPen highlight_pen(); protected: - QWidget *_context_parent; + QWidget *context_parent_; private: - bool _selected; - QPoint _drag_point; + bool selected_; + QPoint drag_point_; }; } // namespace view diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 54c9c982..916801c9 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -61,63 +61,63 @@ const char *const ChannelNames[] = { Signal::Signal(pv::SigSession &session, std::shared_ptr channel) : Trace(channel->name().c_str()), - _session(session), - _channel(channel), - _name_widget(NULL), - _updating_name_widget(false) + session_(session), + channel_(channel), + name_widget_(NULL), + updating_name_widget_(false) { - assert(_channel); + assert(channel_); } void Signal::set_name(QString name) { Trace::set_name(name); - _updating_name_widget = true; - _name_widget->setEditText(name); - _updating_name_widget = false; + updating_name_widget_ = true; + name_widget_->setEditText(name); + updating_name_widget_ = false; } bool Signal::enabled() const { - return _channel->enabled(); + return channel_->enabled(); } void Signal::enable(bool enable) { - _channel->set_enabled(enable); + channel_->set_enabled(enable); - if (_owner) - _owner->extents_changed(true, true); + if (owner_) + owner_->extents_changed(true, true); } shared_ptr Signal::channel() const { - return _channel; + return channel_; } void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) { int index; - _name_widget = new QComboBox(parent); - _name_widget->setEditable(true); + name_widget_ = new QComboBox(parent); + name_widget_->setEditable(true); for(unsigned int i = 0; i < countof(ChannelNames); i++) - _name_widget->insertItem(i, ChannelNames[i]); + name_widget_->insertItem(i, ChannelNames[i]); - index = _name_widget->findText(_name, Qt::MatchExactly); + index = name_widget_->findText(name_, Qt::MatchExactly); if (index == -1) { - _name_widget->insertItem(0, _name); - _name_widget->setCurrentIndex(0); + name_widget_->insertItem(0, name_); + name_widget_->setCurrentIndex(0); } else { - _name_widget->setCurrentIndex(index); + name_widget_->setCurrentIndex(index); } - connect(_name_widget, SIGNAL(editTextChanged(const QString&)), + connect(name_widget_, SIGNAL(editTextChanged(const QString&)), this, SLOT(on_text_changed(const QString&))); - form->addRow(tr("Name"), _name_widget); + form->addRow(tr("Name"), name_widget_); add_colour_option(parent, form); } diff --git a/pv/view/signal.h b/pv/view/signal.h index b7666ee6..b3b591b2 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -79,11 +79,11 @@ private Q_SLOTS: void on_disable(); protected: - pv::SigSession &_session; - std::shared_ptr _channel; + pv::SigSession &session_; + std::shared_ptr channel_; - QComboBox *_name_widget; - bool _updating_name_widget; + QComboBox *name_widget_; + bool updating_name_widget_; }; } // namespace view diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 54342035..105bbc14 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -31,23 +31,23 @@ namespace pv { namespace view { TimeMarker::TimeMarker(View &view, const QColor &colour, double time) : - _view(view), - _colour(colour), - _time(time), - _value_action(NULL), - _value_widget(NULL), - _updating_value_widget(false) + view_(view), + colour_(colour), + time_(time), + value_action_(NULL), + value_widget_(NULL), + updating_value_widget_(false) { } double TimeMarker::time() const { - return _time; + return time_; } float TimeMarker::get_x() const { - return (_time - _view.offset()) / _view.scale(); + return (time_ - view_.offset()) / view_.scale(); } QPoint TimeMarker::point() const @@ -57,12 +57,12 @@ QPoint TimeMarker::point() const void TimeMarker::set_time(double time) { - _time = time; + time_ = time; - if (_value_widget) { - _updating_value_widget = true; - _value_widget->setValue(time); - _updating_value_widget = false; + if (value_widget_) { + updating_value_widget_ = true; + value_widget_->setValue(time); + updating_value_widget_ = false; } time_changed(); @@ -71,7 +71,7 @@ void TimeMarker::set_time(double time) void TimeMarker::paint(QPainter &p, const QRect &rect) { const float x = get_x(); - p.setPen(_colour); + p.setPen(colour_); p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom())); } @@ -83,24 +83,24 @@ pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent) QFormLayout *const form = new QFormLayout(popup); popup->setLayout(form); - _value_widget = new QDoubleSpinBox(parent); - _value_widget->setDecimals(9); - _value_widget->setSuffix("s"); - _value_widget->setSingleStep(1e-6); - _value_widget->setValue(_time); + value_widget_ = new QDoubleSpinBox(parent); + value_widget_->setDecimals(9); + value_widget_->setSuffix("s"); + value_widget_->setSingleStep(1e-6); + value_widget_->setValue(time_); - connect(_value_widget, SIGNAL(valueChanged(double)), + connect(value_widget_, SIGNAL(valueChanged(double)), this, SLOT(on_value_changed(double))); - form->addRow(tr("Time"), _value_widget); + form->addRow(tr("Time"), value_widget_); return popup; } void TimeMarker::on_value_changed(double value) { - if (!_updating_value_widget) { - _time = value; + if (!updating_value_widget_) { + time_ = value; time_changed(); } } diff --git a/pv/view/timemarker.h b/pv/view/timemarker.h index 63de74c4..d57b4dd1 100644 --- a/pv/view/timemarker.h +++ b/pv/view/timemarker.h @@ -100,16 +100,16 @@ Q_SIGNALS: void time_changed(); protected: - View &_view; - const QColor &_colour; + View &view_; + const QColor &colour_; - double _time; + double time_; - QSizeF _text_size; + QSizeF text_size_; - QWidgetAction *_value_action; - QDoubleSpinBox *_value_widget; - bool _updating_value_widget; + QWidgetAction *value_action_; + QDoubleSpinBox *value_widget_; + bool updating_value_widget_; }; } // namespace view diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 9caa8f01..ebd3dc36 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -42,37 +42,37 @@ const QPen Trace::AxisPen(QColor(128, 128, 128, 64)); const int Trace::LabelHitPadding = 2; Trace::Trace(QString name) : - _name(name), - _popup(NULL), - _popup_form(NULL) + name_(name), + popup_(NULL), + popup_form_(NULL) { } QString Trace::name() const { - return _name; + return name_; } void Trace::set_name(QString name) { - _name = name; + name_ = name; } QColor Trace::colour() const { - return _colour; + return colour_; } void Trace::set_colour(QColor colour) { - _colour = colour; + colour_ = colour; } void Trace::paint_label(QPainter &p, int right, bool hover) { const int y = get_visual_y(); - p.setBrush(_colour); + p.setBrush(colour_); if (!enabled()) return; @@ -103,14 +103,14 @@ void Trace::paint_label(QPainter &p, int right, bool hover) } p.setPen(Qt::transparent); - p.setBrush(hover ? _colour.lighter() : _colour); + p.setBrush(hover ? colour_.lighter() : colour_); p.drawPolygon(points, countof(points)); - p.setPen(_colour.lighter()); + p.setPen(colour_.lighter()); p.setBrush(Qt::transparent); p.drawPolygon(highlight_points, countof(highlight_points)); - p.setPen(_colour.darker()); + p.setPen(colour_.darker()); p.setBrush(Qt::transparent); p.drawPolygon(points, countof(points)); @@ -119,7 +119,7 @@ void Trace::paint_label(QPainter &p, int right, bool hover) p.setFont(QApplication::font()); p.drawText(QRectF(r.x(), r.y(), r.width() - label_arrow_length, r.height()), - Qt::AlignCenter | Qt::AlignVCenter, _name); + Qt::AlignCenter | Qt::AlignVCenter, name_); } QMenu* Trace::create_context_menu(QWidget *parent) @@ -133,14 +133,14 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent) { using pv::widgets::Popup; - _popup = new Popup(parent); + popup_ = new Popup(parent); create_popup_form(); - connect(_popup, SIGNAL(closed()), + connect(popup_, SIGNAL(closed()), this, SLOT(on_popup_closed())); - return _popup; + return popup_; } QRectF Trace::label_rect(int right) const @@ -149,7 +149,7 @@ QRectF Trace::label_rect(int right) const QFontMetrics m(QApplication::font()); const QSize text_size( - m.boundingRect(QRect(), 0, _name).width(), + m.boundingRect(QRect(), 0, name_).width(), m.boundingRect(QRect(), 0, "Tg").height()); const QSizeF label_size( text_size.width() + View::LabelPadding.width() * 2, @@ -164,7 +164,7 @@ QRectF Trace::label_rect(int right) const QColor Trace::get_text_colour() const { - return (_colour.lightness() > 64) ? Qt::black : Qt::white; + return (colour_.lightness() > 64) ? Qt::black : Qt::white; } void Trace::paint_axis(QPainter &p, int y, int left, int right) @@ -180,7 +180,7 @@ void Trace::add_colour_option(QWidget *parent, QFormLayout *form) ColourButton *const colour_button = new ColourButton( TracePalette::Rows, TracePalette::Cols, parent); colour_button->set_palette(TracePalette::Colours); - colour_button->set_colour(_colour); + colour_button->set_colour(colour_); connect(colour_button, SIGNAL(selected(const QColor&)), this, SLOT(on_colour_changed(const QColor&))); @@ -194,19 +194,19 @@ void Trace::create_popup_form() // Transfer the layout and the child widgets to a temporary widget // which then goes out of scope destroying the layout and all the child // widgets. - if (_popup_form) - QWidget().setLayout(_popup_form); + if (popup_form_) + QWidget().setLayout(popup_form_); // Repopulate the popup - _popup_form = new QFormLayout(_popup); - _popup->setLayout(_popup_form); - populate_popup_form(_popup, _popup_form); + popup_form_ = new QFormLayout(popup_); + popup_->setLayout(popup_form_); + populate_popup_form(popup_, popup_form_); } void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) { QLineEdit *const name_edit = new QLineEdit(parent); - name_edit->setText(_name); + name_edit->setText(name_); connect(name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(on_text_changed(const QString&))); form->addRow(tr("Name"), name_edit); @@ -216,24 +216,24 @@ void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) void Trace::on_popup_closed() { - _popup = NULL; - _popup_form = NULL; + popup_ = NULL; + popup_form_ = NULL; } void Trace::on_text_changed(const QString &text) { set_name(text); - if (_owner) - _owner->extents_changed(true, false); + if (owner_) + owner_->extents_changed(true, false); } void Trace::on_colour_changed(const QColor &colour) { set_colour(colour); - if (_owner) - _owner->appearance_changed(true, false); + if (owner_) + owner_->appearance_changed(true, false); } } // namespace view diff --git a/pv/view/trace.h b/pv/view/trace.h index 83eb8265..f99e01aa 100644 --- a/pv/view/trace.h +++ b/pv/view/trace.h @@ -127,12 +127,12 @@ private Q_SLOTS: void on_popup_closed(); protected: - QString _name; - QColor _colour; + QString name_; + QColor colour_; private: - pv::widgets::Popup *_popup; - QFormLayout *_popup_form; + pv::widgets::Popup *popup_; + QFormLayout *popup_form_; }; } // namespace view diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 765f0973..16b9d0cc 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -42,7 +42,7 @@ const QColor TraceGroup::LineColour(QColor(0x55, 0x57, 0x53)); TraceGroup::~TraceGroup() { - _owner = nullptr; + owner_ = nullptr; clear_child_items(); } @@ -54,26 +54,26 @@ bool TraceGroup::enabled() const pv::SigSession& TraceGroup::session() { - assert(_owner); - return _owner->session(); + assert(owner_); + return owner_->session(); } const pv::SigSession& TraceGroup::session() const { - assert(_owner); - return _owner->session(); + assert(owner_); + return owner_->session(); } pv::view::View* TraceGroup::view() { - assert(_owner); - return _owner->view(); + assert(owner_); + return owner_->view(); } const pv::view::View* TraceGroup::view() const { - assert(_owner); - return _owner->view(); + assert(owner_); + return owner_->view(); } pair TraceGroup::v_extents() const @@ -152,7 +152,7 @@ pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent) int TraceGroup::owner_visual_v_offset() const { - return _owner ? visual_v_offset() + _owner->owner_visual_v_offset() : 0; + return owner_ ? visual_v_offset() + owner_->owner_visual_v_offset() : 0; } void TraceGroup::restack_items() @@ -192,7 +192,7 @@ void TraceGroup::restack_items() unsigned int TraceGroup::depth() const { - return _owner ? _owner->depth() + 1 : 0; + return owner_ ? owner_->depth() + 1 : 0; } void TraceGroup::ungroup() @@ -202,9 +202,9 @@ void TraceGroup::ungroup() clear_child_items(); for (shared_ptr r : items) - _owner->add_child_item(r); + owner_->add_child_item(r); - _owner->remove_child_item(shared_from_this()); + owner_->remove_child_item(shared_from_this()); } void TraceGroup::on_ungroup() @@ -214,14 +214,14 @@ void TraceGroup::on_ungroup() void TraceGroup::appearance_changed(bool label, bool content) { - if (_owner) - _owner->appearance_changed(label, content); + if (owner_) + owner_->appearance_changed(label, content); } void TraceGroup::extents_changed(bool horz, bool vert) { - if (_owner) - _owner->extents_changed(horz, vert); + if (owner_) + owner_->extents_changed(horz, vert); } } // namespace view diff --git a/pv/view/view.cpp b/pv/view/view.cpp index 3b850832..5af8d28c 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -81,82 +81,82 @@ const QSizeF View::LabelPadding(4, 0); View::View(SigSession &session, QWidget *parent) : QAbstractScrollArea(parent), - _session(session), - _viewport(new Viewport(*this)), - _ruler(new Ruler(*this)), - _cursorheader(new CursorHeader(*this)), - _header(new Header(*this)), - _scale(1e-6), - _offset(0), - _v_offset(0), - _updating_scroll(false), - _show_cursors(false), - _cursors(*this), - _hover_point(-1, -1) + session_(session), + viewport_(new Viewport(*this)), + ruler_(new Ruler(*this)), + cursorheader_(new CursorHeader(*this)), + header_(new Header(*this)), + scale_(1e-6), + offset_(0), + v_offset_(0), + updating_scroll_(false), + show_cursors_(false), + cursors_(*this), + hover_point_(-1, -1) { connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(h_scroll_value_changed(int))); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(v_scroll_value_changed(int))); - connect(&_session, SIGNAL(signals_changed()), + connect(&session_, SIGNAL(signals_changed()), this, SLOT(signals_changed())); - connect(&_session, SIGNAL(capture_state_changed(int)), + connect(&session_, SIGNAL(capture_state_changed(int)), this, SLOT(data_updated())); - connect(&_session, SIGNAL(data_received()), + connect(&session_, SIGNAL(data_received()), this, SLOT(data_updated())); - connect(&_session, SIGNAL(frame_ended()), + connect(&session_, SIGNAL(frame_ended()), this, SLOT(data_updated())); - connect(_cursors.first().get(), SIGNAL(time_changed()), + connect(cursors_.first().get(), SIGNAL(time_changed()), this, SLOT(marker_time_changed())); - connect(_cursors.second().get(), SIGNAL(time_changed()), + connect(cursors_.second().get(), SIGNAL(time_changed()), this, SLOT(marker_time_changed())); - connect(_header, SIGNAL(signals_moved()), + connect(header_, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); - connect(_header, SIGNAL(selection_changed()), - _cursorheader, SLOT(clear_selection())); - connect(_cursorheader, SIGNAL(selection_changed()), - _header, SLOT(clear_selection())); + connect(header_, SIGNAL(selection_changed()), + cursorheader_, SLOT(clear_selection())); + connect(cursorheader_, SIGNAL(selection_changed()), + header_, SLOT(clear_selection())); - connect(_header, SIGNAL(selection_changed()), + connect(header_, SIGNAL(selection_changed()), this, SIGNAL(selection_changed())); - connect(_cursorheader, SIGNAL(selection_changed()), + connect(cursorheader_, SIGNAL(selection_changed()), this, SIGNAL(selection_changed())); connect(this, SIGNAL(hover_point_changed()), this, SLOT(on_hover_point_changed())); - connect(&_lazy_event_handler, SIGNAL(timeout()), + connect(&lazy_event_handler_, SIGNAL(timeout()), this, SLOT(process_sticky_events())); - _lazy_event_handler.setSingleShot(true); + lazy_event_handler_.setSingleShot(true); - setViewport(_viewport); + setViewport(viewport_); - _viewport->installEventFilter(this); - _ruler->installEventFilter(this); - _cursorheader->installEventFilter(this); - _header->installEventFilter(this); + viewport_->installEventFilter(this); + ruler_->installEventFilter(this); + cursorheader_->installEventFilter(this); + header_->installEventFilter(this); // Trigger the initial event manually. The default device has signals // which were created before this object came into being signals_changed(); // make sure the transparent widgets are on the top - _cursorheader->raise(); - _header->raise(); + cursorheader_->raise(); + header_->raise(); } SigSession& View::session() { - return _session; + return session_; } const SigSession& View::session() const { - return _session; + return session_; } View* View::view() @@ -171,27 +171,27 @@ const View* View::view() const Viewport* View::viewport() { - return _viewport; + return viewport_; } const Viewport* View::viewport() const { - return _viewport; + return viewport_; } double View::scale() const { - return _scale; + return scale_; } double View::offset() const { - return _offset; + return offset_; } int View::owner_visual_v_offset() const { - return -_v_offset; + return -v_offset_; } unsigned int View::depth() const @@ -201,12 +201,12 @@ unsigned int View::depth() const void View::zoom(double steps) { - zoom(steps, _viewport->width() / 2); + zoom(steps, viewport_->width() / 2); } 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() @@ -216,8 +216,8 @@ void View::zoom_fit() if (delta < 1e-12) return; - assert(_viewport); - const int w = _viewport->width(); + assert(viewport_); + const int w = viewport_->width(); if (w <= 0) return; @@ -243,8 +243,8 @@ void View::zoom_one_to_one() if (samplerate == 0.0) return; - assert(_viewport); - const int w = _viewport->width(); + assert(viewport_); + const int w = viewport_->width(); if (w <= 0) return; @@ -253,13 +253,13 @@ void View::zoom_one_to_one() void View::set_scale_offset(double scale, double offset) { - _scale = scale; - _offset = offset; + scale_ = scale; + offset_ = offset; update_scroll(); - _ruler->update(); - _cursorheader->update(); - _viewport->update(); + ruler_->update(); + cursorheader_->update(); + viewport_->update(); scale_offset_changed(); } @@ -301,45 +301,45 @@ pair View::get_time_extents() const bool View::cursors_shown() const { - return _show_cursors; + return show_cursors_; } void View::show_cursors(bool show) { - _show_cursors = show; - _cursorheader->update(); - _viewport->update(); + show_cursors_ = show; + cursorheader_->update(); + viewport_->update(); } void View::centre_cursors() { - const double time_width = _scale * _viewport->width(); - _cursors.first()->set_time(_offset + time_width * 0.4); - _cursors.second()->set_time(_offset + time_width * 0.6); - _cursorheader->update(); - _viewport->update(); + const double time_width = scale_ * viewport_->width(); + cursors_.first()->set_time(offset_ + time_width * 0.4); + cursors_.second()->set_time(offset_ + time_width * 0.6); + cursorheader_->update(); + viewport_->update(); } CursorPair& View::cursors() { - return _cursors; + return cursors_; } const CursorPair& View::cursors() const { - return _cursors; + return cursors_; } const QPoint& View::hover_point() const { - return _hover_point; + return hover_point_; } void View::update_viewport() { - assert(_viewport); - _viewport->update(); - _header->update(); + assert(viewport_); + viewport_->update(); + header_->update(); } void View::restack_all_row_items() @@ -367,13 +367,13 @@ void View::restack_all_row_items() void View::get_scroll_layout(double &length, double &offset) const { const pair extents = get_time_extents(); - length = (extents.second - extents.first) / _scale; - offset = _offset / _scale; + length = (extents.second - extents.first) / scale_; + offset = offset_ / scale_; } void View::set_zoom(double scale, int offset) { - const double cursor_offset = _offset + _scale * offset; + const double cursor_offset = offset_ + scale_ * offset; const double new_scale = max(min(scale, MaxScale), MinScale); const double new_offset = cursor_offset - new_scale * offset; set_scale_offset(new_scale, new_offset); @@ -381,9 +381,9 @@ void View::set_zoom(double scale, int offset) void View::update_scroll() { - assert(_viewport); + assert(viewport_); - const QSize areaSize = _viewport->size(); + const QSize areaSize = viewport_->size(); // Set the horizontal scroll bar double length = 0, offset = 0; @@ -392,7 +392,7 @@ void View::update_scroll() horizontalScrollBar()->setPageStep(areaSize.width() / 2); - _updating_scroll = true; + updating_scroll_ = true; if (length < MaxScrollValue) { horizontalScrollBar()->setRange(0, length); @@ -400,10 +400,10 @@ void View::update_scroll() } else { horizontalScrollBar()->setRange(0, MaxScrollValue); horizontalScrollBar()->setSliderPosition( - _offset * MaxScrollValue / (_scale * length)); + offset_ * MaxScrollValue / (scale_ * length)); } - _updating_scroll = false; + updating_scroll_ = false; // Set the vertical scrollbar verticalScrollBar()->setPageStep(areaSize.height()); @@ -417,16 +417,16 @@ void View::update_scroll() void View::update_layout() { setViewportMargins( - _header->sizeHint().width() - pv::view::Header::BaselineOffset, - _ruler->sizeHint().height(), 0, 0); - _ruler->setGeometry(_viewport->x(), 0, - _viewport->width(), _viewport->y()); - _cursorheader->setGeometry( - _viewport->x(), - _ruler->sizeHint().height() - _cursorheader->sizeHint().height() / 2, - _viewport->width(), _cursorheader->sizeHint().height()); - _header->setGeometry(0, _viewport->y(), - _header->sizeHint().width(), _viewport->height()); + header_->sizeHint().width() - pv::view::Header::BaselineOffset, + ruler_->sizeHint().height(), 0, 0); + ruler_->setGeometry(viewport_->x(), 0, + viewport_->width(), viewport_->y()); + cursorheader_->setGeometry( + viewport_->x(), + ruler_->sizeHint().height() - cursorheader_->sizeHint().height() / 2, + viewport_->width(), cursorheader_->sizeHint().height()); + header_->setGeometry(0, viewport_->y(), + header_->sizeHint().width(), viewport_->height()); update_scroll(); } @@ -488,19 +488,19 @@ bool View::eventFilter(QObject *object, QEvent *event) if (type == QEvent::MouseMove) { const QMouseEvent *const mouse_event = (QMouseEvent*)event; - if (object == _viewport) - _hover_point = mouse_event->pos(); - else if (object == _ruler || object == _cursorheader) - _hover_point = QPoint(mouse_event->x(), 0); - else if (object == _header) - _hover_point = QPoint(0, mouse_event->y()); + if (object == viewport_) + hover_point_ = mouse_event->pos(); + else if (object == ruler_ || object == cursorheader_) + hover_point_ = QPoint(mouse_event->x(), 0); + else if (object == header_) + hover_point_ = QPoint(0, mouse_event->y()); else - _hover_point = QPoint(-1, -1); + hover_point_ = QPoint(-1, -1); hover_point_changed(); } else if (type == QEvent::Leave) { - _hover_point = QPoint(-1, -1); + hover_point_ = QPoint(-1, -1); hover_point_changed(); } @@ -534,43 +534,43 @@ void View::resizeEvent(QResizeEvent*) void View::appearance_changed(bool label, bool content) { if (label) - _header->update(); + header_->update(); if (content) - _viewport->update(); + viewport_->update(); } void View::extents_changed(bool horz, bool vert) { - _sticky_events |= + sticky_events_ |= (horz ? SelectableItemHExtentsChanged : 0) | (vert ? SelectableItemVExtentsChanged : 0); - _lazy_event_handler.start(); + lazy_event_handler_.start(); } void View::h_scroll_value_changed(int value) { - if (_updating_scroll) + if (updating_scroll_) return; const int range = horizontalScrollBar()->maximum(); if (range < MaxScrollValue) - _offset = _scale * value; + offset_ = scale_ * value; else { double length = 0, offset; get_scroll_layout(length, offset); - _offset = _scale * length * value / MaxScrollValue; + offset_ = scale_ * length * value / MaxScrollValue; } - _ruler->update(); - _cursorheader->update(); - _viewport->update(); + ruler_->update(); + cursorheader_->update(); + viewport_->update(); } void View::v_scroll_value_changed(int value) { - _v_offset = value; - _header->update(); - _viewport->update(); + v_offset_ = value; + header_->update(); + viewport_->update(); } void View::signals_changed() @@ -580,15 +580,15 @@ void View::signals_changed() // Populate the traces clear_child_items(); - shared_ptr device = _session.device(); + shared_ptr device = session_.device(); assert(device); // Collect a set of signals unordered_map, shared_ptr > signal_map; - shared_lock lock(_session.signals_mutex()); - const vector< shared_ptr > &sigs(_session.signals()); + shared_lock lock(session_.signals_mutex()); + const vector< shared_ptr > &sigs(session_.signals()); for (const shared_ptr &sig : sigs) signal_map[sig->channel()] = sig; @@ -649,13 +649,13 @@ void View::data_updated() update_scroll(); // Repaint the view - _viewport->update(); + viewport_->update(); } void View::marker_time_changed() { - _cursorheader->update(); - _viewport->update(); + cursorheader_->update(); + viewport_->update(); } void View::on_signals_moved() @@ -666,13 +666,13 @@ void View::on_signals_moved() void View::process_sticky_events() { - if (_sticky_events & SelectableItemHExtentsChanged) + if (sticky_events_ & SelectableItemHExtentsChanged) update_layout(); - if (_sticky_events & SelectableItemVExtentsChanged) + if (sticky_events_ & SelectableItemVExtentsChanged) restack_all_row_items(); // Clear the sticky events - _sticky_events = 0; + sticky_events_ = 0; } void View::on_hover_point_changed() diff --git a/pv/view/view.h b/pv/view/view.h index 8664ba8d..dec317cc 100644 --- a/pv/view/view.h +++ b/pv/view/view.h @@ -236,29 +236,29 @@ private Q_SLOTS: void on_hover_point_changed(); private: - SigSession &_session; + SigSession &session_; - Viewport *_viewport; - Ruler *_ruler; - CursorHeader *_cursorheader; - Header *_header; + Viewport *viewport_; + Ruler *ruler_; + CursorHeader *cursorheader_; + Header *header_; /// The view time scale in seconds per pixel. - double _scale; + double scale_; /// The view time offset in seconds. - double _offset; + double offset_; - int _v_offset; - bool _updating_scroll; + int v_offset_; + bool updating_scroll_; - bool _show_cursors; - CursorPair _cursors; + bool show_cursors_; + CursorPair cursors_; - QPoint _hover_point; + QPoint hover_point_; - unsigned int _sticky_events; - QTimer _lazy_event_handler; + unsigned int sticky_events_; + QTimer lazy_event_handler_; }; } // namespace view diff --git a/pv/view/viewport.cpp b/pv/view/viewport.cpp index eeca690d..220a10aa 100644 --- a/pv/view/viewport.cpp +++ b/pv/view/viewport.cpp @@ -42,9 +42,9 @@ namespace view { Viewport::Viewport(View &parent) : QWidget(&parent), - _view(parent), - _mouse_down_valid(false), - _pinch_zoom_active(false) + view_(parent), + mouse_down_valid_(false), + pinch_zoom_active_(false) { setAttribute(Qt::WA_AcceptTouchEvents, true); @@ -52,13 +52,13 @@ Viewport::Viewport(View &parent) : setAutoFillBackground(true); setBackgroundRole(QPalette::Base); - connect(&_view, SIGNAL(signals_moved()), + connect(&view_, SIGNAL(signals_moved()), this, SLOT(on_signals_moved())); } void Viewport::paintEvent(QPaintEvent*) { - vector< shared_ptr > row_items(_view.begin(), _view.end()); + vector< shared_ptr > row_items(view_.begin(), view_.end()); stable_sort(row_items.begin(), row_items.end(), [](const shared_ptr &a, const shared_ptr &b) { return a->visual_v_offset() < b->visual_v_offset(); }); @@ -66,8 +66,8 @@ void Viewport::paintEvent(QPaintEvent*) QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - if (_view.cursors_shown()) - _view.cursors().draw_viewport_background(p, rect()); + if (view_.cursors_shown()) + view_.cursors().draw_viewport_background(p, rect()); // Plot the signal for (const shared_ptr r : row_items) @@ -82,8 +82,8 @@ void Viewport::paintEvent(QPaintEvent*) for (const shared_ptr r : row_items) r->paint_fore(p, 0, width()); - if (_view.cursors_shown()) - _view.cursors().draw_viewport_foreground(p, rect()); + if (view_.cursors_shown()) + view_.cursors().draw_viewport_foreground(p, rect()); p.end(); } @@ -110,9 +110,9 @@ void Viewport::mousePressEvent(QMouseEvent *event) assert(event); if (event->button() == Qt::LeftButton) { - _mouse_down_point = event->pos(); - _mouse_down_offset = _view.offset(); - _mouse_down_valid = true; + mouse_down_point_ = event->pos(); + mouse_down_offset_ = view_.offset(); + mouse_down_valid_ = true; } } @@ -121,7 +121,7 @@ void Viewport::mouseReleaseEvent(QMouseEvent *event) assert(event); if (event->button() == Qt::LeftButton) - _mouse_down_valid = false; + mouse_down_valid_ = false; } void Viewport::mouseMoveEvent(QMouseEvent *event) @@ -129,16 +129,16 @@ void Viewport::mouseMoveEvent(QMouseEvent *event) assert(event); if (event->buttons() & Qt::LeftButton) { - if (!_mouse_down_valid) { - _mouse_down_point = event->pos(); - _mouse_down_offset = _view.offset(); - _mouse_down_valid = true; + if (!mouse_down_valid_) { + mouse_down_point_ = event->pos(); + mouse_down_offset_ = view_.offset(); + mouse_down_valid_ = true; } - _view.set_scale_offset(_view.scale(), - _mouse_down_offset + - (_mouse_down_point - event->pos()).x() * - _view.scale()); + view_.set_scale_offset(view_.scale(), + mouse_down_offset_ + + (mouse_down_point_ - event->pos()).x() * + view_.scale()); } } @@ -147,9 +147,9 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event) assert(event); if (event->buttons() & Qt::LeftButton) - _view.zoom(2.0, event->x()); + view_.zoom(2.0, event->x()); else if (event->buttons() & Qt::RightButton) - _view.zoom(-2.0, event->x()); + view_.zoom(-2.0, event->x()); } void Viewport::wheelEvent(QWheelEvent *event) @@ -158,12 +158,12 @@ void Viewport::wheelEvent(QWheelEvent *event) if (event->orientation() == Qt::Vertical) { // Vertical scrolling is interpreted as zooming in/out - _view.zoom(event->delta() / 120, event->x()); + view_.zoom(event->delta() / 120, event->x()); } else if (event->orientation() == Qt::Horizontal) { // Horizontal scrolling is interpreted as moving left/right - _view.set_scale_offset(_view.scale(), - event->delta() * _view.scale() - + _view.offset()); + view_.set_scale_offset(view_.scale(), + event->delta() * view_.scale() + + view_.offset()); } } @@ -172,42 +172,42 @@ bool Viewport::touchEvent(QTouchEvent *event) QList touchPoints = event->touchPoints(); if (touchPoints.count() != 2) { - _pinch_zoom_active = false; + pinch_zoom_active_ = false; return false; } const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first(); const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last(); - if (!_pinch_zoom_active || + if (!pinch_zoom_active_ || (event->touchPointStates() & Qt::TouchPointPressed)) { - _pinch_offset0 = _view.offset() + _view.scale() * touchPoint0.pos().x(); - _pinch_offset1 = _view.offset() + _view.scale() * touchPoint1.pos().x(); - _pinch_zoom_active = true; + pinch_offset0_ = view_.offset() + view_.scale() * touchPoint0.pos().x(); + pinch_offset1_ = view_.offset() + view_.scale() * touchPoint1.pos().x(); + pinch_zoom_active_ = true; } double w = touchPoint1.pos().x() - touchPoint0.pos().x(); if (abs(w) >= 1.0) { - double scale = (_pinch_offset1 - _pinch_offset0) / w; + double scale = (pinch_offset1_ - pinch_offset0_) / w; if (scale < 0) scale = -scale; - double offset = _pinch_offset0 - touchPoint0.pos().x() * scale; + double offset = pinch_offset0_ - touchPoint0.pos().x() * scale; if (scale > 0) - _view.set_scale_offset(scale, offset); + view_.set_scale_offset(scale, offset); } if (event->touchPointStates() & Qt::TouchPointReleased) { - _pinch_zoom_active = false; + pinch_zoom_active_ = false; if (touchPoint0.state() & Qt::TouchPointReleased) { // Primary touch released - _mouse_down_valid = false; + mouse_down_valid_ = false; } else { // Update the mouse down fields so that continued // dragging with the primary touch will work correctly - _mouse_down_point = touchPoint0.pos().toPoint(); - _mouse_down_offset = _view.offset(); - _mouse_down_valid = true; + mouse_down_point_ = touchPoint0.pos().toPoint(); + mouse_down_offset_ = view_.offset(); + mouse_down_valid_ = true; } } diff --git a/pv/view/viewport.h b/pv/view/viewport.h index 1de9cd2a..1171a707 100644 --- a/pv/view/viewport.h +++ b/pv/view/viewport.h @@ -57,15 +57,15 @@ private Q_SLOTS: void on_signals_moved(); private: - View &_view; + View &view_; - QPoint _mouse_down_point; - double _mouse_down_offset; - bool _mouse_down_valid; + QPoint mouse_down_point_; + double mouse_down_offset_; + bool mouse_down_valid_; - double _pinch_offset0; - double _pinch_offset1; - bool _pinch_zoom_active; + double pinch_offset0_; + double pinch_offset1_; + bool pinch_zoom_active_; }; } // namespace view diff --git a/pv/widgets/colourbutton.cpp b/pv/widgets/colourbutton.cpp index fd417c11..cf930f65 100644 --- a/pv/widgets/colourbutton.cpp +++ b/pv/widgets/colourbutton.cpp @@ -32,37 +32,37 @@ const int ColourButton::SwatchMargin = 7; ColourButton::ColourButton(int rows, int cols, QWidget *parent) : QPushButton("", parent), - _popup(rows, cols, this) + popup_(rows, cols, this) { connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool))); - connect(&_popup, SIGNAL(selected(int, int)), + connect(&popup_, SIGNAL(selected(int, int)), this, SLOT(on_selected(int, int))); } ColourPopup& ColourButton::popup() { - return _popup; + return popup_; } const QColor& ColourButton::colour() const { - return _cur_colour; + return cur_colour_; } void ColourButton::set_colour(QColor colour) { - _cur_colour = colour; + cur_colour_ = colour; - const unsigned int rows = _popup.well_array().numRows(); - const unsigned int cols = _popup.well_array().numCols(); + const unsigned int rows = popup_.well_array().numRows(); + const unsigned int cols = popup_.well_array().numCols(); for (unsigned int r = 0; r < rows; r++) for (unsigned int c = 0; c < cols; c++) - if (_popup.well_array().cellBrush(r, c).color() == + if (popup_.well_array().cellBrush(r, c).color() == colour) { - _popup.well_array().setSelected(r, c); - _popup.well_array().setCurrent(r, c); + popup_.well_array().setSelected(r, c); + popup_.well_array().setCurrent(r, c); return; } } @@ -71,25 +71,25 @@ void ColourButton::set_palette(const QColor *const palette) { assert(palette); - const unsigned int rows = _popup.well_array().numRows(); - const unsigned int cols = _popup.well_array().numCols(); + const unsigned int rows = popup_.well_array().numRows(); + const unsigned int cols = popup_.well_array().numCols(); for (unsigned int r = 0; r < rows; r++) for (unsigned int c = 0; c < cols; c++) - _popup.well_array().setCellBrush(r, c, + popup_.well_array().setCellBrush(r, c, QBrush(palette[r * cols + c])); } void ColourButton::on_clicked(bool) { - _popup.set_position(mapToGlobal(rect().center()), Popup::Bottom); - _popup.show(); + popup_.set_position(mapToGlobal(rect().center()), Popup::Bottom); + popup_.show(); } void ColourButton::on_selected(int row, int col) { - _cur_colour = _popup.well_array().cellBrush(row, col).color(); - selected(_cur_colour); + cur_colour_ = popup_.well_array().cellBrush(row, col).color(); + selected(cur_colour_); } void ColourButton::paintEvent(QPaintEvent *e) @@ -101,7 +101,7 @@ void ColourButton::paintEvent(QPaintEvent *e) const QRect r = rect().adjusted(SwatchMargin, SwatchMargin, -SwatchMargin, -SwatchMargin); p.setPen(QApplication::palette().color(QPalette::Dark)); - p.setBrush(QBrush(_cur_colour)); + p.setBrush(QBrush(cur_colour_)); p.drawRect(r); } diff --git a/pv/widgets/colourbutton.h b/pv/widgets/colourbutton.h index 2e62e43c..a3551486 100644 --- a/pv/widgets/colourbutton.h +++ b/pv/widgets/colourbutton.h @@ -58,8 +58,8 @@ Q_SIGNALS: void selected(const QColor &colour); private: - ColourPopup _popup; - QColor _cur_colour; + ColourPopup popup_; + QColor cur_colour_; }; } // widgets diff --git a/pv/widgets/colourpopup.cpp b/pv/widgets/colourpopup.cpp index 816a4c50..285e9a05 100644 --- a/pv/widgets/colourpopup.cpp +++ b/pv/widgets/colourpopup.cpp @@ -25,21 +25,21 @@ namespace widgets { ColourPopup::ColourPopup(int rows, int cols, QWidget *parent) : Popup(parent), - _well_array(rows, cols, this), - _layout(this) + well_array_(rows, cols, this), + layout_(this) { - _layout.addWidget(&_well_array); - setLayout(&_layout); + layout_.addWidget(&well_array_); + setLayout(&layout_); - connect(&_well_array, SIGNAL(selected(int, int)), + connect(&well_array_, SIGNAL(selected(int, int)), this, SIGNAL(selected(int, int))); - connect(&_well_array, SIGNAL(selected(int, int)), + connect(&well_array_, SIGNAL(selected(int, int)), this, SLOT(colour_selected(int, int))); } QWellArray& ColourPopup::well_array() { - return _well_array; + return well_array_; } void ColourPopup::colour_selected(int, int) diff --git a/pv/widgets/colourpopup.h b/pv/widgets/colourpopup.h index 4f227628..d0441d3c 100644 --- a/pv/widgets/colourpopup.h +++ b/pv/widgets/colourpopup.h @@ -45,8 +45,8 @@ private Q_SLOTS: void colour_selected(int, int); private: - QWellArray _well_array; - QVBoxLayout _layout; + QWellArray well_array_; + QVBoxLayout layout_; }; } // widgets diff --git a/pv/widgets/decodergroupbox.cpp b/pv/widgets/decodergroupbox.cpp index 2cbd532e..e8723e43 100644 --- a/pv/widgets/decodergroupbox.cpp +++ b/pv/widgets/decodergroupbox.cpp @@ -32,24 +32,24 @@ namespace widgets { DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) : QWidget(parent), - _layout(new QGridLayout), - _show_hide_button(QIcon(":/icons/decoder-shown.svg"), QString(), this) + layout_(new QGridLayout), + show_hide_button_(QIcon(":/icons/decoder-shown.svg"), QString(), this) { - _layout->setContentsMargins(0, 0, 0, 0); - setLayout(_layout); + layout_->setContentsMargins(0, 0, 0, 0); + setLayout(layout_); - _layout->addWidget(new QLabel(QString("

%1

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

%1

").arg(title)), 0, 0); - _layout->setColumnStretch(0, 1); + layout_->setColumnStretch(0, 1); QHBoxLayout *const toolbar = new QHBoxLayout; - _layout->addLayout(toolbar, 0, 1); + layout_->addLayout(toolbar, 0, 1); - _show_hide_button.setFlat(true); - _show_hide_button.setIconSize(QSize(16, 16)); - connect(&_show_hide_button, SIGNAL(clicked()), + show_hide_button_.setFlat(true); + show_hide_button_.setIconSize(QSize(16, 16)); + connect(&show_hide_button_, SIGNAL(clicked()), this, SIGNAL(show_hide_decoder())); - toolbar->addWidget(&_show_hide_button); + toolbar->addWidget(&show_hide_button_); QPushButton *const delete_button = new QPushButton( QIcon(":/icons/decoder-delete.svg"), QString(), this); @@ -63,12 +63,12 @@ DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) : void DecoderGroupBox::add_layout(QLayout *layout) { assert(layout); - _layout->addLayout(layout, 1, 0, 1, 2); + layout_->addLayout(layout, 1, 0, 1, 2); } void DecoderGroupBox::set_decoder_visible(bool visible) { - _show_hide_button.setIcon(QIcon(visible ? + show_hide_button_.setIcon(QIcon(visible ? ":/icons/decoder-shown.svg" : ":/icons/decoder-hidden.svg")); } diff --git a/pv/widgets/decodergroupbox.h b/pv/widgets/decodergroupbox.h index e2953917..2c820762 100644 --- a/pv/widgets/decodergroupbox.h +++ b/pv/widgets/decodergroupbox.h @@ -46,8 +46,8 @@ Q_SIGNALS: void show_hide_decoder(); private: - QGridLayout *const _layout; - QPushButton _show_hide_button; + QGridLayout *const layout_; + QPushButton show_hide_button_; }; } // widgets diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index 60eb8e8a..2a1e8395 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -29,7 +29,7 @@ namespace widgets { DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) : QMenu(parent), - _mapper(this) + mapper_(this) { GSList *l = g_slist_sort(g_slist_copy( (GSList*)srd_decoder_list()), decoder_name_cmp); @@ -43,14 +43,14 @@ DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) : QAction *const action = addAction(QString::fromUtf8(d->name)); action->setData(qVariantFromValue(l->data)); - _mapper.setMapping(action, action); + mapper_.setMapping(action, action); connect(action, SIGNAL(triggered()), - &_mapper, SLOT(map())); + &mapper_, SLOT(map())); } } g_slist_free(l); - connect(&_mapper, SIGNAL(mapped(QObject*)), + connect(&mapper_, SIGNAL(mapped(QObject*)), this, SLOT(on_action(QObject*))); } diff --git a/pv/widgets/decodermenu.h b/pv/widgets/decodermenu.h index bfe087e9..92c3a821 100644 --- a/pv/widgets/decodermenu.h +++ b/pv/widgets/decodermenu.h @@ -47,7 +47,7 @@ Q_SIGNALS: void decoder_selected(srd_decoder *decoder); private: - QSignalMapper _mapper; + QSignalMapper mapper_; }; } // widgets diff --git a/pv/widgets/popup.cpp b/pv/widgets/popup.cpp index 52701380..47280d1f 100644 --- a/pv/widgets/popup.cpp +++ b/pv/widgets/popup.cpp @@ -41,24 +41,24 @@ const unsigned int Popup::MarginWidth = 6; Popup::Popup(QWidget *parent) : QWidget(parent, Qt::Popup | Qt::FramelessWindowHint), - _point(), - _pos(Left) + point_(), + pos_(Left) { } const QPoint& Popup::point() const { - return _point; + return point_; } Popup::Position Popup::position() const { - return _pos; + return pos_; } void Popup::set_position(const QPoint point, Position pos) { - _point = point, _pos = pos; + point_ = point, pos_ = pos; setContentsMargins( MarginWidth + ((pos == Right) ? ArrowLength : 0), @@ -113,24 +113,24 @@ void Popup::show() bool Popup::space_for_arrow() const { // Check if there is room for the arrow - switch (_pos) { + switch (pos_) { case Right: - if (_point.x() > x()) + if (point_.x() > x()) return false; return true; case Bottom: - if (_point.y() > y()) + if (point_.y() > y()) return false; return true; case Left: - if (_point.x() < (x() + width())) + if (point_.x() < (x() + width())) return false; return true; case Top: - if (_point.y() < (y() + height())) + if (point_.y() < (y() + height())) return false; return true; } @@ -142,10 +142,10 @@ QPolygon Popup::arrow_polygon() const { QPolygon poly; - const QPoint p = mapFromGlobal(_point); + const QPoint p = mapFromGlobal(point_); const int l = ArrowLength + ArrowOverlap; - switch (_pos) + switch (pos_) { case Right: poly << QPoint(p.x() + l, p.y() - l); @@ -163,7 +163,7 @@ QPolygon Popup::arrow_polygon() const poly << p; - switch (_pos) + switch (pos_) { case Right: case Bottom: @@ -190,11 +190,11 @@ QRegion Popup::arrow_region() const QRect Popup::bubble_rect() const { return QRect( - QPoint((_pos == Right) ? ArrowLength : 0, - (_pos == Bottom) ? ArrowLength : 0), - QSize(width() - ((_pos == Left || _pos == Right) ? + QPoint((pos_ == Right) ? ArrowLength : 0, + (pos_ == Bottom) ? ArrowLength : 0), + QSize(width() - ((pos_ == Left || pos_ == Right) ? ArrowLength : 0), - height() - ((_pos == Top || _pos == Bottom) ? + height() - ((pos_ == Top || pos_ == Bottom) ? ArrowLength : 0))); } @@ -229,19 +229,19 @@ void Popup::reposition_widget() QPoint o; const QRect screen_rect = QApplication::desktop()->availableGeometry( - QApplication::desktop()->screenNumber(_point)); + QApplication::desktop()->screenNumber(point_)); - if (_pos == Right || _pos == Left) + if (pos_ == Right || pos_ == Left) o.ry() = -height() / 2; else o.rx() = -width() / 2; - if (_pos == Left) + if (pos_ == Left) o.rx() = -width(); - else if(_pos == Top) + else if(pos_ == Top) o.ry() = -height(); - o += _point; + o += point_; move(max(min(o.x(), screen_rect.right() - width()), screen_rect.left()), max(min(o.y(), screen_rect.bottom() - height()), @@ -280,7 +280,7 @@ void Popup::paintEvent(QPaintEvent*) const QRegion a(arrow_region()); const QRegion arrow_outline = a.subtracted( - a.translated(ArrowOffsets[_pos])); + a.translated(ArrowOffsets[pos_])); painter.setClipRegion(bubble_outline.subtracted(a).united( arrow_outline)); diff --git a/pv/widgets/popup.h b/pv/widgets/popup.h index 2fdb23c0..83ad7ee0 100644 --- a/pv/widgets/popup.h +++ b/pv/widgets/popup.h @@ -87,8 +87,8 @@ Q_SIGNALS: void closed(); private: - QPoint _point; - Position _pos; + QPoint point_; + Position pos_; }; } // namespace widgets diff --git a/pv/widgets/popuptoolbutton.cpp b/pv/widgets/popuptoolbutton.cpp index 74743ed4..a5886aaf 100644 --- a/pv/widgets/popuptoolbutton.cpp +++ b/pv/widgets/popuptoolbutton.cpp @@ -27,31 +27,31 @@ namespace widgets { PopupToolButton::PopupToolButton(QWidget *parent) : QToolButton(parent), - _popup(NULL) + popup_(NULL) { connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool))); } Popup* PopupToolButton::popup() const { - return _popup; + return popup_; } void PopupToolButton::set_popup(Popup *popup) { assert(popup); - _popup = popup; + popup_ = popup; } void PopupToolButton::on_clicked(bool) { - if(!_popup) + if(!popup_) return; const QRect r = rect(); - _popup->set_position(mapToGlobal(QPoint((r.left() + r.right()) / 2, + popup_->set_position(mapToGlobal(QPoint((r.left() + r.right()) / 2, ((r.top() + r.bottom() * 3) / 4))), Popup::Bottom); - _popup->show(); + popup_->show(); } } // widgets diff --git a/pv/widgets/popuptoolbutton.h b/pv/widgets/popuptoolbutton.h index bbc04f5e..3a3fc63b 100644 --- a/pv/widgets/popuptoolbutton.h +++ b/pv/widgets/popuptoolbutton.h @@ -43,7 +43,7 @@ private Q_SLOTS: void on_clicked(bool); private: - Popup *_popup; + Popup *popup_; }; } // widgets diff --git a/pv/widgets/sweeptimingwidget.cpp b/pv/widgets/sweeptimingwidget.cpp index cb543b12..1c1581bb 100644 --- a/pv/widgets/sweeptimingwidget.cpp +++ b/pv/widgets/sweeptimingwidget.cpp @@ -37,35 +37,35 @@ namespace widgets { SweepTimingWidget::SweepTimingWidget(const char *suffix, QWidget *parent) : QWidget(parent), - _suffix(suffix), - _layout(this), - _value(this), - _list(this), - _value_type(None) + suffix_(suffix), + layout_(this), + value_(this), + list_(this), + value_type_(None) { setContentsMargins(0, 0, 0, 0); - _value.setDecimals(0); - _value.setSuffix(QString::fromUtf8(suffix)); + value_.setDecimals(0); + value_.setSuffix(QString::fromUtf8(suffix)); - connect(&_list, SIGNAL(currentIndexChanged(int)), + connect(&list_, SIGNAL(currentIndexChanged(int)), this, SIGNAL(value_changed())); - connect(&_value, SIGNAL(editingFinished()), + connect(&value_, SIGNAL(editingFinished()), this, SIGNAL(value_changed())); - setLayout(&_layout); - _layout.setMargin(0); - _layout.addWidget(&_list); - _layout.addWidget(&_value); + setLayout(&layout_); + layout_.setMargin(0); + layout_.addWidget(&list_); + layout_.addWidget(&value_); show_none(); } void SweepTimingWidget::show_none() { - _value_type = None; - _value.hide(); - _list.hide(); + value_type_ = None; + value_.hide(); + list_.hide(); } void SweepTimingWidget::show_min_max_step(uint64_t min, uint64_t max, @@ -74,30 +74,30 @@ void SweepTimingWidget::show_min_max_step(uint64_t min, uint64_t max, assert(max > min); assert(step > 0); - _value_type = MinMaxStep; + value_type_ = MinMaxStep; - _value.setRange(min, max); - _value.setSingleStep(step); + value_.setRange(min, max); + value_.setSingleStep(step); - _value.show(); - _list.hide(); + value_.show(); + list_.hide(); } void SweepTimingWidget::show_list(const uint64_t *vals, size_t count) { - _value_type = List; + value_type_ = List; - _list.clear(); + 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), + char *const s = sr_si_string_u64(vals[i], suffix_); + list_.addItem(QString::fromUtf8(s), qVariantFromValue(vals[i])); g_free(s); } - _value.hide(); - _list.show(); + value_.hide(); + list_.show(); } void SweepTimingWidget::show_125_list(uint64_t min, uint64_t max) @@ -142,18 +142,18 @@ 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(); + return (uint64_t)value_.value(); case List: { - const int index = _list.currentIndex(); - return (index >= 0) ? _list.itemData( + const int index = list_.currentIndex(); + return (index >= 0) ? list_.itemData( index).value() : 0; } @@ -166,21 +166,21 @@ uint64_t SweepTimingWidget::value() const void SweepTimingWidget::set_value(uint64_t value) { - _value.setValue(value); + value_.setValue(value); - int best_match = _list.count() - 1; + int best_match = list_.count() - 1; int64_t best_variance = INT64_MAX; - for (int i = 0; i < _list.count(); i++) { + for (int i = 0; i < list_.count(); i++) { const int64_t this_variance = abs( - (int64_t)value - _list.itemData(i).value()); + (int64_t)value - list_.itemData(i).value()); if (this_variance < best_variance) { best_variance = this_variance; best_match = i; } } - _list.setCurrentIndex(best_match); + list_.setCurrentIndex(best_match); } } // widgets diff --git a/pv/widgets/sweeptimingwidget.h b/pv/widgets/sweeptimingwidget.h index fc83c204..5510865e 100644 --- a/pv/widgets/sweeptimingwidget.h +++ b/pv/widgets/sweeptimingwidget.h @@ -59,14 +59,14 @@ Q_SIGNALS: void value_changed(); private: - const char *const _suffix; + const char *const suffix_; - QHBoxLayout _layout; + QHBoxLayout layout_; - QDoubleSpinBox _value; - QComboBox _list; + QDoubleSpinBox value_; + QComboBox list_; - ValueType _value_type; + ValueType value_type_; }; } // widgets diff --git a/signalhandler.cpp b/signalhandler.cpp index a236535c..475f49b0 100644 --- a/signalhandler.cpp +++ b/signalhandler.cpp @@ -29,11 +29,11 @@ #include #include -int SignalHandler::_sockets[2]; +int SignalHandler::sockets_[2]; bool SignalHandler::prepare_signals() { - if(socketpair(AF_UNIX, SOCK_STREAM, 0, _sockets) != 0) + if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets_) != 0) return false; struct sigaction sig_action; @@ -44,8 +44,8 @@ bool SignalHandler::prepare_signals() if(sigaction(SIGINT, &sig_action, 0) != 0 || sigaction(SIGTERM, &sig_action, 0) != 0) { - close(_sockets[0]); - close(_sockets[1]); + close(sockets_[0]); + close(sockets_[1]); return false; } @@ -53,20 +53,20 @@ bool SignalHandler::prepare_signals() } SignalHandler::SignalHandler(QObject* parent) : QObject(parent), - _socket_notifier(0) + socket_notifier_(0) { - _socket_notifier = new QSocketNotifier(_sockets[1], + socket_notifier_ = new QSocketNotifier(sockets_[1], QSocketNotifier::Read, this); - connect(_socket_notifier, SIGNAL(activated(int)), + connect(socket_notifier_, SIGNAL(activated(int)), SLOT(on_socket_notifier_activated())); } void SignalHandler::on_socket_notifier_activated() { - _socket_notifier->setEnabled(false); + socket_notifier_->setEnabled(false); int sig_number; - if(read(_sockets[1], &sig_number, sizeof(int)) != + if(read(sockets_[1], &sig_number, sizeof(int)) != sizeof(int)) { qDebug() << "Failed to catch signal"; abort(); @@ -82,12 +82,12 @@ void SignalHandler::on_socket_notifier_activated() break; } - _socket_notifier->setEnabled(true); + socket_notifier_->setEnabled(true); } void SignalHandler::handle_signals(int sig_number) { - if(write(_sockets[0], &sig_number, sizeof(int)) != + if(write(sockets_[0], &sig_number, sizeof(int)) != sizeof(int)) { // Failed to handle signal abort(); diff --git a/signalhandler.h b/signalhandler.h index 9ca995f7..fe54ff2a 100644 --- a/signalhandler.h +++ b/signalhandler.h @@ -46,10 +46,10 @@ private: static void handle_signals(int sig_number); private: - QSocketNotifier* _socket_notifier; + QSocketNotifier* socket_notifier_; private: - static int _sockets[2]; + static int sockets_[2]; }; #endif // SIGNALHANDLER_H diff --git a/test/data/analogsnapshot.cpp b/test/data/analogsnapshot.cpp index 200d262b..159050aa 100644 --- a/test/data/analogsnapshot.cpp +++ b/test/data/analogsnapshot.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK(s.get_sample_count() == 0); for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++) { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; + const AnalogSnapshot::Envelope &m = s.envelope_levels_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.samples == NULL); @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(Basic) // There should not be enough samples to have a single mip map sample for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++) { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; + const AnalogSnapshot::Envelope &m = s.envelope_levels_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.samples == NULL); @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(Basic) // There should now be enough data for exactly one sample // in mip map level 0, and that sample should be 0 - const AnalogSnapshot::Envelope &e0 = s._envelope_levels[0]; + const AnalogSnapshot::Envelope &e0 = s.envelope_levels_[0]; BOOST_CHECK_EQUAL(e0.length, 1); BOOST_CHECK_EQUAL(e0.data_length, AnalogSnapshot::EnvelopeDataUnit); BOOST_REQUIRE(e0.samples != NULL); @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(Basic) // The higher levels should still be empty for (unsigned int i = 1; i < AnalogSnapshot::ScaleStepCount; i++) { - const AnalogSnapshot::Envelope &m = s._envelope_levels[i]; + const AnalogSnapshot::Envelope &m = s.envelope_levels_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.samples == NULL); @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK_EQUAL(e0.samples[i].max, -1.0f); } - const AnalogSnapshot::Envelope &e1 = s._envelope_levels[1]; + const AnalogSnapshot::Envelope &e1 = s.envelope_levels_[1]; BOOST_CHECK_EQUAL(e1.length, 1); BOOST_CHECK_EQUAL(e1.data_length, AnalogSnapshot::EnvelopeDataUnit); BOOST_REQUIRE(e1.samples != NULL); diff --git a/test/data/decoderstack.cpp b/test/data/decoderstack.cpp index 0fc0da39..09f047d5 100644 --- a/test/data/decoderstack.cpp +++ b/test/data/decoderstack.cpp @@ -70,8 +70,8 @@ BOOST_AUTO_TEST_CASE(TwoDecoderStack) BOOST_REQUIRE(dec1); // Wait for the decode threads to complete - dec0->_decode_thread.join(); - dec1->_decode_thread.join(); + dec0->decode_thread_.join(); + dec1->decode_thread_.join(); // Check there were no errors BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true); diff --git a/test/data/logicsnapshot.cpp b/test/data/logicsnapshot.cpp index 7b7d4e7f..1b5eb24a 100644 --- a/test/data/logicsnapshot.cpp +++ b/test/data/logicsnapshot.cpp @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(Basic) BOOST_CHECK(s.get_sample_count() == 0); for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(Basic) // There should not be enough samples to have a single mip map sample for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); @@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(Basic) // There should now be enough data for exactly one sample // in mip map level 0, and that sample should be 0 - const LogicSnapshot::MipMapLevel &m0 = s._mip_map[0]; + const LogicSnapshot::MipMapLevel &m0 = s.mip_map_[0]; BOOST_CHECK_EQUAL(m0.length, 1); BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit); BOOST_REQUIRE(m0.data != NULL); @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(Basic) // The higher levels should still be empty for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(Basic) for (unsigned int i = 2; i < m0.length; i++) BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[i], 0); - const LogicSnapshot::MipMapLevel &m1 = s._mip_map[1]; + const LogicSnapshot::MipMapLevel &m1 = s.mip_map_[1]; BOOST_CHECK_EQUAL(m1.length, 1); BOOST_CHECK_EQUAL(m1.data_length, LogicSnapshot::MipMapDataUnit); BOOST_REQUIRE(m1.data != NULL); @@ -173,13 +173,13 @@ BOOST_AUTO_TEST_CASE(LargeData) BOOST_CHECK(s.get_sample_count() == Length); // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 62500); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[0].length, 62500); + BOOST_CHECK_EQUAL(s.mip_map_[0].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); + BOOST_REQUIRE(s.mip_map_[0].data != NULL); prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[0].length;) + for (unsigned int i = 0; i < s.mip_map_[0].length;) { BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); @@ -188,7 +188,7 @@ BOOST_AUTO_TEST_CASE(LargeData) prev_sample ^ sample); prev_sample = sample; - for (int j = 1; i < s._mip_map[0].length && j < 16; j++) + for (int j = 1; i < s.mip_map_[0].length && j < 16; j++) { BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0); @@ -196,13 +196,13 @@ BOOST_AUTO_TEST_CASE(LargeData) } // Check mip map level 1 - BOOST_CHECK_EQUAL(s._mip_map[1].length, 3906); - BOOST_CHECK_EQUAL(s._mip_map[1].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[1].length, 3906); + BOOST_CHECK_EQUAL(s.mip_map_[1].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[1].data != NULL); + BOOST_REQUIRE(s.mip_map_[1].data != NULL); prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[1].length; i++) + for (unsigned int i = 0; i < s.mip_map_[1].length; i++) { BOOST_TEST_MESSAGE("Testing mip_map[1].data[" << i << "]"); @@ -214,13 +214,13 @@ BOOST_AUTO_TEST_CASE(LargeData) } // Check mip map level 2 - BOOST_CHECK_EQUAL(s._mip_map[2].length, 244); - BOOST_CHECK_EQUAL(s._mip_map[2].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[2].length, 244); + BOOST_CHECK_EQUAL(s.mip_map_[2].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[2].data != NULL); + BOOST_REQUIRE(s.mip_map_[2].data != NULL); prev_sample = 0; - for (unsigned int i = 0; i < s._mip_map[2].length; i++) + for (unsigned int i = 0; i < s.mip_map_[2].length; i++) { BOOST_TEST_MESSAGE("Testing mip_map[2].data[" << i << "]"); @@ -232,19 +232,19 @@ BOOST_AUTO_TEST_CASE(LargeData) } // Check mip map level 3 - BOOST_CHECK_EQUAL(s._mip_map[3].length, 15); - BOOST_CHECK_EQUAL(s._mip_map[3].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[3].length, 15); + BOOST_CHECK_EQUAL(s.mip_map_[3].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[3].data != NULL); + BOOST_REQUIRE(s.mip_map_[3].data != NULL); - for (unsigned int i = 0; i < s._mip_map[3].length; i++) - BOOST_CHECK_EQUAL(*((uint8_t*)s._mip_map[3].data + i), + for (unsigned int i = 0; i < s.mip_map_[3].length; i++) + BOOST_CHECK_EQUAL(*((uint8_t*)s.mip_map_[3].data + i), 0xFF); // Check the higher levels for (unsigned int i = 4; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); @@ -298,17 +298,17 @@ BOOST_AUTO_TEST_CASE(Pulses) //----- Check the mip-map -----// // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 12); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12); + BOOST_CHECK_EQUAL(s.mip_map_[0].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); + BOOST_REQUIRE(s.mip_map_[0].data != NULL); - for (unsigned int i = 0; i < s._mip_map[0].length;) { + for (unsigned int i = 0; i < s.mip_map_[0].length;) { BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]"); BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0xFF); for (int j = 1; - i < s._mip_map[0].length && + i < s.mip_map_[0].length && j < Period/LogicSnapshot::MipMapScaleFactor; j++) { BOOST_TEST_MESSAGE( "Testing mip_map[0].data[" << i << "]"); @@ -318,7 +318,7 @@ BOOST_AUTO_TEST_CASE(Pulses) // Check the higher levels are all inactive for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); @@ -362,19 +362,19 @@ BOOST_AUTO_TEST_CASE(LongPulses) //----- Check the mip-map -----// // Check mip map level 0 - BOOST_CHECK_EQUAL(s._mip_map[0].length, 12); - BOOST_CHECK_EQUAL(s._mip_map[0].data_length, + BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12); + BOOST_CHECK_EQUAL(s.mip_map_[0].data_length, LogicSnapshot::MipMapDataUnit); - BOOST_REQUIRE(s._mip_map[0].data != NULL); + BOOST_REQUIRE(s.mip_map_[0].data != NULL); - for (unsigned int i = 0; i < s._mip_map[0].length;) { - for (j = 0; i < s._mip_map[0].length && j < 2; j++) { + for (unsigned int i = 0; i < s.mip_map_[0].length;) { + for (j = 0; i < s.mip_map_[0].length && j < 2; j++) { BOOST_TEST_MESSAGE( "Testing mip_map[0].data[" << i << "]"); BOOST_CHECK_EQUAL(s.get_subsample(0, i++), ~0); } - for (; i < s._mip_map[0].length && + for (; i < s.mip_map_[0].length && j < Period/LogicSnapshot::MipMapScaleFactor; j++) { BOOST_TEST_MESSAGE( "Testing mip_map[0].data[" << i << "]"); @@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(LongPulses) // Check the higher levels are all inactive for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) { - const LogicSnapshot::MipMapLevel &m = s._mip_map[i]; + const LogicSnapshot::MipMapLevel &m = s.mip_map_[i]; BOOST_CHECK_EQUAL(m.length, 0); BOOST_CHECK_EQUAL(m.data_length, 0); BOOST_CHECK(m.data == NULL); -- 2.30.2