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 
10 const int MAX_LAYOUT_WIDTH = 300;
11 
13  m_row (0),
14  m_checklineLineEditContainer (0),
15  m_checklineLineEditLayout (0)
16 {
17  setTitle (title);
18 
19  m_layout = new QGridLayout;
20  m_layout->setColumnStretch (0, 0);
21  m_layout->setColumnStretch (1, 1);
22  setLayout (m_layout);
23 }
24 
25 void ChecklistGuidePage::addHtml (const QString &html)
26 {
27  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addHtml";
28 
29  QLabel *label = new QLabel (html);
30  label->setMaximumWidth(MAX_LAYOUT_WIDTH);
31  label->setWordWrap (true);
32 
33  m_layout->addWidget (label, m_row++, 0, 1, 2, Qt::AlignTop);
34 }
35 
36 QRadioButton *ChecklistGuidePage::addLabelAndRadioButton (const QString &label)
37 {
38  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLabelAndRadioButton";
39 
40  QRadioButton *button = new QRadioButton;
41  m_layout->addWidget (button, m_row, 0, 1, 1, Qt::AlignTop);
42 
43  QLabel *lbl = new QLabel (label);
44  lbl->setWordWrap(true);
45  lbl->setMaximumWidth(MAX_LAYOUT_WIDTH);
46  m_layout->addWidget (lbl, m_row++, 1, 1, 1, Qt::AlignTop);
47 
48  return button;
49 }
50 
52 {
53  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePage::addLineEdit";
54 
55  if (m_checklineLineEditContainer == 0) {
56 
57  // This is the first ChecklistLineEdit, so we create a container for it and any more that get added
58  m_checklineLineEditLayout = new QVBoxLayout;
59  m_checklineLineEditLayout->setSpacing (0); // This is the whole reason we wrap the ChecklineLineEdits in a container
60 
61  m_checklineLineEditContainer = new QWidget;
62  m_checklineLineEditContainer->setLayout (m_checklineLineEditLayout);
63  m_layout->addWidget (m_checklineLineEditContainer, m_row++, 0, 1, 2, Qt::AlignTop);
64  }
65 
66  m_checklineLineEditLayout->addWidget (edit);
67 }
void addLineEdit(ChecklistLineEdit *edit)
Insert line edit.
ChecklistGuidePage(const QString &title)
Single constructor.
void addHtml(const QString &html)
Insert html for display.
QRadioButton * addLabelAndRadioButton(const QString &label)
Insert radio button and corresponding label.
Adds key event handling to QLineEdit.