metainfobox.cpp
Go to the documentation of this file.
1 #include "metainfobox.h"
2 
3 #include <QLabel>
4 #include <QGridLayout>
5 #include <QLabel>
6 #include <QDebug>
7 
8 MetaInfoBox::MetaInfoBox(QWidget *parent)
9  : QGroupBox(parent)
10  , m_layout(new QGridLayout)
11 {
12  setLayout(m_layout);
13 }
14 
15 QString boldText(QString text)
16 {
17  return QString("<b>") + text + QString("</b>");
18 }
19 
20 void MetaInfoBox::setMetaInfos(QVector<QStringPair> metaInfos)
21 {
22  if (m_metaInfos == metaInfos)
23  return;
24 
25  m_metaInfos = metaInfos;
26 
27  qDeleteAll(m_labels);
28  m_labels.clear();
29 
30  foreach (QStringPair metaInfo, metaInfos)
31  {
32  QLabel* keyLabel = new QLabel(boldText(metaInfo.first));
33  QLabel* valueLabel = new QLabel(metaInfo.second);
34  valueLabel->setWordWrap(true);
35  // Number of meta infos we've got so far
36  int metaInfoCount = m_labels.size() / 2;
37  m_layout->addWidget(keyLabel, metaInfoCount, 0);
38  m_layout->addWidget(valueLabel, metaInfoCount, 1);
39  m_labels.append(keyLabel);
40  m_labels.append(valueLabel);
41  }
42 }
43 
45 {
46 }
47 
49 {
50  clear();
51 }
QPair< QString, QString > QStringPair
QVector< QStringPair > m_metaInfos
To prevent flickering, avoid redrawing if meta info didn&#39;t change.
Definition: metainfobox.h:30
QVector< QLabel * > m_labels
Definition: metainfobox.h:27
void clear()
Removes all meta info.
Definition: metainfobox.cpp:44
QGridLayout * m_layout
Definition: metainfobox.h:26
void setMetaInfos(QVector< QStringPair > metaInfos)
Sets a list of key-value pairs as meta info.
Definition: metainfobox.cpp:20
QString boldText(QString text)
Definition: metainfobox.cpp:15
MetaInfoBox(QWidget *parent=0)
Definition: metainfobox.cpp:8


hector_nist_arena_designer
Author(s): Stefan Kohlbrecher , Johannes Simon
autogenerated on Fri Aug 21 2020 10:45:27