From: Soeren Apel Date: Thu, 23 Apr 2020 22:10:53 +0000 (+0200) Subject: TabularDecModel: Fix multi-row selection issue X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=6d46525fb5566856d01deac5a7787699b17cc4e4 TabularDecModel: Fix multi-row selection issue --- diff --git a/pv/subwindows/decoder_selector/model.cpp b/pv/subwindows/decoder_selector/model.cpp index ebdfd9d7..2a4182b0 100644 --- a/pv/subwindows/decoder_selector/model.cpp +++ b/pv/subwindows/decoder_selector/model.cpp @@ -142,7 +142,7 @@ Qt::ItemFlags DecoderCollectionModel::flags(const QModelIndex& index) const QVariant DecoderCollectionModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) return root_->data(section); return QVariant(); diff --git a/pv/views/tabular_decoder/model.cpp b/pv/views/tabular_decoder/model.cpp index 0c89cef3..ffd151a5 100644 --- a/pv/views/tabular_decoder/model.cpp +++ b/pv/views/tabular_decoder/model.cpp @@ -80,7 +80,7 @@ QVariant AnnotationCollectionModel::data_from_ann(const Annotation* ann, int ind QVariant AnnotationCollectionModel::data(const QModelIndex& index, int role) const { - if (!index.isValid() || !signal_) + if (!signal_ || !index.isValid() || !index.internalPointer()) return QVariant(); const Annotation* ann = @@ -118,7 +118,7 @@ Qt::ItemFlags AnnotationCollectionModel::flags(const QModelIndex& index) const QVariant AnnotationCollectionModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) return header_data_.at(section); return QVariant(); @@ -128,6 +128,8 @@ QModelIndex AnnotationCollectionModel::index(int row, int column, const QModelIndex& parent_idx) const { (void)parent_idx; + assert(row >= 0); + assert(column >= 0); if (!all_annotations_) return QModelIndex(); diff --git a/pv/views/tabular_decoder/view.cpp b/pv/views/tabular_decoder/view.cpp index 5446ff8e..00f6e20a 100644 --- a/pv/views/tabular_decoder/view.cpp +++ b/pv/views/tabular_decoder/view.cpp @@ -86,8 +86,7 @@ View::View(Session &session, bool is_main_view, QMainWindow *parent) : save_action_(new QAction(this)), table_view_(new QCustomTableView()), model_(new AnnotationCollectionModel()), - signal_(nullptr), - updating_data_(false) + signal_(nullptr) { QVBoxLayout *root_layout = new QVBoxLayout(this); root_layout->setContentsMargins(0, 0, 0, 0); @@ -241,18 +240,7 @@ void View::reset_data() void View::update_data() { - if (updating_data_) { - if (!delayed_view_updater_.isActive()) - delayed_view_updater_.start(); - return; - } - - updating_data_ = true; - - table_view_->setRootIndex(model_->index(1, 0, QModelIndex())); model_->set_signal_and_segment(signal_, current_segment_); - - updating_data_ = false; } void View::save_data_as_csv(unsigned int save_type) const diff --git a/pv/views/tabular_decoder/view.hpp b/pv/views/tabular_decoder/view.hpp index c08b7136..9c251382 100644 --- a/pv/views/tabular_decoder/view.hpp +++ b/pv/views/tabular_decoder/view.hpp @@ -152,7 +152,6 @@ private: data::DecodeSignal* signal_; const data::decode::Decoder* decoder_; - bool updating_data_; }; } // namespace tabular_decoder