X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOWxGimmickView.cpp;h=6bcf489dbcc3029ed8053ef5759502bafe2ad6ff;hb=42f7c93a6f8fc2beeb8709be1b3616ec40f4699e;hp=f60480e8365f0762b610b088c582cd52d15eadba;hpb=b573a12c2f9e5c887ae36166c531fb17cdb7db8f;p=creaImageIO.git diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index f60480e..6bcf489 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -12,6 +12,7 @@ using namespace crea; #include "icons/help.xpm" #include +#include namespace creaImageIO { @@ -205,13 +206,13 @@ namespace creaImageIO //====================================================================== /// Create the tree view for TreeHandler provided - void WxGimmickView::CreateTreeView( TreeHandler* h) + void WxGimmickView::CreateTreeView( TreeHandler* h, TimestampDatabaseHandler* tdh) { std::string name(h->GetTree().GetAttribute("Name")); GimmickMessage(2,"Creating the tree view for '"<< name<<"'"<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; } //================================================= @@ -560,7 +575,7 @@ namespace creaImageIO //================================================= void WxGimmickView::OnRemove(wxCommandEvent& event) { - //TODO Select current tree handler + //TODO Select current tree handler wxBusyCursor busy; GetTreeViewMap()["Local database"]->RemoveSelected();