From 26ccd8ab2e11443157665cc6c64c9ccef706fc81 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Mon, 17 May 2004 16:29:22 +0000 Subject: [PATCH] - wxbRestorePanel : Implemented refresh buttons git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1366 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/CHANGELOG | 3 + bacula/src/wx-console/TODO | 4 -- bacula/src/wx-console/wxbrestorepanel.cpp | 87 +++++++++++++++++------ bacula/src/wx-console/wxbrestorepanel.h | 12 ++-- 4 files changed, 78 insertions(+), 28 deletions(-) diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 17be54a41b..a5ccef9071 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -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 diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 9d64017ed8..9408f38eb2 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -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:] diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 4f4ac64dd6..2a6f0ca9b3 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -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(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) { diff --git a/bacula/src/wx-console/wxbrestorepanel.h b/bacula/src/wx-console/wxbrestorepanel.h index ebfb82f364..bf991cd36d 100644 --- a/bacula/src/wx-console/wxbrestorepanel.h +++ b/bacula/src/wx-console/wxbrestorepanel.h @@ -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(); -- 2.39.2