: mFileName(filename)
{
mDB = new CppSQLite3DB;
+ mIsAdding=false;
GimmickMessage(1,"SQLite version : "
<<std::string(mDB->SQLiteVersion())<< std::endl);
}
//=====================================================================
int SQLiteTreeHandler::AddBranch( const AttributeMapType& attr )
{
+ mIsAdding=true;
tree::Node* parent = DBGetParent(attr);
DBGraftToParent(parent,attr);
+ mIsAdding=false;
return (parent->GetLevel()+1);
}
int nbloaded = 0;
// If children loaded we do not have to do it but we need to recurse
// in order to load the children's children if necessary, and so on...
- if (node->GetChildrenLoaded())
+ if (node->GetChildrenLoaded()||mIsAdding)
{
// Iterate the children
{
nbloaded += DBLoadChildren(*i,numberoflevels-1);
}*/
+
return nbloaded;
}
-
+ else
+ {
/// If children not loaded : do it and recurse
+ std::cout<<"Children are not loaded for node:"<<node->GetLabel()<<std::endl;
+ std::cout<<"Children are not loaded for node (pointer):"<<node<<std::endl;
// Query DB
int level = node->GetLevel();
CppSQLite3Query q;
QUERYDB(query,q);
+ int p=0;
while (!q.eof())
{
- // std::cout<<"Name in q: "<<q.fieldName(3)<<" Value: "<<q.getStringField(3)<<std::endl;
nbloaded++;
Node* n = new Node(node);
for (int fld = 0; fld < q.numFields(); fld++)
if ( numberoflevels != 1 )
{
// msw[2].Pause();
- // nbloaded += DBLoadChildren(n, numberoflevels-1);
+ nbloaded += DBLoadChildren(n, numberoflevels-1);
// msw[2].Resume();
}
// next entry in db
}
node->SetChildrenLoaded(true);
+
// msw[2].Pause();
return nbloaded;
+ }
}
//=====================================================================
{
// Create Node
tree::Node* child = new tree::Node(parent,attr);
-
+ std::cout<<"Number of children "<<parent->GetNumberOfChildren()<<std::endl;
// Set PARENT_ID if necessary
if ( parent->GetLevel()>0 )
child->SetAttribute("PARENT_ID",parent->GetAttribute("ID"));
{
//=============================================================
- /// Ctor with parent
+ /// Ctor with parent Why does it enter once while charging?
Node::Node(Node* parent)
: mParent(parent),
mData(0),
GimmickDebugMessage(6,"Default Node constructor (level "<<GetLevel()<<")"
<< std::endl);
// Insert into parent's children list
- //parent->GetChildrenList().push_back(this);
- //InitializeAttributeMap();
+ InitializeAttributeMap();
+ parent->GetChildrenList().push_back(this);
}
else
{
}
//Resets original data
-
- std::vector<tree::Node*>::iterator selection;
- std::vector<long> change;
long it = -1;
for ( ;; )
{
//Gets current item data, extracts the node and resets it
long item = GetCtrl(level)->GetItemData(it);
GetCtrl(level)->SetItemData(it,((long*)item)[0]);
- tree::Node* n= ((ItemData*)((long*)item)[0])->node;
+ //tree::Node* n= ((ItemData*)((long*)item)[0])->node;
}