You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdewebdev/quanta/components/framewizard/treenode.h

88 lines
3.4 KiB

/***************************************************************************
treenode.h - description
-------------------
begin : lun mar 17 2003
copyright : (C) 2003 by gulmini luciano
email : gulmini.luciano@student.unife.it
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TREENODE_H
#define TREENODE_H
#include <tqptrlist.h>
#include <tqdict.h>
#include <tqstringlist.h>
#include "fwglobal.h"
#include "areaattributedb.h"
/**a node in the tree
*@author gulmini luciano
*/
class treeNode {
private:
TQString m_label,
m_parentLabel;
SplitType m_splitType;
TQPtrList<treeNode> m_childrenList;
areaAttribute *m_atts;
public:
treeNode(const TQString &l=TQString(), const TQString &pl=TQString());
~treeNode();
void addChildNode(const TQString &L);
void addChildNode(treeNode *n){ m_childrenList.append(n); }
void removeChildNode(const TQString &l, bool autoDelete);
void setSplitType(SplitType s) { m_splitType = s; }
void setLabel(const TQString &l) { m_label = l; }
void removeChildren() { m_childrenList.clear(); }
void setParentLabel(const TQString &s){ m_parentLabel = s;}
int childPosition(treeNode* n){ return m_childrenList.find(n); }
bool insertChild(unsigned int pos, treeNode* n) { return m_childrenList.insert( pos, n); }
TQString label() const { return m_label; }
TQString parentLabel() const { return m_parentLabel; }
SplitType splitType() const { return m_splitType; }
TQPtrList<treeNode> childrenList() { return m_childrenList; }
treeNode* firstChild() { return m_childrenList.first(); }
treeNode* nextChild() { return m_childrenList.next(); }
treeNode* lastChild() { return m_childrenList.last(); }
treeNode* currentChild() { return m_childrenList.current(); }
treeNode* findChild(const TQString &L);
areaAttribute* atts() { return m_atts; }
int countChildren() const { return m_childrenList.count(); }
bool hasChildren() const { return !m_childrenList.isEmpty(); }
};
class tree{
private:
treeNode *m_root;
TQDict<treeNode> m_nodeList;
static int nodeId;
public:
tree();
~tree();
treeNode* root() const { return m_root; }
TQString addChildNode(const TQString &l);
bool insertChildNode(const TQString &L);
void removeChildNode(const TQString &pl,const TQString &l,bool autoDelete);//parent node,child node
treeNode* findNode(const TQString &L);
areaAttribute* findAreaAttribute(const TQString &l){ return findNode(l)->atts(); };
void reset();
void refreshGeometries(treeNode*);
};
#endif