Convert database tree from TTreeView to TVirtualStringTree.

- Fixes bug #271 "F5 shortcut in database tree not working"
- Fullfills rfe #519 "Highlight selected item in tree view when focus is elsewhere"
- Fixes inconsistent expansion state of nodes after refreshing
- Fixes plus sign staying when a db node with 0 tables was selected
- Slightly enhances painting speed within the dbtree
- Removes temporary storage of a rightclicked node (DBRightClickSelectItem). VirtualTree handles its right clicked selection exactly like the left clicked one, which makes makes coding a bit cleaner as we can always use the selected item instead of hacking with the right and left clicked node. On the other side it removes a quite user friendly feature. Well, we can reimplement this feature later, though it's not user UNfriendly currently.
- Reasonably rename the StringList "OnlyDBs" to "DatabasesWanted" and "OnlyDBs2" to "Databases"
This commit is contained in:
Ansgar Becker
2008-06-13 23:05:51 +00:00
parent c265dd2f94
commit 41074d211e
13 changed files with 597 additions and 807 deletions

View File

@ -28,7 +28,6 @@ type
public
{ Public declarations }
EditViewName: String;
DBNode: TTreeNode;
end;
@ -83,10 +82,7 @@ begin
// Edit mode
Caption := 'Edit view ...';
editName.Text := EditViewName;
if not Assigned(DBNode) then
db := Mainform.ChildWin.ActiveDatabase
else
db := DBNode.Text;
db := Mainform.ChildWin.ActiveDatabase;
ds := Mainform.ChildWin.GetResults('SELECT * FROM '+Mainform.mask(DBNAME_INFORMATION_SCHEMA)+'.VIEWS ' +
'WHERE TABLE_SCHEMA = '+esc(db)+' AND TABLE_NAME = '+esc(EditViewName));
if ds.RecordCount = 0 then
@ -167,8 +163,6 @@ begin
viewname := EditViewName;
end;
viewname := Mainform.mask(viewname);
if Assigned(DBNode) then
viewname := Mainform.mask(DBNode.Text) + '.' + viewname;
if rgAlgorithm.Enabled and (rgAlgorithm.ItemIndex > -1) then
sql := sql + 'ALGORITHM = '+Uppercase(rgAlgorithm.Items[rgAlgorithm.ItemIndex])+' ';
sql := sql + 'VIEW ' + viewname+' AS '+SynMemoSelect.Text+' ';
@ -181,15 +175,10 @@ begin
// Probably rename view
if (EditViewName <> '') and (EditViewName <> editName.Text) then begin
renamed := Mainform.mask(editName.Text);
if Assigned(DBNode) then
renamed := Mainform.mask(DBNode.Text) + '.' + renamed;
Mainform.Childwin.ExecUpdateQuery('ALTER TABLE '+viewname
+ ' RENAME '+renamed);
end;
if (not Assigned(DBNode)) or (DBNode.Text = Mainform.Childwin.ActiveDatabase) then
Mainform.ChildWin.MenuRefreshClick( Sender )
else
Mainform.ChildWin.PopulateTreeTableList( DBNode, True );
Mainform.ChildWin.RefreshTreeDB(Mainform.ChildWin.ActiveDatabase);
except
on E: THandledSQLError do begin
MessageDlg(E.Message, mtError, [mbOK], 0);