#include "icons/help.xpm"
#include <wx/imaglist.h>
+#include<boost/filesystem/operations.hpp>
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<<"'"<<std::endl);
// Create the WxTreeView
- WxTreeView* view = new WxTreeView(h,this,mNotebook,-1);
+ WxTreeView* view = new WxTreeView(h,tdh,this,mNotebook,-1);
// TO DO : TEST THAT A VIEW WITH SAME NAME IS NOT
// ALREADY IN THE MAP
//=================================================
void WxGimmickView::OnAddFiles(wxCommandEvent& event)
{
+ mViewer->StopPlayer();
long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
std::string wc("*.*");
wxFileDialog* FD = new wxFileDialog( 0,
UpdateTreeViewLevel("Local database",1);
delete mProgressDialog;
DisplayAddSummary();
+
}
-
+ mViewer->StartPlayer();
}
//=================================================
//=================================================
void WxGimmickView::OnAddDir(wxCommandEvent& event)
{
+ mViewer->StopPlayer();
long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
wxDirDialog* FD =
new wxDirDialog( 0,
if (FD->ShowModal()==wxID_OK)
{
+
- bool recurse = false;
+ 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();
- if (wxMessageBox(_T("Recurse into sub-directories ?"),
- _T("Scan directory"),
- wxYES_NO,this ) == wxYES)
- {
- recurse = true;
}
-
- 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();
- }
+ mViewer->StartPlayer();
+ }
+
+ //=================================================
+ // 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;
}
//=================================================
//=================================================
void WxGimmickView::OnRemove(wxCommandEvent& event)
{
- //TODO Select current tree handler
+ //TODO Select current tree handler
wxBusyCursor busy;
GetTreeViewMap()["Local database"]->RemoveSelected();
mess << times;
*/
wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this);
+ }
+
+ void WxGimmickView::OnAddDB(wxCommandEvent& event)
+ {
+
+ //Select DB
+ long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
+ std::string wc("*.sqlite3*");
+ wxFileDialog* FD = new wxFileDialog( 0,
+ _T("Select file"),
+ _T(""),
+ _T(""),
+ crea::std2wx(wc),
+ style,
+ wxDefaultPosition);
+
+ if (FD->ShowModal()==wxID_OK)
+ {
+ wxBusyCursor busy;
+ wxArrayString files;
+ FD->GetPaths(files);
+ for(int i = 0; i< files.size(); i++)
+ {
+ std::string snb = "remote_1";
+ mGimmick->addDB(snb, crea::wx2std(files[i]));
+ // UpdateTreeViewLevel("remote_1",1);
+ }
+ }
+
+
}
//=================================================
EVT_TOOL(TOOL_ADDFILES_ID, WxGimmickView::OnAddFiles)
EVT_TOOL(TOOL_ADDDIR_ID, WxGimmickView::OnAddDir)
EVT_TOOL(TOOL_REMOVE_ID, WxGimmickView::OnRemove)
+ EVT_TOOL(TOOL_ADDDATABASE_ID, WxGimmickView::OnAddDB)
END_EVENT_TABLE()
//=================================================