mImageAdder.AddDirectory(f,recurse);
}
+
//========================================================================
//========================================================================
//=====================================================================
- bool SQLiteTreeHandler::Remove(tree::Node*)
+ bool SQLiteTreeHandler::Remove(tree::Node* node)
{
- return false;
+ DBRecursiveRemoveNode(node);
+
+ // std::cout << "DELETE"<<std::endl;
+ if (node->GetParent())
+ {
+ node->GetParent()->RemoveChildrenFromList(node);
+ }
+ delete node;
+ // std::cout << "DELETE OK"<<std::endl;
+ return true;
}
+
+ //========================================================================
+
+
+
//=====================================================================
//=====================================================================
std::string insert("INSERT INTO ");
insert += GetTree().GetLevelDescriptor(n->GetLevel()).GetName();
insert += " " + val + ";";
+
UPDATEDB(insert);
// Store DB id of newly created node;
}
//=====================================================================
+
+ //=====================================================================
+ void SQLiteTreeHandler::DBRecursiveRemoveNode(Node* node)
+ {
+
+ std::string query = "DELETE FROM ";
+
+ query += GetTree().GetLevelDescriptor(node->GetLevel()).GetName();
+ query += " WHERE ID='"+ node->GetAttribute("ID") + "';";
+
+ UPDATEDB(query);
+ GimmickDebugMessage(2,
+ " Deleting '"
+ <<node->GetLabel()<<"' with ID '"
+ <<node->GetAttribute("ID")
+ <<"' in level "<< GetTree().GetLevelDescriptor(node->GetLevel()).GetName()
+ <<std::endl);
+
+ Node::ChildrenListType::iterator i;
+ for (i = node->GetChildrenList().begin();
+ i != node->GetChildrenList().end();
+ i++)
+ {
+ DBRecursiveRemoveNode((*i));
+ }
+ }
+
/*
//=====================================================================
bool SQLiteTreeHandler::DBInsert(Node* alien_node,
// std::cout << " ** Node = "<<i->second<<std::endl;
return i->second;
}
+
//=====================================================================
//=====================================================================
bool SQLiteTreeHandler::Remove(Node* node)
{
- DBRecursiveRemoveNode(node);
+
+ //DBRecursiveRemoveNode(node);
// std::cout << "DELETE"<<std::endl;
if (node->GetParent())
// std::cout << "DELETE OK"<<std::endl;
return true;
}
+
+
//========================================================================
//=====================================================================
DBRecursiveRemoveNode((*i));
}
}
+
//=====================================================================
//=====================================================================
/// Inserts the Node in the database
void DBInsert(tree::Node* n);
//======================================================================
+
+
+ // Recursively Removes the nodes whose parent is given as a parameter
+ void DBRecursiveRemoveNode(tree::Node* node);
/*
///
int DBQueryNumberOfChildren(tree::Node* n);
// UpdateSummary& summary);
- //
- void DBRecursiveRemoveNode(tree::Node* node);
+ */
+ /*
void BuildSQLFieldsValues(tree::Node* n,
std::string& str);
#include <creaImageIOTreeHandler.h>
#include <creaImageIOSystem.h>
+
namespace creaImageIO
{
/**
/// Updates the view of a level given the selected items of upper level
virtual void UpdateLevel( int )
{ GimmickError("INTERNAL ERROR : TreeView::UpdateLevel not overloaded");}
-
+
+ ///Removes selected nodes on given level
+ virtual void RemoveSelected( int )
+ { GimmickError("INTERNAL ERROR : TreeView::RemoveSelected not overloaded");}
+
protected:
TreeHandler* GetTreeHandler() { return mTreeHandler; }
DisplayAddSummary();
}
}
+ //=================================================
+
+ //=================================================
+ void WxGimmickView::OnRemove(wxCommandEvent& event)
+ {
+ //TODO Select current tree handler
+ GetTreeViewMap()["Local database"]->RemoveSelected(1);
+ }
//=================================================
//=================================================
BEGIN_EVENT_TABLE(WxGimmickView, wxPanel)
EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
EVT_TOOL(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir)
+ EVT_TOOL(TOOL_REMOVE_ID, WxGimmickView::OnRemove)
END_EVENT_TABLE()
//=================================================
void OnAddFiles(wxCommandEvent& event);
/// Callback for adding dir
void OnAddDir(wxCommandEvent& event);
+ /// Callback for removing files
+ void OnRemove(wxCommandEvent& event);
/// Display a message box with the last addition statistics
void DisplayAddSummary();
{
tree::Node* node;
};
+
//=====================================================================
-
- //=====================================================================
- ///
- void WxTreeView::UpdateLevel( int level )
+ std::vector<tree::Node*> WxTreeView::GetSelected(int level)
{
- GimmickDebugMessage(1,
- GetTreeHandler()->GetTree().GetLabel()
- <<" view : updating level "<<level
- <<std::endl);
int l = level - 1;
// the selection of upper level
std::vector<tree::Node*> sel;
}
}
}
+ return sel;
+ }
+
+ //=====================================================================
+
+ ///Removes selected nodes on given level
+ void WxTreeView::RemoveSelected( int level )
+ {
+ std::vector<tree::Node*> sel=GetSelected(level+1);
+
+ std::vector<tree::Node*>::iterator i;
+ for (i=sel.begin(); i!=sel.end(); ++i)
+ {
+ GimmickDebugMessage(2,
+ "deleting '"
+ <<(*i)->GetLabel()
+ <<"'"<<level
+ <<std::endl);
+ GetTreeHandler()->Remove(*i);
+ }
+
+ UpdateLevel(level);
+
+ }
+
+
+ //=====================================================================
+
+ //=====================================================================
+
+ ///
+ void WxTreeView::UpdateLevel( int level )
+ {
+ GimmickDebugMessage(1,
+ GetTreeHandler()->GetTree().GetLabel()
+ <<" view : updating level "<<level
+ <<std::endl);
+
+
+ std::vector<tree::Node*> sel=GetSelected(level);
+ int l = level - 1;
+
// to speed up inserting we hide the control temporarily
GetCtrl(l)->Hide();
GetCtrl(l)->DeleteAllItems();
/// Updates the view of a level given the selected items of upper level
virtual void UpdateLevel( int );
-
+
+ ///Removes selected nodes on given level
+ virtual void RemoveSelected( int );
+
/// Callback for selection change
void OnSelected(wxListEvent& event);
/// return the wxListCtrl of one level
wxListCtrl* GetCtrl(int l) { return mLevelList[l].wxCtrl; }
+
+ std::vector<tree::Node*>GetSelected(int level);
+
DECLARE_EVENT_TABLE()