[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [zanshin/reparentingModel] src/reparentingmodel: rename, documentation
From:       Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date:       2012-05-31 17:25:44
Message-ID: 20120531172544.501D7A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit a798d604868119533b6fa0112afac2db65387e0d by Christian Mollekopf.
Committed on 31/05/2012 at 19:25.
Pushed by cmollekopf into branch 'reparentingModel'.

rename, documentation

M  +1    -1    src/reparentingmodel/reparentingmodel.cpp
M  +2    -2    src/reparentingmodel/reparentingstrategy.cpp
M  +54   -8    src/reparentingmodel/reparentingstrategy.h

http://commits.kde.org/zanshin/a798d604868119533b6fa0112afac2db65387e0d

diff --git a/src/reparentingmodel/reparentingmodel.cpp \
b/src/reparentingmodel/reparentingmodel.cpp index 71a2add..da897f3 100644
--- a/src/reparentingmodel/reparentingmodel.cpp
+++ b/src/reparentingmodel/reparentingmodel.cpp
@@ -107,7 +107,7 @@ void ReparentingModel::removeNode(TodoNode *root, bool \
removeChildren)  if (removeChildren) {
         foreach(TodoNode *childNode, root->children()) {
             Id childId = m_parentMap.key(childNode);
-            if (m_strategy->reparentOnRemoval(childId)) {
+            if (m_strategy->reparentOnParentRemoval(childId)) {
 //                 kDebug() << "child " << childId;
                 IdList parents = m_strategy->getParents(childNode->rowSourceIndex(), \
IdList() << m_parentMap.key(root));//Don't try to re-add it to the current parent \
                (which is not yet removed)
                 reparentNode(childId, parents, childNode->rowSourceIndex());
diff --git a/src/reparentingmodel/reparentingstrategy.cpp \
b/src/reparentingmodel/reparentingstrategy.cpp index d0452ea..81bcd6b 100644
--- a/src/reparentingmodel/reparentingstrategy.cpp
+++ b/src/reparentingmodel/reparentingstrategy.cpp
@@ -92,7 +92,7 @@ void ReparentingStrategy::removeNode(Id id)
 }
 
 
-bool ReparentingStrategy::reparentOnRemoval(Id) const
+bool ReparentingStrategy::reparentOnParentRemoval(Id) const
 {
     return mReparentOnRemoval;
 }
@@ -163,7 +163,7 @@ void TestParentStructureStrategy::init()
     node2->setRowData(Zanshin::TopicRoot, Zanshin::ItemTypeRole);
 }
 
-bool TestParentStructureStrategy::reparentOnRemoval(Id id) const
+bool TestParentStructureStrategy::reparentOnParentRemoval(Id id) const
 {
     if (id < 900) {
         kDebug() << "reparent " << id;
diff --git a/src/reparentingmodel/reparentingstrategy.h \
b/src/reparentingmodel/reparentingstrategy.h index ee245f8..2897e4e 100644
--- a/src/reparentingmodel/reparentingstrategy.h
+++ b/src/reparentingmodel/reparentingstrategy.h
@@ -31,28 +31,59 @@ typedef qint64 Id;
 typedef QList<qint64> IdList;
 class ReparentingModel;
 class TodoNode;
+
+/**
+ * A reparenting strategy for a ReparentingModel
+ *
+ * The strategy is basically responsible for identifying nodes, and to give \
information about the nodes parent relations. + * Each node can have multiple parents \
(TODO not yet implemented), and is identified by a unique Id. + */
 class ReparentingStrategy
 {
 public:
     ReparentingStrategy();
     virtual ~ReparentingStrategy(){};
     virtual void init() {};
-    /// Get the id for an object
+    /**
+     * Return the unique Id for the node.
+     *
+     * The Id must be unique for this strategy.
+     * Ids may be reused after a reset (given all caches are cleared). 
+     */
     virtual Id getId(const QModelIndex &/*sourceChildIndex*/) = 0;
-    /// Get parents
+    /**
+     * Return the parents of a node.
+     *
+     * @param ignore is a list of ids which must be removed from the return list \
(otherwise moves won't work). +     */
     virtual IdList getParents(const QModelIndex &, const IdList &ignore = IdList());
 
-    virtual void onNodeRemoval(const Id &changed);
-
+    /**
+     * Reset all internal data (caches etc.)
+     *
+     * Issued on model reset.
+     */
     virtual void reset();
 
+    /**
+     * React to the removal of a node (e.g. cleanup cache)
+     */
+    virtual void onNodeRemoval(const Id &changed);
+
+    /**
+     * Set the reparenting model.
+     */
     void setModel(ReparentingModel *model);
 
-    ///Return true if @param child should be reparented on parent removal
-    virtual bool reparentOnRemoval(Id child) const;
+    /**
+     * Return true if @param child should be reparented on parent removal, otherwise \
the child is removed as well. +     */
+    virtual bool reparentOnParentRemoval(Id child) const;
 
     /**
-     * Set data on a virtual node
+     * Set data on a virtual node.
+     *
+     * Called during the creating of a virtual node.
      */
     virtual void setData(TodoNode* node, Id id) {};
 
@@ -63,10 +94,25 @@ public:
     virtual bool onSetData(Id id, const QVariant &value, int role) { return false; \
};  
 protected:
+    /**
+     * Creates a virtual node (no corresponding sourceIndex).
+     */
     virtual TodoNode *createNode(Id id, IdList pid, QString name);
+    /**
+     * Remove a node.
+     */
     void removeNode(Id id);
+    /**
+     * Trigger an update of the parents (move the node to it's new parents).
+     */
     void updateParents(Id id, IdList parents);
+    /**
+     * Rename a virtual node.
+     */
     void renameNode(Id id, QString name);
+    /**
+     * Get the data of a node (same as index.data)
+     */
     QVariant getData(Id id, int role);
     
     Id getNextId();
@@ -127,7 +173,7 @@ public:
     void removeParent(const qint64 &identifier);
     void onNodeRemoval(const qint64 &changed) { qDebug() << "removed node: " << \
changed; };  
-    virtual bool reparentOnRemoval(Id ) const;
+    virtual bool reparentOnParentRemoval(Id ) const;
 
     virtual Id getId(const QModelIndex& );
     virtual IdList getParents(const QModelIndex &, const IdList &ignore = IdList());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic