]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOWxTreeView.cpp
Correction sur l'affichage des dates et des temps.
[creaImageIO.git] / src2 / creaImageIOWxTreeView.cpp
index d81877f38ea60104dd1ff99cc669bf40db004325..49c72ef98bd8d61bcc1c0be867ab7dade7677570 100644 (file)
@@ -3,6 +3,13 @@
 #include <creaImageIOSystem.h>
 #include <wx/splitter.h>
 #include <wx/gdicmn.h>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/local_time_adjustor.hpp>
+#include <boost/date_time/c_local_time_adjustor.hpp>
+
+
+
 
 const std::string empty_string("");
 
@@ -127,8 +134,8 @@ namespace creaImageIO
     int col_style = wxLIST_FORMAT_LEFT;
 
     // Creating the ListCtrl for the levels > 0 (not for Root level)
-    for (int i = 1;
-        i < handler->GetTree().GetNumberOfLevels();
+    for (int i = 0;
+        i < handler->GetTree().GetNumberOfLevels() -1;
         ++i)
       {
 
@@ -141,10 +148,11 @@ namespace creaImageIO
        // If the first level : parent = this
        wxWindow* sparent = this;
        // else parent = last splitter
-       if (i>1) sparent = mLevelList[i-2].wxSplitter;
+       if (i>0) 
+               sparent = mLevelList[i-1].wxSplitter;
 
        level.wxSplitter = new wxSplitterWindow( sparent , -1);
-       if(i!=1)
+       if(i!=0)
        {
        level.wxSplitter->Show(false);
        }
@@ -163,10 +171,11 @@ namespace creaImageIO
        int col = 0;
        std::string title;
        tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
-       for (a  = handler->GetTree().GetAttributeDescriptorList(i).begin();
-            a != handler->GetTree().GetAttributeDescriptorList(i).end();
+       for (a  = handler->GetTree().GetAttributeDescriptorList(i+1).begin();
+            a != handler->GetTree().GetAttributeDescriptorList(i+1).end();
             ++a)
-         {
+
+{
        
            GimmickDebugMessage(5,"Creating column "<<col<<" : "
                                <<a->GetName()
@@ -187,15 +196,19 @@ namespace creaImageIO
                  {
                    title=a->GetName();
                  }
-               
+                 std::string temp = a->GetKey();
+                 if (temp.compare("ID") != 0)
+                 {
                ctrl->InsertColumn(col, 
                                   crea::std2wx(title),
                                   col_style);
+               col++;
+                 }
                level.key.push_back(a->GetKey());
 
                //          ctrl->SetColumnWidth(col, wxLIST_AUTOSIZE );
 
-               col++;
+               
              }
                
          }
@@ -466,11 +479,25 @@ namespace creaImageIO
                            
                                for (int k=0; k<GetCtrl(l)->GetColumnCount(); k++)
                                {
-                               std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
-                               if (val.size()==0) val = "?";
-                               item.SetText( crea::std2wx(val));
-                               item.SetColumn(k);
-                               GetCtrl(l)->SetItem(item);
+                                       std::string val = (*j)->GetAttribute(mLevelList[l].key[k]);
+                                       if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isDateEntry())
+                                       {
+                                               boost::gregorian::date d1(boost::gregorian::from_undelimited_string(val));
+                                               val = to_iso_extended_string(d1);
+                                       }
+                                       else if(((*j)->GetAttributeDescriptor(mLevelList[l].key[k])).isTimeEntry())
+                                       {
+                                               if (val != "" || val != " ")
+                                                       val = val.substr(0,2) + " : " + val.substr(2,2) + " : " + val.substr(4,2);
+                                       }
+                                       else
+                                       {
+
+                                       }
+                                       if (val.size()==0) val = "?";
+                                       item.SetText( crea::std2wx(val));
+                                       item.SetColumn(k);
+                                       GetCtrl(l)->SetItem(item);
                                }       
                            
                        }
@@ -861,6 +888,17 @@ namespace creaImageIO
                }
     }
 
+  }
+  //================================================================
+   //=================================================
+  void WxTreeView::OnKeyDown(wxListEvent &event)
+  {
+         if(event.GetKeyCode() == WXK_DELETE)
+         {
+                   RemoveSelected();
+               //      ClearSelection();
+         }
+                 
   }
   //================================================================
 
@@ -1041,6 +1079,7 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
     EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
 #endif
   */
+    EVT_LIST_KEY_DOWN(-1, WxTreeView::OnKeyDown)
     EVT_LIST_ITEM_SELECTED(-1, WxTreeView::OnItemSelected)
   
     EVT_LIST_ITEM_DESELECTED(-1, WxTreeView::OnItemDeSelected)