Developer documentation
Version 3.0.3-105-gd3941f44
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_dialog_list_h__
18#define __gui_dialog_list_h__
19
20#include "gui/gui.h"
21#include "gui/opengl/gl.h"
22
23namespace MR
24{
25 namespace GUI
26 {
27 namespace Dialog
28 {
29
32 public:
33 TreeItem (const std::string& key, const std::string& value, TreeItem* parent = 0) {
34 parentItem = parent;
35 itemData << qstr (key) << qstr (value);
36 }
38 qDeleteAll (childItems);
39 }
41 childItems.append (child);
42 }
44 return childItems.value (row);
45 }
46 int childCount () const {
47 return childItems.count();
48 }
49 int columnCount () const {
50 return itemData.count();
51 }
52 QVariant data (int column) const {
53 return itemData.value (column);
54 }
55 int row () const {
56 if (parentItem)
57 return parentItem->childItems.indexOf (const_cast<TreeItem*> (this));
58 return 0;
59 }
61 return parentItem;
62 }
63
64 private:
65 QList<TreeItem*> childItems;
66 QList<QVariant> itemData;
67 TreeItem* parentItem;
68 };
69
70
71 class TreeModel : public QAbstractItemModel
73 public:
74 TreeModel (QObject* parent) : QAbstractItemModel (parent) {
75 rootItem = new TreeItem ("Parameter", "Value");
76 }
78 delete rootItem;
79 }
80 QVariant data (const QModelIndex& index, int role) const;
81 Qt::ItemFlags flags (const QModelIndex& index) const;
82 QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
83 QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex()) const;
84 QModelIndex parent (const QModelIndex& index) const;
85 int rowCount (const QModelIndex& parent = QModelIndex()) const;
86 int columnCount (const QModelIndex& parent = QModelIndex()) const;
88 };
89
90 }
91 }
92}
93
94#endif
95
96
97
TreeItem * child(int row)
Definition: list.h:43
void appendChild(TreeItem *child)
Definition: list.h:40
TreeItem * parent()
Definition: list.h:60
int columnCount() const
Definition: list.h:49
int row() const
Definition: list.h:55
TreeItem(const std::string &key, const std::string &value, TreeItem *parent=0)
Definition: list.h:33
QVariant data(int column) const
Definition: list.h:52
int childCount() const
Definition: list.h:46
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Qt::ItemFlags flags(const QModelIndex &index) const
int columnCount(const QModelIndex &parent=QModelIndex()) const
TreeModel(QObject *parent)
Definition: list.h:74
QVariant data(const QModelIndex &index, int role) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
TreeItem * rootItem
Definition: list.h:87
QModelIndex parent(const QModelIndex &index) const
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
Definition: SH.h:233
#define NOMEMALIGN
Definition: memory.h:22
QString qstr(const std::string &s)
Definition: gui.h:31
Definition: base.h:24