ATLAS Offline Software
Loading...
Searching...
No Matches
VP1CollectionWidget::Imp Class Reference
Collaboration diagram for VP1CollectionWidget::Imp:

Public Member Functions

 Imp (VP1CollectionWidget *tc)
QList< qint32 > visibleStdCollectionTypesFromVisStdCols (const QList< VP1StdCollection * > &l) const
void repopulateGUIFromCollections ()
void clearGui (bool deleteGuiElements)
void updateStatesWithCurrentInfo ()

Public Attributes

VP1CollectionWidgettheclass
QWidget * collWidget
int appropriateFixedWidth
QList< QWidget * > widgetsFromCollections
QList< VP1Collection * > collections
VP1CollStates states
QList< qint32 > last_visibleStdCollectionTypes
QList< VP1StdCollection * > last_visibleStdCollections

Detailed Description

Definition at line 29 of file VP1CollectionWidget.cxx.

Constructor & Destructor Documentation

◆ Imp()

VP1CollectionWidget::Imp::Imp ( VP1CollectionWidget * tc)
inline

Definition at line 31 of file VP1CollectionWidget.cxx.

Member Function Documentation

◆ clearGui()

void VP1CollectionWidget::Imp::clearGui ( bool deleteGuiElements)

Definition at line 67 of file VP1CollectionWidget.cxx.

68{
69 if (!deleteGuiElements) {
70 for(QWidget *w : widgetsFromCollections) {
71 w->hide();
72 w->setParent(0);
73 }
74 }
75 delete collWidget;
76 collWidget = 0;
77
78}
QList< QWidget * > widgetsFromCollections

◆ repopulateGUIFromCollections()

void VP1CollectionWidget::Imp::repopulateGUIFromCollections ( )

Definition at line 101 of file VP1CollectionWidget.cxx.

102{
103 theclass->setUpdatesEnabled(false);
104 if (collWidget)
105 clearGui(false);
106
107 collWidget = new QWidget();//We only add the widget in the end (to avoid needless updates).
108
109 QVBoxLayout * vlayout = new QVBoxLayout;
110 vlayout->setSpacing(0);
111 vlayout->setMargin(0);
112 if (collections.isEmpty()) {
113 QHBoxLayout * labellayout = new QHBoxLayout;
114 labellayout->setSpacing(0);
115 labellayout->addWidget(new QLabel("No collections in event."),0,Qt::AlignLeft);
116 labellayout->addStretch(1);
117 vlayout->addLayout(labellayout);
118 }
119
120 QSet<QString> sections;
121 for (VP1Collection* col :collections)
122 sections.insert(col->section());
123 QList<QString> sectionsSorted = sections.values();
124 std::sort(sectionsSorted.begin(), sectionsSorted.end());
125 theclass->sortSections(sectionsSorted);
126
127 const bool nosectionlabels = sectionsSorted.count() == 1 && sectionsSorted.at(0).isEmpty();
128
129 int maxFirstColumnCheckBoxWidth(0);
130 QList<QCheckBox*> firstColumnCheckBoxes;
131
132 int gridmargins(0);
133 for (const QString& section : sectionsSorted) {
134 //type section header:
135 QLabel * sectionlabel(0);
136 if (!nosectionlabels) {
137 QHBoxLayout * labellayout = new QHBoxLayout;
138 labellayout->setSpacing(0);
139 sectionlabel =new QLabel;
140 sectionlabel->setTextFormat(Qt::RichText);
141 sectionlabel->setText("<b>"+section+"</b>");
142 labellayout->addWidget(sectionlabel,0,Qt::AlignLeft);
143 labellayout->addStretch(1);
144 vlayout->addLayout(labellayout);
145 }
146 //Add individual widgets for collections:
147 QGridLayout * gridLayout = new QGridLayout;
148 gridLayout->setHorizontalSpacing(6);
149 gridLayout->setVerticalSpacing(0);
150 gridLayout->setMargin(0);
151 if (!nosectionlabels)
152 gridLayout->addItem(new QSpacerItem(10, 1, QSizePolicy::Fixed, QSizePolicy::Fixed),0,0);
153 vlayout->addLayout(gridLayout);
154 for (VP1Collection* col : collections) {
155 if (col->section()!=section)
156 continue;
157 if (sectionlabel) {
158 if (!col->sectionToolTip().isEmpty())
159 sectionlabel->setToolTip(col->sectionToolTip());
160 sectionlabel = 0;
161 }
162 int newrow = gridLayout->rowCount();
163 int i(1);
164 for (QWidget*w : col->widgetsForGuiRow()) {
165 if (!w) {
166 theclass->message("WARNING: Ignoring null widget provided by widgetsForGuiRow() (perhaps due to a VP1StdCollection you didn't init()?)");
167 continue;
168 }
169 //Smaller font:
170 QFont f(w->font());
171 // f.setPointSizeF(f.pointSizeF()*0.9);
172 w->setFont(f);
173 int maxheight = static_cast<int>(0.5+QFontMetricsF(f).height()*1.05+2);
174 w->setMaximumHeight(maxheight);
175 VP1MaterialButton * mb = dynamic_cast<VP1MaterialButton *>(w);
176 if (mb)
177 mb->setDimension(maxheight);
178 if (i==1) {
179 QCheckBox * cb = dynamic_cast<QCheckBox *>(w);
180 if (cb) {
181 firstColumnCheckBoxes << cb;
182 if (maxFirstColumnCheckBoxWidth<cb->sizeHint().width())
183 maxFirstColumnCheckBoxWidth = cb->sizeHint().width();
184 }
185 }
187 w->setParent(collWidget);
188 w->setVisible(true);
189 gridLayout->addWidget( w, newrow, i++);
190 }
191 gridLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding),newrow,i);
192 }
193 if (gridmargins==0) {
194 int left, top, right, bottom;
195 gridLayout->getContentsMargins ( &left, &top, &right, &bottom );
196 gridmargins = left+right;
197 }
198 }
199
200 if (maxFirstColumnCheckBoxWidth>0) {
201 for (QCheckBox *cb : firstColumnCheckBoxes)
202 cb->setMinimumWidth(maxFirstColumnCheckBoxWidth);
203 }
204
205 vlayout->addStretch(1);
206
207 QHBoxLayout * hlayout = new QHBoxLayout;
208 hlayout->setMargin(0);
209 hlayout->setSpacing(0);
210 hlayout->addLayout(vlayout);
211 hlayout->addStretch(1);
212 collWidget->setLayout(hlayout);
213
214 //Put collWidget into the collection widget:
215 delete theclass->layout();
216 QHBoxLayout * hlayoutPageCol = new QHBoxLayout;
217 collWidget->setParent(theclass);
218 hlayoutPageCol->addWidget(collWidget);
219 theclass->setLayout(hlayoutPageCol);
220 theclass->setContentsMargins(0,0,0,0);
221 collWidget->setContentsMargins(0,0,0,0);
222 hlayoutPageCol->setContentsMargins(0,0,0,0);
223 //Fixme: reshuffle the above or turn off updates to avoid flicker.
224
225 theclass->setContentsMargins(0,0,0,0);
226 collWidget->setContentsMargins(0,0,0,0);
227 appropriateFixedWidth = collWidget->sizeHint().width()//Fixme: before we add the collwidget.
228 +gridmargins;
229
230 theclass->setUpdatesEnabled(true);
231 theclass->visibleContentsChanged();
232
233}
const double width
void section(const std::string &sec)
@ top
void clearGui(bool deleteGuiElements)
QList< VP1Collection * > collections
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ updateStatesWithCurrentInfo()

