ATLAS Offline Software
Loading...
Searching...
No Matches
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
24
25#include <QWidget>
26#include <QList>
27#include <QString>
28
29
31
32class VP1CollectionWidget : public QWidget, public VP1HelperClassBase {
33
34 Q_OBJECT
35
36public:
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
79protected:
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:
89public:
90 QList<qint32> visibleStdCollectionTypes() const;
91 QList<VP1StdCollection*> visibleStdCollections() const;
92signals:
93 void visibleStdCollectionTypesChanged(const QList<qint32>&);
94 void visibleStdCollectionsChanged(const QList<VP1StdCollection*>&);
95 void visibleContentsChanged();//We need it to resize scroll areas
96protected Q_SLOTS:
98
99private:
102 class Imp;
104};
105
106#endif
QMap< QByteArray, QByteArray > VP1CollStates
void setCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
void visibleStdCollectionsChanged(const QList< VP1StdCollection * > &)
VP1CollectionWidget(QWidget *parent=0)
void addCollections(const QList< VP1Collection * > &, bool applySavedStates=true)
VP1CollectionWidget(const VP1CollectionWidget &)
void addStateInfo(const VP1CollStates &, bool overwritesExisting=true)
void addCollections(const QList< collT * > &colls, bool applySavedStates=true)
void setCollections(const QList< collT * > &colls, bool applySavedStates=true)
VP1CollectionWidget & operator=(const VP1CollectionWidget &)
void visibleStdCollectionTypesChanged(const QList< qint32 > &)
const QList< VP1Collection * > & collections() const
static void ensureFirst(const QString &wildcard, QList< QString > &)
QList< qint32 > visibleStdCollectionTypes() const
static void ensureLast(const QString &wildcard, QList< QString > &)
QList< collT * > collections() const
virtual void sortSections(QList< QString > &)
QList< VP1StdCollection * > visibleStdCollections() const
VP1CollStates states() const
void clear(bool deleteCollections=true, bool deleteGuiElements=false)
void visibleContentsChanged()
static QList< VP1Collection * > toBaseCollList(const QList< T * > &)
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")