ATLAS Offline Software
VP1CollectionWidget.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 // //
8 // Header file for class VP1CollectionWidget //
9 // //
10 // Description: Convenience widget which displays lists of //
11 // available collections. //
12 // Is meant to be used with VP1Collection's. //
13 // //
14 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
15 // Initial version: June 2008 //
16 // //
18 
19 #ifndef VP1COLLECTIONWIDGET_H
20 #define VP1COLLECTIONWIDGET_H
21 
22 #include "VP1Base/VP1Collection.h"
24 
25 #include <QWidget>
26 #include <QList>
27 #include <QString>
28 
29 
30 class VP1StdCollection;
31 
32 class VP1CollectionWidget : public QWidget, public VP1HelperClassBase {
33 
34  Q_OBJECT
35 
36 public:
37 
38  VP1CollectionWidget(QWidget * parent = 0);
39  virtual ~VP1CollectionWidget();
40 
41  void clear( bool deleteCollections = true, bool deleteGuiElements = false );//Call at systemerase if collections are event data.
42  //deleteGuiElements==true => the widgets supplied by
43  //widgetsForGuiRow() will be deleted.
44  void addStateInfo(const VP1CollStates&, bool overwritesExisting = true );
45  void setCollections(const QList<VP1Collection*>&, bool applySavedStates = true );//call at refresh cycle.
46 
47  void addCollections(const QList<VP1Collection*>&, bool applySavedStates = true );//dynamically add new available collections (i.e. those appearing after refits)
48 
49  VP1CollStates states() const;
50 
51  const QList<VP1Collection*>& collections() const;
52 
53  int appropriateFixedWidth() const;
54 
55  //Convenience:
56  template <class collT>
57  void setCollections(const QList<collT*>& colls, bool applySavedStates = true ) {
58  setCollections(VP1Collection::toBaseCollList(colls), applySavedStates);
59  }
60  //Convenience:
61  template <class collT>
62  void addCollections(const QList<collT*>& colls, bool applySavedStates = true ) {
63  addCollections(VP1Collection::toBaseCollList(colls), applySavedStates);
64  }
65 
66  //NB: If the cast from VP1Collection to collT fails, returned number
67  //of collections might be less than the actual number of
68  //collections.
69  template <class collT>
70  QList<collT*> collections() const {
71  QList<collT*> l;
72  for(VP1Collection*col : collections()) {
73  collT* c = dynamic_cast<collT*>(col);
74  if (c) l << c;
75  }
76  return l;
77  }
78 
79 protected:
80  virtual void sortSections(QList<QString>&) {}//Reimplement and sort list if specific sorting is needed.
81  //Utility methods for use in sortSections(..) reimplementations:
82  static void ensureFirst(const QString& wildcard,QList<QString>&);
83  static void ensureLast(const QString& wildcard,QList<QString>&);
84 
85 //The next methods and signals are only interesting if (some of) your
86 //collections inherit from VP1StdCollection. In that case, it will let
87 //you know which and which types are currently visible, allowing for
88 //instance the controller to adapt itself:
89 public:
90  QList<qint32> visibleStdCollectionTypes() const;
91  QList<VP1StdCollection*> visibleStdCollections() const;
92 signals:
93  void visibleStdCollectionTypesChanged(const QList<qint32>&);
94  void visibleStdCollectionsChanged(const QList<VP1StdCollection*>&);
95  void visibleContentsChanged();//We need it to resize scroll areas
96 protected Q_SLOTS:
98 
99 private:
102  class Imp;
103  Imp * m_d;
104 };
105 
106 #endif
VP1CollStates
QMap< QByteArray, QByteArray > VP1CollStates
Definition: VP1Collection.h:27
VP1CollectionWidget::Imp
Definition: VP1CollectionWidget.cxx:29
VP1CollectionWidget::visibleStdCollectionsChanged
void visibleStdCollectionsChanged(const QList< VP1StdCollection * > &)
VP1CollectionWidget::setCollections
void setCollections(const QList< collT * > &colls, bool applySavedStates=true)
Definition: VP1CollectionWidget.h:57
VP1CollectionWidget::sortSections
virtual void sortSections(QList< QString > &)
Definition: VP1CollectionWidget.h:80
VP1CollectionWidget::addCollections
void addCollections(const QList< collT * > &colls, bool applySavedStates=true)
Definition: VP1CollectionWidget.h:62
VP1CollectionWidget::setCollections
void setCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
Definition: VP1CollectionWidget.cxx:258
VP1CollectionWidget::VP1CollectionWidget
VP1CollectionWidget(QWidget *parent=0)
Definition: VP1CollectionWidget.cxx:49
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1CollectionWidget::collections
QList< collT * > collections() const
Definition: VP1CollectionWidget.h:70
VP1Collection.h
VP1CollectionWidget::clear
void clear(bool deleteCollections=true, bool deleteGuiElements=false)
Definition: VP1CollectionWidget.cxx:81
VP1CollectionWidget::operator=
VP1CollectionWidget & operator=(const VP1CollectionWidget &)
HitType::wildcard
@ wildcard
VP1CollectionWidget::ensureLast
static void ensureLast(const QString &wildcard, QList< QString > &)
Definition: VP1CollectionWidget.cxx:377
VP1CollectionWidget::addStateInfo
void addStateInfo(const VP1CollStates &, bool overwritesExisting=true)
Definition: VP1CollectionWidget.cxx:289
VP1CollectionWidget::visibleStdCollectionTypes
QList< qint32 > visibleStdCollectionTypes() const
Definition: VP1CollectionWidget.cxx:324
VP1CollectionWidget::possibleChange_visibleStdCollections
void possibleChange_visibleStdCollections()
Definition: VP1CollectionWidget.cxx:341
VP1Collection::toBaseCollList
static QList< VP1Collection * > toBaseCollList(const QList< T * > &)
Definition: VP1Collection.h:80
VP1CollectionWidget::~VP1CollectionWidget
virtual ~VP1CollectionWidget()
Definition: VP1CollectionWidget.cxx:55
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1CollectionWidget::states
VP1CollStates states() const
Definition: VP1CollectionWidget.cxx:304
VP1CollectionWidget::appropriateFixedWidth
int appropriateFixedWidth() const
Definition: VP1CollectionWidget.cxx:276
VP1CollectionWidget::m_d
Imp * m_d
Definition: VP1CollectionWidget.h:102
python.L1.Config.LegacyTopoMergerMap.signals
signals
Definition: LegacyTopoMergerMap.py:13
VP1HelperClassBase
Definition: VP1HelperClassBase.h:28
VP1Collection
Definition: VP1Collection.h:31
VP1CollectionWidget::visibleStdCollections
QList< VP1StdCollection * > visibleStdCollections() const
Definition: VP1CollectionWidget.cxx:330
VP1CollectionWidget::collections
const QList< VP1Collection * > & collections() const
Definition: VP1CollectionWidget.cxx:61
VP1HelperClassBase.h
query_example.col
col
Definition: query_example.py:7
VP1CollectionWidget::addCollections
void addCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
Definition: VP1CollectionWidget.cxx:237
VP1CollectionWidget::VP1CollectionWidget
VP1CollectionWidget(const VP1CollectionWidget &)
VP1CollectionWidget
Definition: VP1CollectionWidget.h:32
VP1CollectionWidget::ensureFirst
static void ensureFirst(const QString &wildcard, QList< QString > &)
Definition: VP1CollectionWidget.cxx:361
VP1StdCollection
Definition: VP1StdCollection.h:31
VP1CollectionWidget::visibleContentsChanged
void visibleContentsChanged()
python.compressB64.c
def c
Definition: compressB64.py:93
VP1CollectionWidget::visibleStdCollectionTypesChanged
void visibleStdCollectionTypesChanged(const QList< qint32 > &)