00001
00002
00003
00004
00005
00006
00007 #include "ChecklistGuidePageCurves.h"
00008 #include "ChecklistLineEdit.h"
00009 #include "Curve.h"
00010 #include "Logger.h"
00011 #include <QHeaderView>
00012 #include <QRadioButton>
00013 #include <QTableWidget>
00014 #include "SettingsForGraph.h"
00015
00016 ChecklistGuidePageCurves::ChecklistGuidePageCurves(const QString &title) :
00017 ChecklistGuidePage (title)
00018 {
00019 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::ChecklistGuidePageCurves";
00020
00021 const QString WHATS_THIS_CURVE (tr ("Curve name. Empty if unused."));
00022 const QString WHATS_THIS_LINES (tr ("Draw lines between points in each curve."));
00023 const QString WHATS_THIS_POINTS (tr ("Draw points in each curve, without lines between the points."));
00024
00025 addHtml (tr ("<p>What are the names of the curves that are to be digitized? At least one entry is required.</p>"));
00026
00027 m_edit = new ChecklistLineEdit* [NUM_CURVE_NAMES()];
00028
00029 for (int i = 0; i < NUM_CURVE_NAMES(); i++) {
00030 m_edit [i] = new ChecklistLineEdit;
00031 connect (m_edit [i], SIGNAL (signalKeyRelease()), this, SLOT (slotTableChanged()));
00032 addLineEdit (m_edit [i],
00033 WHATS_THIS_CURVE);
00034 }
00035
00036 SettingsForGraph settingsForGraph;
00037 QString curveName = settingsForGraph.defaultCurveName (1,
00038 DEFAULT_GRAPH_CURVE_NAME);
00039
00040 m_edit [0]->setText (curveName);
00041
00042 addHtml ("<p> </p>");
00043
00044 addHtml (tr ("<p>How are those curves drawn?</p>"));
00045
00046 m_btnLines = addLabelAndRadioButton (tr ("With lines (with or without points)"),
00047 WHATS_THIS_LINES);
00048 m_btnPoints = addLabelAndRadioButton (tr ("With points only (no lines between points)"),
00049 WHATS_THIS_POINTS);
00050
00051 m_btnLines->setChecked (true);
00052 }
00053
00054 QStringList ChecklistGuidePageCurves::curveNames () const
00055 {
00056 QStringList curveNames;
00057
00058 for (int i = 0; i < NUM_CURVE_NAMES(); i++) {
00059 const QLineEdit *edit = m_edit [i];
00060 QString text = edit->text();
00061 if (!text.isEmpty()) {
00062 curveNames << text;
00063 }
00064 }
00065
00066 return curveNames;
00067 }
00068
00069 bool ChecklistGuidePageCurves::curveNamesAreAllUnique() const
00070 {
00071 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::curveNamesAreAllUnique";
00072
00073 QStringList names = curveNames();
00074
00075 int numberDuplicatesRemoved = names.removeDuplicates();
00076
00077 return (numberDuplicatesRemoved == 0);
00078 }
00079
00080 bool ChecklistGuidePageCurves::isComplete () const
00081 {
00082 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::isComplete";
00083
00084 return !curveNames().isEmpty () &&
00085 curveNamesAreAllUnique ();
00086 }
00087
00088 void ChecklistGuidePageCurves::slotTableChanged ()
00089 {
00090 LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuidePageCurves::slotTableChanged";
00091
00092 emit completeChanged();
00093 }
00094
00095 bool ChecklistGuidePageCurves::withLines() const
00096 {
00097 return m_btnLines->isChecked();
00098 }