Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkModulesDialog.h"
18 
19 #include <QDialogButtonBox>
20 #include <QHBoxLayout>
21 #include <QHeaderView>
22 #include <QSortFilterProxyModel>
23 #include <QTableView>
24 
25 #include "QmitkModuleTableModel.h"
26 
27 QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
28 {
29  this->setWindowTitle("MITK Modules");
30 
31  auto layout = new QVBoxLayout();
32  this->setLayout(layout);
33 
34  auto tableView = new QTableView(this);
35  auto tableModel = new QmitkModuleTableModel(tableView);
36  auto sortProxyModel = new QSortFilterProxyModel(tableView);
37  sortProxyModel->setSourceModel(tableModel);
38  sortProxyModel->setDynamicSortFilter(true);
39  tableView->setModel(sortProxyModel);
40 
41  tableView->verticalHeader()->hide();
42  tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
43  tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
44  tableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
45  tableView->setTextElideMode(Qt::ElideMiddle);
46  tableView->setSortingEnabled(true);
47  tableView->sortByColumn(0, Qt::AscendingOrder);
48 
49  tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
50  tableView->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
51  tableView->horizontalHeader()->setStretchLastSection(true);
52  tableView->horizontalHeader()->setCascadingSectionResizes(true);
53 
54  layout->addWidget(tableView);
55 
56  auto btnBox = new QDialogButtonBox(QDialogButtonBox::Close);
57  layout->addWidget(btnBox);
58 
59  this->resize(800, 600);
60 
61  connect(btnBox, SIGNAL(rejected()), this, SLOT(reject()));
62 }
QmitkModulesDialog(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint)