Engauge Digitizer  2
ChecklistGuidePageCurves.cpp
1 #include "ChecklistGuidePageCurves.h"
2 #include "ChecklistLineEdit.h"
3 #include "Curve.h"
4 #include "Logger.h"
5 #include <QHeaderView>
6 #include <QRadioButton>
7 #include <QTableWidget>
8 
9 const int FIRST_COL = 0;
10 const int NUM_COL = 1;
11 const int NUM_ROW = 6;
12 
14  ChecklistGuidePage ("Curves")
15 {
16  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::ChecklistGuidePageCurves";
17 
18  addHtml ("<p>What are the names of the curves that are to be digitized? At least one entry is required.</p>");
19 
20  m_edit = new ChecklistLineEdit* [NUM_CURVE_NAMES()];
21 
22  for (int i = 0; i < NUM_CURVE_NAMES(); i++) {
23  m_edit [i] = new ChecklistLineEdit;
24  connect (m_edit [i], SIGNAL (signalKeyRelease()), this, SLOT (slotTableChanged()));
25  addLineEdit (m_edit [i]);
26  }
27 
28  m_edit [0]->setText (DEFAULT_GRAPH_CURVE_NAME); // Simple default name
29 
30  addHtml ("<p>&nbsp;</p>");
31 
32  addHtml ("<p>How are those curves drawn?</p>");
33 
34  m_btnLines = addLabelAndRadioButton ("With lines (with or without points)");
35  m_btnPoints = addLabelAndRadioButton ("With points only (no lines between points)");
36 
37  m_btnLines->setChecked (true); // Default encourages digitizing using the lines, since that is easier
38 }
39 
41 {
42  QStringList curveNames;
43 
44  for (int i = 0; i < NUM_CURVE_NAMES(); i++) {
45  const QLineEdit *edit = m_edit [i];
46  QString text = edit->text();
47  if (!text.isEmpty()) {
48  curveNames << text;
49  }
50  }
51 
52  return curveNames;
53 }
54 
55 bool ChecklistGuidePageCurves::curveNamesAreAllUnique() const
56 {
57  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::curveNamesAreAllUnique";
58 
59  QStringList names = curveNames();
60 
61  int numberDuplicatesRemoved = names.removeDuplicates();
62 
63  return (numberDuplicatesRemoved == 0);
64 }
65 
67 {
68  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::isComplete";
69 
70  return !curveNames().isEmpty () &&
71  curveNamesAreAllUnique ();
72 }
73 
75 {
76  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::slotTableChanged";
77 
78  emit completeChanged();
79 }
80 
82 {
83  return m_btnLines->isChecked();
84 }
void addLineEdit(ChecklistLineEdit *edit)
Insert line edit.
ChecklistGuidePageCurves()
Single constructor.
This class customizes QWizardPage for ChecklistGuideWizard.
bool withLines() const
Drawn with lines, else points.
QStringList curveNames() const
Wizard selection for curve names.
virtual bool isComplete() const
Validate the contents of this page.
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.
void slotTableChanged()
Update after curve table update.