ATLAS Offline Software
Loading...
Searching...
No Matches
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>
11
12class QWidget;
13class QToolBox;
14
15class ZappedVolumeListModel : public QAbstractListModel {
16
17 Q_OBJECT
18
19public:
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
33public Q_SLOTS:
34 void activated(const QModelIndex&);
35
36private:
37
38 QList<VolumeHandle*> m_zappedhandles;
39};
40
42// INLINES //
44
45inline int ZappedVolumeListModel::rowCount ( const QModelIndex & parent ) const
46{
47 return parent.isValid() ? 0 : m_zappedhandles.count();
48}
49
50inline Qt::ItemFlags ZappedVolumeListModel::flags ( const QModelIndex & index ) const
51{
52 return index.isValid() ? (Qt::ItemIsEnabled|Qt::ItemIsSelectable) : Qt::ItemFlags();
53}
54
55
56inline 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
62{
63 beginResetModel(); // see: http://doc.qt.io/qt-5/qabstractitemmodel-obsolete.html
64 m_zappedhandles << handle;
65 endResetModel();
66}
67
69{
70 beginResetModel();
71 m_zappedhandles.removeAll(handle);
72 endResetModel();
73}
74
75#endif
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
void activated(const QModelIndex &)
int rowCount(const QModelIndex &parent=QModelIndex()) const
QList< VolumeHandle * > m_zappedhandles
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
ZappedVolumeListModel(QObject *parent=0)
void addToZappedVolumes(VolumeHandle *)
void removeFromZappedVolumes(VolumeHandle *)
Qt::ItemFlags flags(const QModelIndex &index) const
Definition index.py:1