Developer documentation
Version 3.0.3-105-gd3941f44
node_list.h
Go to the documentation of this file.
1/* Copyright (c) 2008-2022 the MRtrix3 contributors.
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 *
7 * Covered Software is provided under this License on an "as is"
8 * basis, without warranty of any kind, either expressed, implied, or
9 * statutory, including, without limitation, warranties that the
10 * Covered Software is free of defects, merchantable, fit for a
11 * particular purpose or non-infringing.
12 * See the Mozilla Public License v. 2.0 for more details.
13 *
14 * For more details, see http://www.mrtrix.org/.
15 */
16
17#ifndef __gui_mrview_tool_connectome_node_list_h__
18#define __gui_mrview_tool_connectome_node_list_h__
19
20#include <memory>
21
24
25#include <QAbstractItemModel>
26#include <QTableView>
27
28
29namespace MR
30{
31 namespace GUI
32 {
33 namespace MRView
34 {
35
36 class Window;
37
38 namespace Tool
39 {
40
41
42 class Connectome;
43
44
45 class Node_list_model : public QAbstractItemModel
47 public:
48
50
51 QVariant data (const QModelIndex& index, int role) const override;
52 QVariant headerData (int section, Qt::Orientation orientation, int role) const override;
53
54 Qt::ItemFlags flags (const QModelIndex& index) const override {
55 if (!index.isValid()) return {};
56 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
57 }
58
59 QModelIndex parent (const QModelIndex&) const override {
60 return {};
61 }
62
63 int rowCount (const QModelIndex& parent = QModelIndex()) const override;
64 int columnCount (const QModelIndex& parent = QModelIndex()) const override;
65
66 QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex()) const override {
67 (void ) parent;
68 return createIndex (row, column);
69 }
70
71 void clear()
72 {
73 beginRemoveRows (QModelIndex(), 0, rowCount()-1);
74 endRemoveRows();
75 }
76
77 void initialize()
78 {
79 beginInsertRows (QModelIndex(), 0, rowCount()-1);
80 endInsertRows();
81 }
82
83 void reset_pixmaps();
84
85 private:
86 Connectome& connectome;
87 };
88
89
90 class Node_list_view : public QTableView
92 public:
93 Node_list_view (QWidget* parent) :
94 QTableView (parent) { }
95 void setModel (QAbstractItemModel* model)
96 {
97 QTableView::setModel (model);
98 //setColumnWidth (0, model->original_headerData (0, Qt::Horizontal, Qt::SizeHintRole).toInt());
99 //setColumnWidth (1, model->original_headerData (1, Qt::Horizontal, Qt::SizeHintRole).toInt());
100 }
101 };
102
103
104
105 class Node_list : public Tool::Base
107
108 Q_OBJECT
109
110 public:
112
113 void initialize();
114 void colours_changed();
115 int row_height() const;
116
117 private slots:
118 void clear_selection_slot();
119 void node_selection_changed_slot (const QItemSelection&, const QItemSelection&);
120 void node_selection_settings_dialog_slot();
121
122 private:
123 Connectome& connectome;
124
125 QPushButton *clear_selection_button;
126 QPushButton *node_selection_settings_button;
127 Node_list_model *node_list_model;
128 Node_list_view *node_list_view;
129
130 // Settings related to how visual elements are changed on selection / non-selection
131 std::unique_ptr<NodeSelectionSettingsDialog> node_selection_dialog;
132
133 };
134
135
136
137 }
138 }
139 }
140}
141
142#endif
143
144
145
void setModel(QAbstractItemModel *model)
Definition: node_list.h:95
#define NOMEMALIGN
Definition: memory.h:22
Definition: base.h:24
size_t index
#define MEMALIGN(...)
Definition: types.h:185