]> sigrok.org Git - pulseview.git/blobdiff - pv/subwindows/decoder_selector/subwindow.cpp
DecoderSelector: Use proxy model to permit sorting
[pulseview.git] / pv / subwindows / decoder_selector / subwindow.cpp
index f669146d56eab408c4a33548340cabf23fdc900d..375e749e789b9860af5988f07422a42c404d5ea9 100644 (file)
@@ -52,7 +52,8 @@ SubWindow::SubWindow(Session& session, QWidget* parent) :
        info_label_header_(new QLabel()),
        info_label_body_(new QLabel()),
        info_label_footer_(new QLabel()),
        info_label_header_(new QLabel()),
        info_label_body_(new QLabel()),
        info_label_footer_(new QLabel()),
-       model_(new DecoderCollectionModel())
+       model_(new DecoderCollectionModel()),
+       sort_filter_model_(new QSortFilterProxyModel())
 {
        QVBoxLayout* root_layout = new QVBoxLayout(this);
        root_layout->setContentsMargins(0, 0, 0, 0);
 {
        QVBoxLayout* root_layout = new QVBoxLayout(this);
        root_layout->setContentsMargins(0, 0, 0, 0);
@@ -62,8 +63,12 @@ SubWindow::SubWindow(Session& session, QWidget* parent) :
        splitter_->addWidget(tree_view_);
        splitter_->addWidget(info_box_);
 
        splitter_->addWidget(tree_view_);
        splitter_->addWidget(info_box_);
 
-       tree_view_->setModel(model_);
+       sort_filter_model_->setSourceModel(model_);
+
+       tree_view_->setModel(sort_filter_model_);
        tree_view_->setRootIsDecorated(true);
        tree_view_->setRootIsDecorated(true);
+       tree_view_->setSortingEnabled(true);
+       tree_view_->sortByColumn(0, Qt::AscendingOrder);
 
        // Hide the columns that hold the detailed item information
        tree_view_->hideColumn(2);  // ID
 
        // Hide the columns that hold the detailed item information
        tree_view_->hideColumn(2);  // ID