tree::Node* parent=node->GetParent();
if (parent)
{
- parent->RemoveChildrenFromList(node);
- int nC=GetNumberOfChildren(parent);
- nC=nC-1;
+ int nC = parent->RemoveChildrenFromList(node);
if(nC>0)
{
std::stringstream out;
sql += GetTree().GetLevelDescriptor(n->GetLevel()).GetName();
sql += " SET ";
sql += key;
- sql += "='";
+ sql += " = '";
sql += value;
- sql += "' WHERE ID=";
+ sql += "' WHERE ID = '";
sql += n->GetAttribute("ID");
+ sql +="'";
// sql += " LIMIT 1";
UPDATEDB(sql);
}
// Query DB
int nb=0;
int level = n->GetLevel();
-
+
if(level<GetTree().GetNumberOfLevels()&& level>0)
{
std::string query = "SELECT NumberOfChildren FROM ";
//=============================================================
//=============================================================
- void Node::RemoveChildrenFromList(Node* node)
+ int Node::RemoveChildrenFromList(Node* node)
{
ChildrenListType::iterator i = find(GetChildrenList().begin(),
GetChildrenList().end(),
{
GetChildrenList().erase(i);
}
+ return GetChildrenList().size();
}
//=============================================================
const ChildrenListType& GetChildrenList() const { return mChildren; }
/// Remove the given children from the children list
- void RemoveChildrenFromList(Node*);
+ int RemoveChildrenFromList(Node*);
AttributeMapType& GetAttributeMap() { return mAttributeMap; }
/// Sorts the children of the node
void SortChildren(const LexicographicalComparator&);
-
virtual void Print() const;
std::string GetLabel() const;
/*
#include "icons/help.xpm"
#include <wx/imaglist.h>
+#include<boost/filesystem/operations.hpp>
namespace creaImageIO
{
if (FD->ShowModal()==wxID_OK)
{
- bool recurse = false;
-
- if (wxMessageBox(_T("Recurse into sub-directories ?"),
- _T("Scan directory"),
- wxYES_NO,this ) == wxYES)
- {
- recurse = true;
+ std::string dirname = wx2std (FD->GetPath());
+ bool recurse = isNeedRecursive(dirname);
+ if (recurse)
+ {
+ recurse = wxMessageBox(_T("Recurse into sub-directories ?"), _T("Scan directory"), wxYES_NO,this ) == wxYES ? true : false;
+ }
+
+ wxBusyCursor busy;
+ wxString title(_T("Adding directory"));
+ if (recurse)
+ title = _T("Adding directory (recursive)");
+ mProgressDialog =
+ new wxProgressDialog(_T("Adding directory"),
+ _T(""),
+ 1000,
+ this,
+ wxPD_ELAPSED_TIME |
+ // wxPD_ESTIMATED_TIME |
+ // wxPD_REMAINING_TIME |
+ wxPD_CAN_ABORT );
+
+ mCurrentDirectory = FD->GetPath();
+
+ // TO DO : select the current tree handler
+ mGimmick->AddDir("Local database",dirname,recurse);
+
+ mProgressDialog->Pulse(_T("Updating view..."));
+
+ UpdateTreeViewLevel("Local database",1);
+ delete mProgressDialog;
+ DisplayAddSummary();
}
-
- wxBusyCursor busy;
- wxString title(_T("Adding directory"));
- if (recurse)
- title = _T("Adding directory (recursive)");
- mProgressDialog =
- new wxProgressDialog(_T("Adding directory"),
- _T(""),
- 1000,
- this,
- wxPD_ELAPSED_TIME |
- // wxPD_ESTIMATED_TIME |
- // wxPD_REMAINING_TIME |
- wxPD_CAN_ABORT );
- std::string dirname = wx2std (FD->GetPath()) ;
- mCurrentDirectory = FD->GetPath();
-
- // TO DO : select the current tree handler
- mGimmick->AddDir("Local database",dirname,recurse);
-
- mProgressDialog->Pulse(_T("Updating view..."));
-
- UpdateTreeViewLevel("Local database",1);
- delete mProgressDialog;
- DisplayAddSummary();
- }
+ }
+
+ //=================================================
+ // Test a directory to know if contains sub-directory to analyze
+ bool WxGimmickView::isNeedRecursive(std::string i_name)
+ {
+ boost::filesystem::directory_iterator iter(i_name), end_iter;
+ bool bfindir = false;
+ for(; iter != end_iter; ++iter)
+ {
+ if(boost::filesystem::is_directory(*iter))
+ {
+ return true;
+ }
+ }
+ return false;
}
//=================================================
GetCtrl(l)->InsertItem(item);
//Setting attributes
-
- for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
+ for (int k=0; k<GetCtrl(l)->GetColumnCount(); ++k)
{
- std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
+ std::string val;
+ // Temporary correction : it works but no explanation about the problem FCY
+ if(k==0 && level <3)
+ val = (*j)->GetAttribute("NumberOfChildren");
+ else
+ val = (*j)->GetAttribute(mLevelList[l].key[k]);
if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry()) // Date
{
boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));