ATLAS Offline Software
Loading...
Searching...
No Matches
VP1Collection.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 VP1Collection //
9// //
10// Description: Base class for collection handles. Can be //
11// displayed in VP1CollectionWidget's. //
12// //
13// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
14// Initial version: June 2008 //
15// //
17
18#ifndef VP1COLLECTION_H
19#define VP1COLLECTION_H
20
22
23#include <QByteArray>
24#include <QList>
25#include <QMap>
26#include <QString>
27class QWidget;
28
29typedef QMap<QByteArray,QByteArray> VP1CollStates;//persistifiable id->state
30
32public:
33 VP1Collection( IVP1System * sys = 0, const QString& helperClassName="VP1Collection" );//sys!=0 for messages in gui
34 virtual ~VP1Collection();
35
36 QByteArray persistifiableID() const;//Could essentially contain a SG key, or, when multiple
37 //types go in the same list, key+some integer giving the type
38 QString section() const;//If all collections have empty sections, the collection widget won't make section headers
39
40 QString sectionToolTip() const;//Tooltip to go with the section (NB. provide same tooltip in all instances
41 // providing a given section. It is arbitrary which we use for the tooltip!)
42
43 virtual QByteArray persistifiableState() const = 0;//Provide default implementation based on widget list + version
44 virtual void setState(const QByteArray&) = 0;//Provide default implementation based on widget list + version
45 virtual QList<QWidget*> widgetsForGuiRow() const;
46
47
48protected:
49
50 virtual QList<QWidget*> provideWidgetsForGuiRow() const = 0;//Should never return empty list.
51 virtual QByteArray providePersistifiableID() const = 0; //Will be called exactly once.
52 virtual QString provideSection() const = 0; //Will be called exactly once.
53 virtual QString provideSectionToolTip() const { return ""; }//Will be called exactly once.
54
55private:
56
59 class Imp;
61
62public:
63
65 // Static convenience methods for handling states: //
67
68 static VP1CollStates getStates(const QList<VP1Collection*>&);
69 static void applyStates(const QList<VP1Collection*>&, const VP1CollStates&);
70 static void updateStates(VP1CollStates& state, const VP1CollStates& newInfo);//Similar entries in newInfo will override those in state.
71 template <class T>
72 static QList<VP1Collection*> toBaseCollList( const QList<T*>& );
73};
74
76// INLINES //
78
79template <class T>
80QList<VP1Collection*> VP1Collection::toBaseCollList( const QList<T*>& in)
81{
82 QList<VP1Collection*> l;
83 for (T * t : in)
84 l << static_cast<T*>(t);
85 return l;
86}
87
88#endif
QMap< QByteArray, QByteArray > VP1CollStates
virtual QString provideSectionToolTip() const
virtual ~VP1Collection()
VP1Collection(IVP1System *sys=0, const QString &helperClassName="VP1Collection")
QString section() const
static void updateStates(VP1CollStates &state, const VP1CollStates &newInfo)
static void applyStates(const QList< VP1Collection * > &, const VP1CollStates &)
virtual QByteArray persistifiableState() const =0
QString sectionToolTip() const
static QList< VP1Collection * > toBaseCollList(const QList< T * > &)
VP1Collection(const VP1Collection &)
VP1Collection & operator=(const VP1Collection &)
virtual QString provideSection() const =0
virtual QByteArray providePersistifiableID() const =0
QByteArray persistifiableID() const
virtual QList< QWidget * > provideWidgetsForGuiRow() const =0
virtual void setState(const QByteArray &)=0
static VP1CollStates getStates(const QList< VP1Collection * > &)
virtual QList< QWidget * > widgetsForGuiRow() const
VP1HelperClassBase(IVP1System *sys=0, QString helpername="")
const QString & helperClassName() const