{ Private \90é\8c¾ }
FBoard: TBoard;
FThreadItem: TThreadItem;
+ procedure CopyTree( dst, src : TTreeNode );
// procedure PrepareFavoriteTree(Favo: TFavoriteItem; Node: TTreeNode);
function GetGikoFavoriteNode(FavFolder: TFavoriteFolder): TTreeNode;
public
{$R *.dfm}
-procedure TFavoriteAddDialog.FormCreate(Sender: TObject);
+procedure TFavoriteAddDialog.CopyTree( dst, src : TTreeNode );
var
- i: Integer;
+ newNode : TTreeNode;
begin
- FolderTreeView.Items := FavoriteDM.TreeView.Items;
-
- for i := FolderTreeView.Items.Count - 1 downto 0 do begin
- if not (TObject(FolderTreeView.Items[i].Data) is TFavoriteFolder) then
- FolderTreeView.Items[i].Delete;
+ while src <> nil do begin
+ if TObject( src.Data ) is TFavoriteFolder then begin
+ newNode := FolderTreeView.Items.AddChildObject( dst, src.Text, src.Data );
+ newNode.ImageIndex := src.ImageIndex;
+ newNode.SelectedIndex := src.SelectedIndex;
+ CopyTree( newNode, src.getFirstChild );
+ end;
+ src := src.getNextSibling;
end;
+end;
+
+procedure TFavoriteAddDialog.FormCreate(Sender: TObject);
+var
+ src : TTreeNode;
+ node : TTreeNode;
+begin
+ FolderTreeView.Items.BeginUpdate;
+
+ // FavoriteDM \82Ì\83t\83H\83\8b\83_\8aK\91w\82ð\83R\83s\81[
+ FolderTreeView.Items.Clear;
+ src := FavoriteDM.TreeView.Items.GetFirstNode;
+ node := TTreeNode.Create( FolderTreeView.Items );
+ node := FolderTreeView.Items.AddFirst( node, src.Text );
+ node.Data := src.Data;
+ node.ImageIndex := src.ImageIndex;
+ node.SelectedIndex := src.SelectedIndex;
+ CopyTree( node, src.getFirstChild );
if FolderTreeView.Items.GetFirstNode <> nil then begin
FolderTreeView.Items.GetFirstNode.Expanded := True;
FolderTreeView.Items.GetFirstNode.Selected := True;
end;
+ FolderTreeView.Items.EndUpdate;
+
{ Node := FolderTreeView.Items.AddChild(nil, GikoForm.Favorite.Root.Title);
Node.ImageIndex := 0;
Node.Data := GikoForm.Favorite.Root;
procedure TFavoriteAddDialog.OKButtonClick(Sender: TObject);
var
- i: Integer;
- Node: TTreeNode;
- FavoBoardItem: TFavoriteBoardItem;
- FavoThreadItem: TFavoriteThreadItem;
- FavNode: TTreeNode;
+ Node : TTreeNode;
+ NewNode : TTreeNode;
+ FavoBoardItem : TFavoriteBoardItem;
+ FavoThreadItem : TFavoriteThreadItem;
+ FavNode : TTreeNode;
begin
if FolderTreeView.Selected = nil then
Exit;
- Node := nil;
- for i := 0 to FolderTreeView.Items.Count - 1 do begin
- FavNode := GetGikoFavoriteNode(FolderTreeView.Items[i].Data);
+ Node := FolderTreeView.Items.GetFirstNode;
+ while Node <> nil do begin
+ FavNode := GetGikoFavoriteNode(Node.Data);
if FavNode = nil then begin
- FavNode := GetGikoFavoriteNode(FolderTreeView.Items[i].Parent.Data);
- if FavNode <> nil then
- Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, FolderTreeView.Items[i].Text, FolderTreeView.Items[i].Data);
- Node.ImageIndex := 14;
- Node.SelectedIndex := 14;
+ if Node.Parent <> nil then
+ FavNode := GetGikoFavoriteNode(Node.Parent.Data);
+ if FavNode <> nil then begin
+ NewNode := FavoriteDM.TreeView.Items.AddChildObject(FavNode, Node.Text, Node.Data);
+ NewNode.ImageIndex := 14;
+ NewNode.SelectedIndex := 14;
+ end;
end;
+ Node := Node.GetNext;
end;
-
FavNode := GetGikoFavoriteNode(FolderTreeView.Selected.Data);
if FavNode <> nil then begin
if FBoard <> nil then begin
FavoBoardItem := TFavoriteBoardItem.Create( FBoard.URL, FBoard.Title, FBoard );
- Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, CaptionEdit.Text, FavoBoardItem);
- Node.ImageIndex := 15;
- Node.SelectedIndex := 15;
+ NewNode := FavoriteDM.TreeView.Items.AddChildObject(FavNode, CaptionEdit.Text, FavoBoardItem);
+ NewNode.ImageIndex := 15;
+ NewNode.SelectedIndex := 15;
end else if FThreadItem <> nil then begin
FavoThreadItem := TFavoriteThreadItem.Create( FThreadItem.URL, FThreadItem.Title, FThreadItem );
- Node := FavoriteDM.TreeView.Items.AddChildObject(FavNode, CaptionEdit.Text, FavoThreadItem);
- Node.ImageIndex := 16;
- Node.SelectedIndex := 16;
+ NewNode := FavoriteDM.TreeView.Items.AddChildObject(FavNode, CaptionEdit.Text, FavoThreadItem);
+ NewNode.ImageIndex := 16;
+ NewNode.SelectedIndex := 16;
end;
end;
function TFavoriteAddDialog.GetGikoFavoriteNode(FavFolder: TFavoriteFolder): TTreeNode;
var
- i: Integer;
+ Node : TTreeNode;
begin
- Result := nil;
- for i := 0 to FavoriteDM.TreeView.Items.Count - 1 do begin
- if FavoriteDM.TreeView.Items[i].Data = FavFolder then begin
- Result := FavoriteDM.TreeView.Items[i];
+ Result := nil;
+ Node := FavoriteDM.TreeView.Items.GetFirstNode;
+ while Node <> nil do begin
+ if Node.Data = FavFolder then begin
+ Result := Node;
Exit;
end;
+ Node := Node.GetNext;
end;
end;