]> sigrok.org Git - pulseview.git/commitdiff
TabularDecModel: Fix multi-row selection issue
authorSoeren Apel <redacted>
Thu, 23 Apr 2020 22:10:53 +0000 (00:10 +0200)
committerUwe Hermann <redacted>
Sun, 3 May 2020 15:20:55 +0000 (17:20 +0200)
pv/subwindows/decoder_selector/model.cpp
pv/views/tabular_decoder/model.cpp
pv/views/tabular_decoder/view.cpp
pv/views/tabular_decoder/view.hpp

index ebdfd9d7d387635c442be8cabedaa6cebc5016e3..2a4182b05840462e2c8a38f9285a26af19f792a9 100644 (file)
@@ -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();
index 0c89cef314f3a8547dfdad3659a90fc1c21676cc..ffd151a5300c4278a297a45fe040b84f22e4e246 100644 (file)
@@ -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();
index 5446ff8e248a7781606b78717a9c8eca318efa9e..00f6e20a5d00120381d61a36fa134eaf2e945c7a 100644 (file)
@@ -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
index c08b71367dd815d7bbd9b34a0cf04809ae85665a..9c251382c675bbb2e2cb074dbde47016eb02afc7 100644 (file)
@@ -152,7 +152,6 @@ private:
 
        data::DecodeSignal* signal_;
        const data::decode::Decoder* decoder_;
-       bool updating_data_;
 };
 
 } // namespace tabular_decoder