type
TOParentPos =
class
public
Reiter :
string;
TextSnip :
string;
end;
TOSearchResult =
class(TOParentPos)
public
Number : Integer;
Kategorie :
string;
Ueberschrift :
string;
end;
{...}
procedure TSearchResultForm.FormCreate(Sender: TObject);
var
tmpCaption :
string;
daten : TOSearchResult;
parentpos : TOParentPos;
counter : Integer;
node : PVirtualNode;
begin
counter := 0;
VST_SearchResult.NodeDataSize := SizeOf(TOParentPos);
with MainForm.IBQuery
do
begin
SQL.Clear;
SQL.Text := SQLCommand;
Open;
Active := True;
while not EOF
do
begin
counter := counter + 1;
MainForm.GetCategoryPath(tmpCaption, Fields[1].AsInteger, '
');
daten := TOSearchResult.Create;
with daten
do
begin
Number := counter;
Kategorie := tmpCaption;
Ueberschrift := Fields[2].AsString;
end;
node := VST_SearchResult.AddChild(
nil, daten);
parentpos := TOParentPos.Create;
parentpos.Reiter := '
Sourcecode ' + IntToStr(PosEx(SearchKeywords, Fields[3].AsString));
parentpos.TextSnip := '
Test';
VST_SearchResult.AddChild(node, parentpos);
Next;
end;
Active := False;
end;
// END-With IBQuery
SearchResultCount := counter;
end;
procedure TSearchResultForm.VST_SearchResultDblClick(Sender: TObject);
var
tmpSelectedText:
string;
I: Integer;
Node: PVirtualNode;
Daten: TOSearchResult;
begin
with MainForm
do
begin
M_Description.SelAttributes.Style := [];
M_Description.SelAttributes.Color := clWindowText;
Node := VST_SearchResult.FocusedNode;
Daten := TOSearchResult(VST_SearchResult.GetNodeData(Node)^);
tmpSelectedText := Daten.Ueberschrift;
for I := 0
to TV_Category.Items.Count - 1
do
if tmpSelectedText = TV_Category.Items.Item[i].Text
then
with TV_Category
do
begin
Selected := Items.Item[i];
Selected.SelectedIndex := 2;
Selected.ImageIndex := 2;
TV_CategoryChange(Sender,Selected);
end;
end;
end;
procedure TSearchResultForm.VST_SearchResultFreeNode(Sender: TBaseVirtualTree;
Node: PVirtualNode);
var
daten: TOParentPos;
begin
daten := TOParentPos(VST_SearchResult.GetNodeData(Node)^);
daten.free;
end;
procedure TSearchResultForm.VST_SearchResultGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
var CellText: WideString);
var
daten: TOSearchResult;
begin
daten := TOSearchResult(VST_SearchResult.GetNodeData(Node)^);
case Column
of
0: CellText := IntToStr(daten.Number);
1:
if daten
is TOSearchResult
then
CellText := daten.Kategorie
else
CellText := TOParentPos(daten).Reiter;
2:
if daten
is TOSearchResult
then
CellText := daten.Ueberschrift
else
CellText := TOParentPos(daten).TextSnip;
end;
end;