]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxGimmickView.cpp
Remove timestamp_database and timestamp files (now management only with maintenance_d...
[creaImageIO.git] / src2 / creaImageIOWxGimmickView.cpp
index a77f9a7fe9de9bdc1726f0db2b1d01a3b22868ee..447b35bc298a4a9a99a7e6e2f552f7138836614c 100644 (file)
@@ -20,6 +20,7 @@ using namespace crea;
 #include "icons/synchronize.xpm"
 #include "icons/settings.xpm"
 #include "icons/tools.xpm"
+//#include "icons/import.xpm"
 
 #include <wx/imaglist.h>
 #include <wx/popupwin.h>
@@ -423,9 +424,10 @@ namespace creaImageIO
                mProgressDialog = 
                new wxProgressDialog(_T("Adding directory"),
                                        _T(""),
-                                       1000,
+                                       NumberFilesToAdd(dirname,recurse),
                                        this,
-                                       wxPD_ELAPSED_TIME |
+                                       wxPD_ELAPSED_TIME | 
+                                       wxPD_SMOOTH |
                                        //                             wxPD_ESTIMATED_TIME | 
                                        //                             wxPD_REMAINING_TIME |
                                        wxPD_CAN_ABORT );
@@ -442,6 +444,33 @@ namespace creaImageIO
     mViewer->StartPlayer();
   }
 
+
+   //=================================================
+  // Determines number of files potentially to add to database
+   int WxGimmickView::NumberFilesToAdd(const std::string &dirpath, bool recursive)
+  {
+          int nb = 0;
+          if ( !boost::filesystem::exists( dirpath ) ) return nb;
+          boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
+          for ( boost::filesystem::directory_iterator itr( dirpath );  itr != end_itr;  ++itr )
+         {
+               // If is directory & recurse : do recurse
+               if ( boost::filesystem::is_directory(itr->status()) )
+               {
+                       if (recursive) 
+                       {
+                               nb += NumberFilesToAdd(itr->string(), recursive);
+                       }
+               }
+               else
+               {
+                       nb++;
+               }
+         }
+       return nb;
+
+  }
+
     //=================================================
    // Test a directory to know if contains sub-directory to analyze
   bool WxGimmickView::isNeedRecursive(std::string i_name)
@@ -715,6 +744,38 @@ namespace creaImageIO
     dial->ShowModal();
   }
   //=================================================
+  void WxGimmickView::OnImportExport(wxCommandEvent &Event)
+  {
+       wxBusyCursor busy;
+       // Test if one image is selected => export
+       // if not =>import
+    if (GetTreeViewMap()[crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection()))])
+       {
+               ExportImages();
+       }
+       else
+       {
+               ImportImages();
+       }
+  }
+
+  void WxGimmickView::ExportImages()
+  {
+               //Archive selection: name, emplacement
+               //same process than copy local but to a zip
+               // if settings are yes "always ask for descriptor addition", ask
+               // if settings are yes, adding descriptor
+  }
+
+  void WxGimmickView::ImportImages()
+  {
+               //Find the *.zip
+               //dezip
+               // Contain a descriptor.text
+               // create a new database, and add to database
+               // if not, add to current database
+               // 
+  }
 
   //=================================================
   //AndresDonadio