]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxGimmickView.cpp
bug correction : no spaces in descriptor files
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.cpp
index 6bcf489dbcc3029ed8053ef5759502bafe2ad6ff..024bc8c19589838b05252260ae162b0cb466aa01 100644 (file)
@@ -220,7 +220,7 @@ namespace creaImageIO
 
     // Add Notebook page
     mNotebook->AddPage( view, crea::std2wx(name) );
-
+       
   }
 
   //======================================================================
@@ -289,6 +289,7 @@ namespace creaImageIO
   //=================================================
   void WxGimmickView::OnAddFiles(wxCommandEvent& event)
   {
+    mViewer->StopPlayer();
    long style = wxOPEN | wxFILE_MUST_EXIST | wxFD_MULTIPLE;
     std::string wc("*.*");
     wxFileDialog* FD = new wxFileDialog( 0, 
@@ -324,21 +325,24 @@ namespace creaImageIO
                               wxPD_CAN_ABORT );
 
        // TO DO : select the current tree handler
-       mGimmick->AddFiles("Local database",filenames);
+       mGimmick->AddFiles(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),filenames);
 
        mProgressDialog->Pulse(_T("Updating view..."));
 
-       UpdateTreeViewLevel("Local database",1);
+       UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
        delete mProgressDialog;
        DisplayAddSummary();    
+
       }
-       
+       mViewer->StartPlayer(); 
   }
   //=================================================
 
   //=================================================
   void WxGimmickView::OnAddDir(wxCommandEvent& event)
   {
+    mViewer->StopPlayer();
+       std::string name = crea::wx2std(mNotebook->GetCurrentPage()->GetName());
     long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
     wxDirDialog* FD = 
       new wxDirDialog( 0, 
@@ -348,6 +352,7 @@ namespace creaImageIO
     
     if (FD->ShowModal()==wxID_OK)
       {
+
        
                  std::string dirname = wx2std (FD->GetPath());
                  bool recurse =  isNeedRecursive(dirname);
@@ -371,16 +376,15 @@ namespace creaImageIO
                                        wxPD_CAN_ABORT );
                
                mCurrentDirectory = FD->GetPath();  
-               
-               // TO DO : select the current tree handler
-               mGimmick->AddDir("Local database",dirname,recurse);
-               
+               mGimmick->AddDir(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),dirname,recurse);
                mProgressDialog->Pulse(_T("Updating view..."));
                
-               UpdateTreeViewLevel("Local database",1);
+               UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
                delete mProgressDialog;
                DisplayAddSummary();
+
          }
+    mViewer->StartPlayer();
   }
 
     //=================================================
@@ -631,6 +635,44 @@ namespace creaImageIO
     mess << times;
     */
     wxMessageBox(std2wx(mess.str()),_T("Addition result"),wxOK,this);
+  }
+
+  //////////////////////////////////////////////////
+  // Add a DB to application                                     //
+  // @param event : WxEvent                                              //
+  // @return : -                                                                 //
+  //////////////////////////////////////////////////
+  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);
+               std::stringstream st;
+               for(int i = 0; i< files.size(); i++)
+               {
+                       st<< "remote_" << i+1;
+                       //create TreeHandler
+                       mGimmick->addDB(st.str(), crea::wx2std(files[i]));
+                       //create TreeView
+                       CreateSingleTreeView(st.str());
+               }
+       }
+    
+               
   }
 
    //=================================================
@@ -640,6 +682,7 @@ namespace creaImageIO
     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()
   //=================================================