ATLAS Offline Software
graphics
VP1
VP1Systems
VP1GeometrySystems
VP1GeometrySystems
ZappedVolumeListModel.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef ZAPPEDVOLUMELISTMODEL_H
6
#define ZAPPEDVOLUMELISTMODEL_H
7
8
#include <QAbstractListModel>
9
#include <QList>
10
#include "
VP1GeometrySystems/VolumeHandle.h
"
11
12
class
QWidget;
13
class
QToolBox;
14
15
class
ZappedVolumeListModel
:
public
QAbstractListModel {
16
17
Q_OBJECT
18
19
public
:
20
21
ZappedVolumeListModel
(QObject *
parent
= 0);
22
23
virtual
~ZappedVolumeListModel
();
24
25
inline
int
rowCount
(
const
QModelIndex &
parent
= QModelIndex() )
const
;
26
inline
Qt::ItemFlags
flags
(
const
QModelIndex &
index
)
const
;
27
inline
QVariant
data
(
const
QModelIndex &
index
,
int
role = Qt::DisplayRole )
const
;
28
29
//For use by VolumeHandleSharedData's:
30
inline
void
addToZappedVolumes
(
VolumeHandle
* );
//Assumes that the handle is known not to be zapped before.
31
inline
void
removeFromZappedVolumes
(
VolumeHandle
* );
//Assumes that the handle is known to be zapped before.
32
33
public
Q_SLOTS:
34
void
activated
(
const
QModelIndex&);
35
36
private
:
37
38
QList<VolumeHandle*>
m_zappedhandles
;
39
};
40
42
// INLINES //
44
45
inline
int
ZappedVolumeListModel::rowCount
(
const
QModelIndex &
parent
)
const
46
{
47
return
parent
.isValid() ? 0 :
m_zappedhandles
.count();
48
}
49
50
inline
Qt::ItemFlags
ZappedVolumeListModel::flags
(
const
QModelIndex &
index
)
const
51
{
52
return
index
.isValid() ? (Qt::ItemIsEnabled|Qt::ItemIsSelectable) : Qt::ItemFlags();
53
}
54
55
56
inline
QVariant
ZappedVolumeListModel::data
(
const
QModelIndex &
index
,
int
role )
const
57
{
58
return
(role!=Qt::DisplayRole||!
index
.isValid()) ? QVariant() :
m_zappedhandles
.at(
index
.row())->getName();
59
}
60
61
inline
void
ZappedVolumeListModel::addToZappedVolumes
(
VolumeHandle
* handle )
62
{
63
beginResetModel();
// see: http://doc.qt.io/qt-5/qabstractitemmodel-obsolete.html
64
m_zappedhandles
<< handle;
65
endResetModel();
66
}
67
68
inline
void
ZappedVolumeListModel::removeFromZappedVolumes
(
VolumeHandle
* handle )
69
{
70
beginResetModel();
71
m_zappedhandles
.removeAll(handle);
72
endResetModel();
73
}
74
75
#endif
ZappedVolumeListModel::removeFromZappedVolumes
void removeFromZappedVolumes(VolumeHandle *)
Definition:
ZappedVolumeListModel.h:68
ZappedVolumeListModel::m_zappedhandles
QList< VolumeHandle * > m_zappedhandles
Definition:
ZappedVolumeListModel.h:38
index
Definition:
index.py:1
ZappedVolumeListModel::~ZappedVolumeListModel
virtual ~ZappedVolumeListModel()
Definition:
ZappedVolumeListModel.cxx:14
ZappedVolumeListModel::activated
void activated(const QModelIndex &)
Definition:
ZappedVolumeListModel.cxx:19
ZappedVolumeListModel::ZappedVolumeListModel
ZappedVolumeListModel(QObject *parent=0)
Definition:
ZappedVolumeListModel.cxx:8
ZappedVolumeListModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition:
ZappedVolumeListModel.h:56
test_pyathena.parent
parent
Definition:
test_pyathena.py:15
ZappedVolumeListModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition:
ZappedVolumeListModel.h:50
VolumeHandle
Definition:
VolumeHandle.h:21
ZappedVolumeListModel::addToZappedVolumes
void addToZappedVolumes(VolumeHandle *)
Definition:
ZappedVolumeListModel.h:61
ZappedVolumeListModel
Definition:
ZappedVolumeListModel.h:15
ZappedVolumeListModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition:
ZappedVolumeListModel.h:45
VolumeHandle.h
Generated on Thu Nov 7 2024 21:32:16 for ATLAS Offline Software by
1.8.18