]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbRestorePanel : Implemented refresh buttons
authorNicolas Boichat <nicolas@boichat.ch>
Mon, 17 May 2004 16:29:22 +0000 (16:29 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Mon, 17 May 2004 16:29:22 +0000 (16:29 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1366 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbrestorepanel.h

index 17be54a41bd331c45eef6c36f18f73c887710c37..a5ccef90715faad1f0c4e50223cf0319202a64cd 100644 (file)
@@ -1,3 +1,6 @@
+17-05-2004 :
+ - wxbRestorePanel : Implemented refresh buttons
+
 15-05-2004 :
  - wxbRestorePanel : The user can now mark/unmark a range of files selected
      with shift-click or multiple files selected with ctl-click, by
index 9d64017ed8cd7249fa28bd28dbec50ca980adab3..9408f38eb2c3534cb2c8e2e4c2dfb785d567e2d1 100644 (file)
@@ -10,12 +10,8 @@ Mac OS X : "You must first get a unique identifier for your application,
 Mac OS X : Ask kern for the status of this distribution (who is
   the package releaser ?)
 
-wxbRestorePanel : Implement refresh buttons
-
 wxbRestorePanel : Add images in add/remove/refresh buttons
 
-general : replace delete by delete [] when needed
-
 wxbRestorePanel : disable controls when working
 
 [postponed to July:]
index 4f4ac64dd6cc9e33696e51e5c139fb3fd65710d2..2a6f0ca9b31a6da350df53d5ac45c4382d7b1778 100644 (file)
@@ -1133,7 +1133,7 @@ void wxbRestorePanel::CmdList(wxTreeItemId item) {
       if (!item.IsOk()) {
          return;
       }
-      UpdateTreeItem(item, (tree->GetSelection() == item));
+      UpdateTreeItem(item, (tree->GetSelection() == item), false);
     
       if (list->GetItemCount() >= 1) {
          int firstwidth = list->GetSize().GetWidth(); 
@@ -1347,7 +1347,7 @@ wxbDataTokenizer* wxbRestorePanel::WaitForEnd(wxString cmd, bool keepresults, bo
 }
 
 /* Run a dir command, and waits until result is fully received. */
-void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist) {
+void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse) {
 //   this->updatelist = updatelist;
    wxbDataTokenizer* dt;
 
@@ -1400,6 +1400,9 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist) {
                   tree->SetItemImage(treeid, stat, wxTreeItemIcon_Selected);
                   static_cast<wxbTreeItemData*>(tree->GetItemData(treeid))->SetMarked(file[6]);
                }
+               if ((recurse) && (tree->IsExpanded(treeid))) {
+                  UpdateTreeItem(treeid, false, true);
+               }
                updated = true;
                break;
             }
@@ -1606,23 +1609,59 @@ void wxbRestorePanel::UpdateTreeItemState(wxTreeItemId item) {
    UpdateTreeItemState(tree->GetItemParent(item));
 }
 
-/* 
- * Refresh a tree item, and all its childs, 
- * by asking the director for new lists 
- */
-void wxbRestorePanel::RefreshTree(wxTreeItemId item) {
-/*   UpdateTreeItem(item, updatelist);*/
+/* Refresh the whole tree. */
+void wxbRestorePanel::RefreshTree() {
+   /* Save current selection */
+   wxArrayString current;
+   
+   wxTreeItemId item = currentTreeItem;
+   
+   while ((item.IsOk()) && (item != tree->GetRootItem())) {
+      current.Add(tree->GetItemText(item));
+      item = tree->GetItemParent(item);
+   }
 
-   /* Update all child which are not collapsed */
-/*   long cookie;
-   wxTreeItemId currentChild = tree->GetFirstChild(item, cookie);
+   /* Update the tree */
+   UpdateTreeItem(tree->GetRootItem(), false, true);
 
-   while (currentChild.IsOk()) {
-      if (tree->IsExpanded(currentChild))
-         UpdateTree(currentChild, false);
+   /* Reselect the former selected item */   
+   item = tree->GetRootItem();
+   
+   if (current.Count() == 0) {
+      tree->SelectItem(item);
+      return;
+   }
+   
+   bool match;
+   
+   for (int i = current.Count()-1; i >= 0; i--) {
+      long cookie;
+      wxTreeItemId currentChild = tree->GetFirstChild(item, cookie);
+      
+      match = false;
+      
+      while (currentChild.IsOk()) {
+         if (tree->GetItemText(currentChild) == current[i]) {
+            item = currentChild;
+            match = true;
+            break;
+         }
+   
+         currentChild = tree->GetNextChild(item, cookie);
+      }
+      
+      if (!match) break;
+   }
+   
+   UpdateTreeItem(item, true, false); /* Update the list */
+   
+   tree->SelectItem(item);
+}
 
-      currentChild = tree->GetNextChild(item, cookie);
-   }*/
+void wxbRestorePanel::RefreshList() {
+   if (currentTreeItem.IsOk()) {
+      UpdateTreeItem(currentTreeItem, true, false); /* Update the list */
+   }
 }
 
 /* Update first config, adapting settings to the job name selected */
@@ -1991,6 +2030,7 @@ void wxbRestorePanel::OnTreeRefresh(wxCommandEvent& event) {
       return;
    }
    
+   RefreshTree();
 }
 
 void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) {
@@ -1998,9 +2038,14 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) {
       //event.Skip();
       return;
    }
+   
+   if (list->GetSelectedItemCount() == 0) {
+      return;
+   }
+   
    SetCursor(*wxHOURGLASS_CURSOR);
-   working = true;
-     
+   working = true;  
+   
    long* items = new long[list->GetSelectedItemCount()];
    
    int num = 0;
@@ -2016,7 +2061,9 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) {
    
    delete[] items;
    
-   OnListChanged(wxListEvent());
+   wxListEvent listevt;
+   
+   OnListChanged(listevt);
    
    event.Skip();
    tree->Refresh();
@@ -2163,7 +2210,7 @@ void wxbRestorePanel::OnListRefresh(wxCommandEvent& WXUNUSED(event)) {
       return;
    }
    
-   
+   RefreshList();
 }
 
 void wxbRestorePanel::OnConfigUpdated(wxCommandEvent& event) {
index ebfb82f364d1989a3fc55217853a75fab8391738..bf991cd36d3e4e1ec8003b2772322759a020b085 100644 (file)
@@ -105,8 +105,9 @@ class wxbRestorePanel : public wxbPanel
        * containing the data. */
       wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
 
-      /* Run a dir command, and waits until result is fully received. */
-      void UpdateTreeItem(wxTreeItemId item, bool updatelist);
+      /* Run a dir command, and waits until result is fully received.
+       * If recurse is true, update the children too. */
+      void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
 
       /* Parse dir command results. */
       wxString* ParseList(wxString line);
@@ -120,8 +121,11 @@ class wxbRestorePanel : public wxbPanel
       /* Update a tree item parents' state */
       void UpdateTreeItemState(wxTreeItemId item);
 
-      /* Refresh a tree item, and all its children. */
-      void RefreshTree(wxTreeItemId item);
+      /* Refresh the whole tree. */
+      void RefreshTree();
+      
+      /* Refresh file list */
+      void RefreshList();
       
       /* Update first config, adapting settings to the job name selected */
       void UpdateFirstConfig();