summaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2019-01-02 17:38:38 +0100
committerAleks Kissinger <aleks0@gmail.com>2019-01-02 17:38:38 +0100
commit904e73cbfa571377ab1860ba7d5a54119ab909e0 (patch)
treeb3619b3066c1600bc117293d6d0d8d9beaeb26be /src/data
parente090751ebb8e4c7c6a9075587e1017d4ac95cd05 (diff)
added some documentation to the source code
Diffstat (limited to 'src/data')
-rw-r--r--src/data/delimitedstringvalidator.h14
-rw-r--r--src/data/edge.h8
-rw-r--r--src/data/graphelementdata.h6
-rw-r--r--src/data/graphelementproperty.h37
4 files changed, 60 insertions, 5 deletions
diff --git a/src/data/delimitedstringvalidator.h b/src/data/delimitedstringvalidator.h
index 654e4ab..b4ed3bd 100644
--- a/src/data/delimitedstringvalidator.h
+++ b/src/data/delimitedstringvalidator.h
@@ -19,6 +19,10 @@
/*!
* A string validator which keeps curly braces matched. Used in various places
* to ensure the user doesn't make non-parseable .tikz or .tikzstyles files.
+ *
+ * Its validation function will return Acceptable if all curly braces are matched
+ * properly, Intermediate if all braces are matched except for possibly some opening
+ * curly braces, and Invalid if there are unmatched closing curly braces.
*/
#ifndef DELIMITEDSTRINGVALIDATOR_H
@@ -34,8 +38,18 @@ class DelimitedStringValidator : public QValidator
public:
DelimitedStringValidator(QObject *parent);
QValidator::State validate(QString &input, int &/*pos*/) const override;
+
+ /*!
+ * \brief fixup adds curly braces until all braces are matched (if possible)
+ * \param input
+ */
void fixup(QString &input) const override;
private:
+ /*!
+ * \brief braceDepth computes the final (non-escaped) curly-brace depth of a given string
+ * \param input a string
+ * \return the final brace depth, or -1 if the depth *ever* drops below 0
+ */
int braceDepth(QString input) const;
};
diff --git a/src/data/edge.h b/src/data/edge.h
index 5d26b3e..27d5bef 100644
--- a/src/data/edge.h
+++ b/src/data/edge.h
@@ -16,6 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+/*!
+ * Class representing an edge in a Graph.
+ */
+
#ifndef EDGE_H
#define EDGE_H
@@ -30,8 +34,8 @@ class Edge : public QObject
{
Q_OBJECT
public:
- explicit Edge(Node *s, Node *t, QObject *parent = 0);
- Edge *copy(QMap<Node *, Node *> *nodeTable = 0);
+ explicit Edge(Node *s, Node *t, QObject *parent = nullptr);
+ Edge *copy(QMap<Node *, Node *> *nodeTable = nullptr);
Node *source() const;
Node *target() const;
diff --git a/src/data/graphelementdata.h b/src/data/graphelementdata.h
index b1311d7..dce0d46 100644
--- a/src/data/graphelementdata.h
+++ b/src/data/graphelementdata.h
@@ -16,6 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+/*!
+ * A list of GraphElementProperty objects, which convenience methods
+ * for lookup, deletion, re-ordering, etc. It inherits QAbstractItemModel
+ * so it can be used as the model for a QTreeView in the StyleEditor.
+ */
+
#ifndef GRAPHELEMENTDATA_H
#define GRAPHELEMENTDATA_H
diff --git a/src/data/graphelementproperty.h b/src/data/graphelementproperty.h
index 4ebe104..5777c18 100644
--- a/src/data/graphelementproperty.h
+++ b/src/data/graphelementproperty.h
@@ -16,6 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+/*!
+ * A class which holds either a single key/value pair (i.e. a proper property)
+ * or simply a key with no value (i.e. an atom).
+ */
+
#ifndef GRAPHELEMENTPROPERTY_H
#define GRAPHELEMENTPROPERTY_H
@@ -26,13 +31,19 @@ class GraphElementProperty
public:
GraphElementProperty();
- // full constructor
GraphElementProperty(QString key, QString value, bool atom);
- // construct a proper property
+ /*!
+ * \brief GraphElementProperty constructs a proper property with the given key/value
+ * \param key
+ * \param value
+ */
GraphElementProperty(QString key, QString value);
- // construct an atom
+ /*!
+ * \brief GraphElementProperty constructs an atom with the given key
+ * \param key
+ */
GraphElementProperty(QString key);
QString key() const;
@@ -40,9 +51,29 @@ public:
QString value() const;
void setValue(const QString &value);
bool atom() const;
+
+ /*!
+ * \brief operator == returns true for atoms if the keys match and for properties
+ * if the keys and values match. Note a property is never equal to an atom.
+ * \param p
+ * \return
+ */
bool operator==(const GraphElementProperty &p);
+ /*!
+ * \brief tikzEscape prepares a property key or value for export to tikz code. If
+ * the property only contains numbers, letters, whitespace, or the characters (<,>,-)
+ * this method does nothing. Otherwise, wrap the property in curly braces.
+ * \param str
+ * \return
+ */
static QString tikzEscape(QString str);
+
+ /*!
+ * \brief tikz escapes the key/value of a propery or atom and outputs it as "key=value"
+ * for properties and "key" for atoms.
+ * \return
+ */
QString tikz();
signals: