Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkModulesDialog.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "QmitkModulesDialog.h"
14 
15 #include <QDialogButtonBox>
16 #include <QHBoxLayout>
17 #include <QHeaderView>
18 #include <QSortFilterProxyModel>
19 #include <QTableView>
20 
21 #include "QmitkModuleTableModel.h"
22 
23 QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
24 {
25  this->setWindowTitle("MITK Modules");
26 
27  auto layout = new QVBoxLayout();
28  this->setLayout(layout);
29 
30  auto tableView = new QTableView(this);
31  auto tableModel = new QmitkModuleTableModel(tableView);
32  auto sortProxyModel = new QSortFilterProxyModel(tableView);
33  sortProxyModel->setSourceModel(tableModel);
34  sortProxyModel->setDynamicSortFilter(true);
35  tableView->setModel(sortProxyModel);
36 
37  tableView->verticalHeader()->hide();
38  tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
39  tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
40  tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
41  tableView->setTextElideMode(Qt::ElideMiddle);
42  tableView->setSortingEnabled(true);
43  tableView->sortByColumn(0, Qt::AscendingOrder);
44 
45  tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
46  tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
47  tableView->horizontalHeader()->setStretchLastSection(true);
48  tableView->horizontalHeader()->setCascadingSectionResizes(true);
49 
50  layout->addWidget(tableView);
51 
52  auto btnBox = new QDialogButtonBox(QDialogButtonBox::Close);
53  layout->addWidget(btnBox);
54 
55  this->resize(800, 600);
56 
57  connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
58 }
QmitkModulesDialog(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint)