Engauge Digitizer  2
ChecklistGuidePage.cpp
1 #include "ChecklistGuidePage.h"
2 #include "ChecklistLineEdit.h"
3 #include "Logger.h"
4 #include <QGridLayout>
5 #include <QLabel>
6 #include <QPalette>
7 #include <QRadioButton>
8 #include <QVBoxLayout>
9 
11  m_row (0),
12  m_checklineLineEditContainer (0),
13  m_checklineLineEditLayout (0)
14 {
15  setTitle (title);
16 
17  m_layout = new QGridLayout;
18  m_layout->setColumnStretch (0, 0);
19  m_layout->setColumnStretch (1, 1);
20  setLayout (m_layout);
21 }
22 
23 void ChecklistGuidePage::addHtml (const QString &html)
24 {
25  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addHtml";
26 
27  QLabel *label = new QLabel (html);
28  label->setWordWrap (true);
29 
30  m_layout->addWidget (label, m_row++, 0, 1, 2, Qt::AlignTop);
31 }
32 
33 QRadioButton *ChecklistGuidePage::addLabelAndRadioButton (const QString &label,
34  const QString &whatsThis)
35 {
36  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLabelAndRadioButton";
37 
38  QRadioButton *button = new QRadioButton;
39  button->setWhatsThis (whatsThis);
40  m_layout->addWidget (button, m_row, 0, 1, 1, Qt::AlignTop);
41 
42  QLabel *lbl = new QLabel (label);
43  lbl->setWordWrap(true);
44  m_layout->addWidget (lbl, m_row++, 1, 1, 1, Qt::AlignTop);
45 
46  return button;
47 }
48 
50  const QString &whatsThis)
51 {
52  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLineEdit";
53 
54  bool isFirst = false;
55 
56  if (m_checklineLineEditContainer == 0) {
57 
58  isFirst = true;
59 
60  // This is the first ChecklistLineEdit, so we create a container for it and any more that get added
61  m_checklineLineEditLayout = new QVBoxLayout;
62  m_checklineLineEditLayout->setSpacing (0); // This is the whole reason we wrap the ChecklineLineEdits in a container
63 
64  m_checklineLineEditContainer = new QWidget;
65  m_checklineLineEditContainer->setLayout (m_checklineLineEditLayout);
66  m_layout->addWidget (m_checklineLineEditContainer, m_row++, 0, 1, 2, Qt::AlignTop);
67  }
68 
69  edit->setWhatsThis (whatsThis);
70  m_checklineLineEditLayout->addWidget (edit);
71 
72  // Windows border is missing on left side so border is made complete here
73  QString style = QString ("QLineEdit { "
74  "border-left : 1px solid gray; "
75  "border-right: 1px solid gray; "
76  "border-top: %1px solid gray; "
77  "border-bottom:1px solid gray; }")
78  .arg (isFirst ? 1 : 0);
79  edit->setStyleSheet (style);
80 }
void addLineEdit(ChecklistLineEdit *edit, const QString &whatsThis)
Insert line edit.
QRadioButton * addLabelAndRadioButton(const QString &label, const QString &whatsThis)
Insert radio button and corresponding label.
ChecklistGuidePage(const QString &title)
Single constructor.
void addHtml(const QString &html)
Insert html for display.
Adds key event handling to QLineEdit.