void VP1CollectionWidget::Imp::updateStatesWithCurrentInfo ( )

Definition at line 282 of file VP1CollectionWidget.cxx.

283{
284 VP1Msg::messageDebug("VP1CollectionWidget::Imp::updateStatesWithCurrentInfo()");
286}
static void updateStates(VP1CollStates &state, const VP1CollStates &newInfo)
static VP1CollStates getStates(const QList< VP1Collection * > &)
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39

◆ visibleStdCollectionTypesFromVisStdCols()

QList< qint32 > VP1CollectionWidget::Imp::visibleStdCollectionTypesFromVisStdCols ( const QList< VP1StdCollection * > & l) const

Definition at line 312 of file VP1CollectionWidget.cxx.

313{
314 QSet<qint32> vt;
315 for (VP1StdCollection* stdcol : l)
316 vt.insert(stdcol->collTypeID());
317 QList<qint32> vistypes = vt.values();
318 std::sort(vistypes.begin(), vistypes.end());
319 return vistypes;
320
321}

Member Data Documentation

◆ appropriateFixedWidth

int VP1CollectionWidget::Imp::appropriateFixedWidth

Definition at line 34 of file VP1CollectionWidget.cxx.

◆ collections

QList<VP1Collection*> VP1CollectionWidget::Imp::collections

Definition at line 36 of file VP1CollectionWidget.cxx.

◆ collWidget

QWidget* VP1CollectionWidget::Imp::collWidget

Definition at line 33 of file VP1CollectionWidget.cxx.

◆ last_visibleStdCollections

QList<VP1StdCollection*> VP1CollectionWidget::Imp::last_visibleStdCollections

Definition at line 39 of file VP1CollectionWidget.cxx.

◆ last_visibleStdCollectionTypes

QList<qint32> VP1CollectionWidget::Imp::last_visibleStdCollectionTypes

Definition at line 38 of file VP1CollectionWidget.cxx.

◆ states

VP1CollStates VP1CollectionWidget::Imp::states

Definition at line 37 of file VP1CollectionWidget.cxx.

◆ theclass

VP1CollectionWidget* VP1CollectionWidget::Imp::theclass

Definition at line 32 of file VP1CollectionWidget.cxx.

◆ widgetsFromCollections

QList<QWidget *> VP1CollectionWidget::Imp::widgetsFromCollections

Definition at line 35 of file VP1CollectionWidget.cxx.


The documentation for this class was generated from the following file: