diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
commit | 71a39f4652cd51df814c930dd268f3c9ad2aee86 (patch) | |
tree | 5994350a603908c4e4d660bc9d72c4ec43dd648e /include/treekey.h | |
parent | 03134fa5f6f25d92724ce4c183f9bbe12a9e37dc (diff) |
Imported Upstream version 1.6.0+dfsg
Diffstat (limited to 'include/treekey.h')
-rw-r--r-- | include/treekey.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/include/treekey.h b/include/treekey.h index 1e7c773..749460b 100644 --- a/include/treekey.h +++ b/include/treekey.h @@ -1,7 +1,7 @@ /****************************************************************************** * versekey.h - code for class 'versekey'- a standard Biblical verse key * - * $Id: treekey.h 1958 2006-08-22 00:15:10Z scribe $ + * $Id: treekey.h 2280 2009-03-07 15:34:36Z scribe $ * * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society @@ -44,7 +44,24 @@ protected: // This better conforms to the SWORD write methodology: mod.setKey, mod.setEntry mutable SWBuf unsnappedKeyText; + // called whenever position of this key is changed. Should we move this + // to a more base class? + void positionChanged() { if (posChangeListener) posChangeListener->positionChanged(); } + public: + + class PositionChangeListener { + TreeKey *treeKey; + public: + PositionChangeListener() {} + virtual ~PositionChangeListener() {} + virtual void positionChanged() = 0; + TreeKey *getTreeKey() { return treeKey; } + void setTreeKey(TreeKey *tk) { treeKey = tk; } + } *posChangeListener; + + void setPositionChangeListener(PositionChangeListener *pcl) { posChangeListener = pcl; posChangeListener->setTreeKey(this); } + // TreeKey (const char *ikey = 0); // TreeKey (const SWKey * ikey); // TreeKey (TreeKey const &k); @@ -55,7 +72,9 @@ public: virtual const char *getLocalName() = 0; virtual const char *setLocalName(const char *) = 0; - virtual const char *getUserData(int *size = 0) = 0; + virtual int getLevel() { long bm = getOffset(); int level = 0; do { level++; } while (parent()); setOffset(bm); return level; } + + virtual const char *getUserData(int *size = 0) const = 0; virtual void setUserData(const char *userData, int size = 0) = 0; /** Go to the root node @@ -109,7 +128,7 @@ public: /** Set the key to this path. If the path doesn't exist, then * nodes are created as necessary - * @keyPath = path to set/create; if unsupplied, then use any unsnapped setText value. + * @param keyPath path to set/create; if unsupplied, then use any unsnapped setText value. */ virtual void assureKeyPath(const char *keyPath = 0); virtual void save() {} |