mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 18:12:05 +08:00
Refactor session manager:
* Replace the pulldown by a list to get a better overview * Display last connected and created date in details * Prompt user on form closing if modifications should be saved * Remove moreorless useless image * Remove options "timeout" and "sort database" TODO: Display some help text on the right side when no session at all is existant to help new users.
This commit is contained in:
@ -177,6 +177,7 @@ const
|
||||
REGNAME_FILTERS = 'RecentFilters';
|
||||
REGNAME_SERVERVERSION = 'ServerVersion';
|
||||
REGNAME_LASTCONNECT = 'LastConnect';
|
||||
REGNAME_SESSIONCREATED = 'SessionCreated';
|
||||
REGNAME_DO_STATISTICS = 'DoUsageStatistics';
|
||||
DEFAULT_DO_STATISTICS = False;
|
||||
REGNAME_LAST_STATSCALL = 'LastUsageStatisticCall';
|
||||
|
BIN
res/icons/server_edit.png
Normal file
BIN
res/icons/server_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 749 B |
File diff suppressed because it is too large
Load Diff
@ -10,58 +10,78 @@ interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, Buttons, ExtCtrls, ZPlainMySqlDriver,
|
||||
PngSpeedButton, TntStdCtrls, ComCtrls, ToolWin;
|
||||
StdCtrls, Buttons, ExtCtrls, ComCtrls, WideStrings,
|
||||
TntStdCtrls, VirtualTrees, Menus;
|
||||
|
||||
type
|
||||
Tconnform = class(TForm)
|
||||
editHost: TEdit;
|
||||
lblHost: TLabel;
|
||||
lblUsername: TLabel;
|
||||
editUsername: TEdit;
|
||||
lblPassword: TLabel;
|
||||
editPassword: TEdit;
|
||||
lblPort: TLabel;
|
||||
editPort: TEdit;
|
||||
lblTimeout: TLabel;
|
||||
editTimeout: TEdit;
|
||||
pnlLogo: TPanel;
|
||||
comboSession: TComboBox;
|
||||
imgLogo: TImage;
|
||||
lblSession: TLabel;
|
||||
btnCancel: TButton;
|
||||
btnConnect: TButton;
|
||||
chkCompressed: TCheckBox;
|
||||
lblSeconds: TLabel;
|
||||
btnOpen: TButton;
|
||||
btnSave: TButton;
|
||||
ListSessions: TVirtualStringTree;
|
||||
btnNew: TButton;
|
||||
btnDelete: TButton;
|
||||
grpDetails: TGroupBox;
|
||||
lblHost: TLabel;
|
||||
lblUsername: TLabel;
|
||||
lblPassword: TLabel;
|
||||
lblPort: TLabel;
|
||||
lblOnlyDBs: TLabel;
|
||||
editOnlyDBs: TTntEdit;
|
||||
chkSorted: TCheckBox;
|
||||
btnSaveAndConnect: TButton;
|
||||
tlbEdit: TToolBar;
|
||||
btnNew: TToolButton;
|
||||
btnSave: TToolButton;
|
||||
btnDelete: TToolButton;
|
||||
btnSaveAs: TToolButton;
|
||||
btnEditDesc: TButton;
|
||||
editHost: TEdit;
|
||||
editUsername: TEdit;
|
||||
editPassword: TEdit;
|
||||
editPort: TEdit;
|
||||
chkCompressed: TCheckBox;
|
||||
radioTypeTCPIP: TRadioButton;
|
||||
radioTypeNamedPipe: TRadioButton;
|
||||
memoDatabases: TTntMemo;
|
||||
updownPort: TUpDown;
|
||||
lblLastConnectLeft: TLabel;
|
||||
lblLastConnectRight: TLabel;
|
||||
lblCreatedLeft: TLabel;
|
||||
lblCreatedRight: TLabel;
|
||||
lblNetworkType: TLabel;
|
||||
popupSessions: TPopupMenu;
|
||||
Save1: TMenuItem;
|
||||
Delete1: TMenuItem;
|
||||
Saveas1: TMenuItem;
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure btnSaveAndConnectClick(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure btnConnectClick(Sender: TObject);
|
||||
procedure btnOpenClick(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure btnSaveClick(Sender: TObject);
|
||||
procedure btnSaveAsClick(Sender: TObject);
|
||||
procedure btnNewClick(Sender: TObject);
|
||||
procedure btnDeleteClick(Sender: TObject);
|
||||
procedure comboSessionSelect(Sender: TObject);
|
||||
procedure Modified(Sender: TObject);
|
||||
procedure ButtonEditDescClick(Sender: TObject);
|
||||
procedure Modification(Sender: TObject);
|
||||
procedure radioNetTypeClick(Sender: TObject);
|
||||
procedure ListSessionsGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
|
||||
procedure ListSessionsFocusChanged(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex);
|
||||
procedure ListSessionsGetImageIndex(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
|
||||
var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
procedure ListSessionsNewText(Sender: TBaseVirtualTree; Node: PVirtualNode;
|
||||
Column: TColumnIndex; NewText: WideString);
|
||||
procedure ListSessionsFocusChanging(Sender: TBaseVirtualTree; OldNode,
|
||||
NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
|
||||
var Allowed: Boolean);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
private
|
||||
{ Private declarations }
|
||||
procedure FillSessionCombo(Sender: TObject);
|
||||
FLoaded: Boolean;
|
||||
FSessionNames: TStringlist;
|
||||
FSessionModified, FSessionAdded: Boolean;
|
||||
FOrgNetType: Byte;
|
||||
FOrgHost, FOrgUser, FOrgPassword, FOrgDatabases: WideString;
|
||||
FOrgCompressed: Boolean;
|
||||
FOrgPort: Integer;
|
||||
function SelectedSession: String;
|
||||
procedure RefreshSessionList(RefetchRegistry: Boolean);
|
||||
procedure FinalizeModifications(var CanProceed: Boolean);
|
||||
procedure SaveCurrentValues(Session: String; IsNew: Boolean);
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -83,28 +103,53 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{**
|
||||
FormCreate
|
||||
}
|
||||
procedure Tconnform.FormCreate(Sender: TObject);
|
||||
var
|
||||
LastSession: String;
|
||||
begin
|
||||
// Fix GUI stuff
|
||||
InheritFont(Font);
|
||||
SetWindowSizeGrip(Handle, True);
|
||||
FixVT(ListSessions);
|
||||
FLoaded := False;
|
||||
FSessionNames := TStringList.Create;
|
||||
RefreshSessionList(True);
|
||||
// Focus last session
|
||||
LastSession := GetRegValue(REGNAME_LASTSESSION, '');
|
||||
btnSave.Enabled := False;
|
||||
btnDelete.Enabled := False;
|
||||
SelectNode(ListSessions, FSessionNames.IndexOf(LastSession));
|
||||
end;
|
||||
|
||||
|
||||
// Connect
|
||||
procedure Tconnform.btnConnectClick(Sender: TObject);
|
||||
var
|
||||
btn: TButton;
|
||||
ConType: Byte;
|
||||
procedure Tconnform.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
// Modifications? Ask if they should be saved.
|
||||
FinalizeModifications(CanClose);
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.FormShow(Sender: TObject);
|
||||
begin
|
||||
ListSessions.SetFocus;
|
||||
FLoaded := True;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.btnOpenClick(Sender: TObject);
|
||||
var
|
||||
ConType: Byte;
|
||||
CanProceed: Boolean;
|
||||
begin
|
||||
// Connect to selected session
|
||||
FinalizeModifications(CanProceed);
|
||||
if not CanProceed then
|
||||
Exit;
|
||||
|
||||
Screen.Cursor := crHourglass;
|
||||
// Save last connection name to registry
|
||||
OpenRegistry;
|
||||
MainReg.WriteString(REGNAME_LASTSESSION, comboSession.Text);
|
||||
|
||||
btn := Sender as TButton;
|
||||
btn.Enabled := false;
|
||||
MainReg.WriteString(REGNAME_LASTSESSION, SelectedSession);
|
||||
|
||||
if radioTypeTCPIP.Checked then ConType := NETTYPE_TCPIP
|
||||
else ConType := NETTYPE_NAMEDPIPE;
|
||||
@ -115,67 +160,21 @@ begin
|
||||
editPort.Text,
|
||||
editUsername.Text,
|
||||
editPassword.Text,
|
||||
editOnlyDBs.Text,
|
||||
editTimeout.Text,
|
||||
IntToStr(Integer(chkCompressed.Checked)),
|
||||
IntToStr(Integer(chkSorted.Checked))) then begin
|
||||
memoDatabases.Text,
|
||||
IntToStr(Integer(chkCompressed.Checked))) then begin
|
||||
ModalResult := mrOK;
|
||||
Mainform.SessionName := comboSession.Text;
|
||||
Mainform.SessionName := SelectedSession;
|
||||
end else begin
|
||||
ModalResult := mrNone;
|
||||
btn.Enabled := True;
|
||||
end;
|
||||
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// Read all connections from registry
|
||||
procedure Tconnform.FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure Tconnform.SaveCurrentValues(Session: String; IsNew: Boolean);
|
||||
begin
|
||||
Action := caFree;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.FillSessionCombo(Sender: TObject);
|
||||
begin
|
||||
comboSession.Items.Clear;
|
||||
if MainReg.OpenKey(REGPATH + REGKEY_SESSIONS, true) then
|
||||
MainReg.GetKeyNames(comboSession.Items);
|
||||
if comboSession.Items.Count > 0 then begin
|
||||
comboSession.ItemIndex := 0;
|
||||
comboSessionSelect(Sender);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.FormShow(Sender: TObject);
|
||||
var
|
||||
LastSessionIndex: Integer;
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
FillSessionCombo(Sender);
|
||||
LastSessionIndex := comboSession.Items.IndexOf(GetRegValue(REGNAME_LASTSESSION, ''));
|
||||
if LastSessionIndex > -1 then
|
||||
comboSession.ItemIndex := LastSessionIndex;
|
||||
comboSessionSelect(Sender);
|
||||
comboSession.SetFocus;
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.btnSaveAndConnectClick(Sender: TObject);
|
||||
begin
|
||||
btnSaveClick(Sender);
|
||||
btnConnectClick(Sender);
|
||||
end;
|
||||
|
||||
procedure Tconnform.btnSaveClick(Sender: TObject);
|
||||
begin
|
||||
// save connection!
|
||||
Screen.Cursor := crHourglass;
|
||||
OpenRegistry(comboSession.Text);
|
||||
OpenRegistry(Session);
|
||||
MainReg.WriteString(REGNAME_HOST, editHost.Text);
|
||||
MainReg.WriteString(REGNAME_USER, editUsername.Text);
|
||||
MainReg.WriteString(REGNAME_PASSWORD, encrypt(editPassword.Text));
|
||||
@ -184,12 +183,24 @@ begin
|
||||
MainReg.WriteInteger(REGNAME_NETTYPE, NETTYPE_TCPIP)
|
||||
else
|
||||
MainReg.WriteInteger(REGNAME_NETTYPE, NETTYPE_NAMEDPIPE);
|
||||
MainReg.WriteString(REGNAME_TIMEOUT, editTimeout.Text);
|
||||
MainReg.WriteBool(REGNAME_COMPRESSED, chkCompressed.Checked);
|
||||
MainReg.WriteString(REGNAME_ONLYDBS, Utf8Encode(editOnlyDBs.Text));
|
||||
MainReg.WriteBool(REGNAME_ONLYDBSSORTED, chkSorted.Checked);
|
||||
comboSessionSelect(Sender);
|
||||
Screen.Cursor := crDefault;
|
||||
MainReg.WriteString(REGNAME_ONLYDBS, Utf8Encode(memoDatabases.Text));
|
||||
if IsNew then
|
||||
MainReg.WriteString(REGNAME_SESSIONCREATED, DateTimeToStr(Now));
|
||||
FSessionModified := False;
|
||||
FSessionAdded := False;
|
||||
RefreshSessionList(True);
|
||||
ListSessions.FocusedNode := nil;
|
||||
SelectNode(ListSessions, FSessionNames.IndexOf(Session));
|
||||
btnNew.Enabled := True;
|
||||
btnSave.Enabled := False;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.btnSaveClick(Sender: TObject);
|
||||
begin
|
||||
// Save session settings
|
||||
SaveCurrentValues(SelectedSession, FSessionAdded);
|
||||
end;
|
||||
|
||||
|
||||
@ -198,7 +209,7 @@ var
|
||||
newName: String;
|
||||
NameOK: Boolean;
|
||||
begin
|
||||
// Save as ...
|
||||
// Save session as ...
|
||||
newName := 'Enter new session name ...';
|
||||
NameOK := False;
|
||||
OpenRegistry;
|
||||
@ -209,12 +220,9 @@ begin
|
||||
if not NameOK then
|
||||
MessageDlg('Session name '''+newName+''' already in use.', mtError, [mbOK], 0)
|
||||
else begin
|
||||
Screen.Cursor := crHourglass;
|
||||
MainReg.MoveKey(REGKEY_SESSIONS + comboSession.Text, REGKEY_SESSIONS + newName, False);
|
||||
Screen.Cursor := crDefault;
|
||||
FillSessionCombo(Sender);
|
||||
comboSession.ItemIndex := comboSession.Items.IndexOf(newName);
|
||||
comboSessionSelect(Sender);
|
||||
// Create the key and save its values
|
||||
OpenRegistry(newName);
|
||||
SaveCurrentValues(newName, True);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -222,156 +230,209 @@ end;
|
||||
|
||||
procedure Tconnform.btnNewClick(Sender: TObject);
|
||||
var
|
||||
i : Integer;
|
||||
session : String;
|
||||
i, NewIdx: Integer;
|
||||
NewName: String;
|
||||
begin
|
||||
// save new connection!
|
||||
// Create new session
|
||||
i := 0;
|
||||
session := 'New session';
|
||||
while MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + session) do begin
|
||||
NewName := 'Unnamed';
|
||||
while MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + NewName) do begin
|
||||
inc(i);
|
||||
session := 'New session' + ' (' + inttostr(i) + ')';
|
||||
NewName := 'Unnamed-' + IntToStr(i);
|
||||
end;
|
||||
if not InputQuery('New session ...', 'Session name:', session) then
|
||||
exit;
|
||||
if MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + session) then
|
||||
begin
|
||||
MessageDlg('Session "' + session + '" already exists!', mtError, [mbOK], 0);
|
||||
exit;
|
||||
end;
|
||||
|
||||
Screen.Cursor := crHourglass;
|
||||
OpenRegistry(session);
|
||||
MainReg.WriteInteger(REGNAME_NETTYPE, DEFAULT_NETTYPE);
|
||||
MainReg.WriteString(REGNAME_HOST, DEFAULT_HOST);
|
||||
MainReg.WriteString(REGNAME_USER, DEFAULT_USER);
|
||||
MainReg.WriteString(REGNAME_PASSWORD, encrypt(DEFAULT_PASSWORD));
|
||||
MainReg.WriteString(REGNAME_PORT, inttostr(DEFAULT_PORT));
|
||||
MainReg.WriteString(REGNAME_TIMEOUT, inttostr(DEFAULT_TIMEOUT));
|
||||
MainReg.WriteBool(REGNAME_COMPRESSED, DEFAULT_COMPRESSED);
|
||||
MainReg.WriteString(REGNAME_ONLYDBS, '');
|
||||
MainReg.WriteBool(REGNAME_ONLYDBSSORTED, DEFAULT_ONLYDBSSORTED);
|
||||
|
||||
// show parameters:
|
||||
FillSessionCombo(Sender);
|
||||
comboSession.ItemIndex := comboSession.Items.IndexOf(session);
|
||||
comboSessionSelect(Sender);
|
||||
Screen.Cursor := crDefault;
|
||||
FSessionNames.Add(NewName);
|
||||
FSessionNames.Sort;
|
||||
NewIdx := FSessionNames.IndexOf(NewName);
|
||||
// Select it
|
||||
RefreshSessionList(False);
|
||||
SelectNode(ListSessions, NewIdx);
|
||||
FSessionAdded := True;
|
||||
ListSessions.EditNode(ListSessions.FocusedNode, ListSessions.FocusedColumn);
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.btnDeleteClick(Sender: TObject);
|
||||
var
|
||||
SessionKey: String;
|
||||
begin
|
||||
if MessageDlg('Delete session "' + comboSession.Text + '" ?', mtConfirmation, [mbYes, mbCancel], 0) = mrYes then
|
||||
if MessageDlg('Delete session "' + SelectedSession + '" ?', mtConfirmation, [mbYes, mbCancel], 0) = mrYes then
|
||||
begin
|
||||
if not MainReg.DeleteKey(REGPATH + REGKEY_SESSIONS + comboSession.Text) then
|
||||
MessageDlg('Error while deleting session from Registry!', mtError, [mbOK], 0);
|
||||
FillSessionCombo(Sender);
|
||||
comboSessionSelect(Sender);
|
||||
SessionKey := REGPATH + REGKEY_SESSIONS + SelectedSession;
|
||||
if MainReg.KeyExists(SessionKey) then
|
||||
MainReg.DeleteKey(SessionKey);
|
||||
FSessionNames.Delete(FSessionNames.IndexOf(SelectedSession));
|
||||
RefreshSessionList(False);
|
||||
if (not Assigned(ListSessions.FocusedNode)) and (ListSessions.RootNodeCount > 0) then
|
||||
SelectNode(ListSessions, ListSessions.RootNodeCount-1);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.comboSessionSelect(Sender: TObject);
|
||||
function Tconnform.SelectedSession: String;
|
||||
begin
|
||||
Result := FSessionNames[ListSessions.FocusedNode.Index];
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.RefreshSessionList(RefetchRegistry: Boolean);
|
||||
begin
|
||||
// Refresh list of session names
|
||||
if RefetchRegistry then begin
|
||||
MainReg.OpenKey(REGPATH + REGKEY_SESSIONS, True);
|
||||
MainReg.GetKeyNames(FSessionNames);
|
||||
end;
|
||||
ListSessions.RootNodeCount := FSessionNames.Count;
|
||||
ListSessions.Repaint;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.ListSessionsGetImageIndex(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
|
||||
var Ghosted: Boolean; var ImageIndex: Integer);
|
||||
begin
|
||||
// A new session gets an additional plus symbol, editing gets a pencil
|
||||
ImageIndex := 36;
|
||||
if Node = Sender.FocusedNode then begin
|
||||
if FSessionAdded then ImageIndex := 72
|
||||
else if FSessionModified then ImageIndex := 135;
|
||||
end
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.ListSessionsGetText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
|
||||
var CellText: WideString);
|
||||
begin
|
||||
// Display session name cell
|
||||
CellText := FSessionNames[Node.Index];
|
||||
if (FSessionModified or FSessionAdded) and (Node = Sender.FocusedNode) and (not Sender.IsEditing) then
|
||||
CellText := CellText + ' *';
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.ListSessionsFocusChanged(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex);
|
||||
var
|
||||
Session: String;
|
||||
SessionSelected: Boolean;
|
||||
SessionFocused, SessionExists: Boolean;
|
||||
LastConnect, Created, DummyDate: TDateTime;
|
||||
begin
|
||||
// select one connection!
|
||||
Screen.Cursor := crHourglass;
|
||||
OpenRegistry;
|
||||
Session := comboSession.Text;
|
||||
SessionSelected := (Session <> '') and MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + Session);
|
||||
if SessionSelected then begin
|
||||
case GetRegValue(REGNAME_NETTYPE, DEFAULT_NETTYPE, Session) of
|
||||
SessionFocused := Assigned(Node);
|
||||
SessionExists := SessionFocused;
|
||||
if SessionFocused then begin
|
||||
SessionExists := MainReg.KeyExists(REGPATH + REGKEY_SESSIONS + SelectedSession);
|
||||
lblLastConnectRight.Caption := 'unknown or never';
|
||||
lblLastConnectRight.Hint := '';
|
||||
lblLastConnectRight.Enabled := False;
|
||||
lblCreatedRight.Caption := 'unknown';
|
||||
lblCreatedRight.Hint := lblLastConnectRight.Hint;
|
||||
lblCreatedRight.Enabled := lblLastConnectRight.Enabled;
|
||||
|
||||
if SessionExists then begin
|
||||
OpenRegistry(SelectedSession);
|
||||
FOrgNetType := GetRegValue(REGNAME_NETTYPE, DEFAULT_NETTYPE, SelectedSession);
|
||||
FOrgHost := GetRegValue(REGNAME_HOST, '', SelectedSession);
|
||||
FOrgUser := GetRegValue(REGNAME_USER, '', SelectedSession);
|
||||
FOrgPassword := decrypt(GetRegValue(REGNAME_PASSWORD, '', SelectedSession));
|
||||
FOrgPort := StrToIntDef(GetRegValue(REGNAME_PORT, '', SelectedSession), DEFAULT_PORT);
|
||||
FOrgCompressed := GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, SelectedSession);
|
||||
FOrgDatabases := Utf8Decode(GetRegValue(REGNAME_ONLYDBS, '', SelectedSession));
|
||||
DummyDate := StrToDateTime('2000-01-01');
|
||||
LastConnect := StrToDateTimeDef(GetRegValue(REGNAME_LASTCONNECT, '', SelectedSession), DummyDate);
|
||||
if LastConnect <> DummyDate then begin
|
||||
lblLastConnectRight.Hint := DateTimeToStr(LastConnect);
|
||||
lblLastConnectRight.Caption := DateBackFriendlyCaption(LastConnect);
|
||||
lblLastConnectRight.Enabled := True;
|
||||
end;
|
||||
Created := StrToDateTimeDef(GetRegValue(REGNAME_SESSIONCREATED, '', SelectedSession), DummyDate);
|
||||
if Created <> DummyDate then begin
|
||||
lblCreatedRight.Hint := DateTimeToStr(Created);
|
||||
lblCreatedRight.Caption := DateBackFriendlyCaption(Created);
|
||||
lblCreatedRight.Enabled := True;
|
||||
end;
|
||||
|
||||
end else begin
|
||||
// Editing a new session, not saved yet
|
||||
FOrgNetType := NETTYPE_TCPIP;
|
||||
FOrgHost := DEFAULT_HOST;
|
||||
FOrgUser := DEFAULT_USER;
|
||||
FOrgPassword := '';
|
||||
FOrgPort := DEFAULT_PORT;
|
||||
FOrgCompressed := DEFAULT_COMPRESSED;
|
||||
FOrgDatabases := '';
|
||||
end;
|
||||
|
||||
case FOrgNetType of
|
||||
NETTYPE_NAMEDPIPE: radioTypeNamedPipe.Checked := True;
|
||||
else radioTypeTCPIP.Checked := True;
|
||||
end;
|
||||
editHost.Text := GetRegValue(REGNAME_HOST, '', Session);
|
||||
editUsername.Text := GetRegValue(REGNAME_USER, '', Session);
|
||||
editPassword.Text := decrypt(GetRegValue(REGNAME_PASSWORD, '', Session));
|
||||
editPort.Text := GetRegValue(REGNAME_PORT, '', Session);
|
||||
editTimeout.Text := GetRegValue(REGNAME_TIMEOUT, '', Session);
|
||||
chkCompressed.Checked := GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, Session);
|
||||
editOnlyDBs.Text := Utf8Decode(GetRegValue(REGNAME_ONLYDBS, '', Session));
|
||||
chkSorted.Checked := GetRegValue(REGNAME_ONLYDBSSORTED, DEFAULT_ONLYDBSSORTED, Session);
|
||||
end else begin
|
||||
radioTypeTCPIP.Checked := True;
|
||||
editHost.Text := '';
|
||||
editUsername.Text := '';
|
||||
editPassword.Text := '';
|
||||
editPort.Text := '';
|
||||
editTimeout.Text := '';
|
||||
chkCompressed.Checked := False;
|
||||
editOnlyDBs.Text := '';
|
||||
chkSorted.Checked := False;
|
||||
radioNetTypeClick(Sender);
|
||||
editHost.Text := FOrgHost;
|
||||
editUsername.Text := FOrgUser;
|
||||
editPassword.Text := FOrgPassword;
|
||||
updownPort.Position := FOrgPort;
|
||||
chkCompressed.Checked := FOrgCompressed;
|
||||
memoDatabases.Text := FOrgDatabases;
|
||||
end;
|
||||
|
||||
btnConnect.Enabled := SessionSelected;
|
||||
btnSave.Enabled := SessionSelected;
|
||||
btnSaveAndConnect.Enabled := SessionSelected;
|
||||
btnDelete.Enabled := SessionSelected;
|
||||
btnEditDesc.Enabled := SessionSelected;
|
||||
radioTypeTCPIP.Enabled := SessionSelected;
|
||||
radioTypeNamedPipe.Enabled := SessionSelected;
|
||||
editHost.Enabled := SessionSelected;
|
||||
editUsername.Enabled := SessionSelected;
|
||||
editPassword.Enabled := SessionSelected;
|
||||
editPort.Enabled := SessionSelected;
|
||||
editTimeout.Enabled := SessionSelected;
|
||||
editOnlyDBs.Enabled := SessionSelected;
|
||||
chkCompressed.Enabled := SessionSelected;
|
||||
chkSorted.Enabled := SessionSelected;
|
||||
lblHost.Enabled := SessionSelected;
|
||||
lblUsername.Enabled := SessionSelected;
|
||||
lblPassword.Enabled := SessionSelected;
|
||||
lblPort.Enabled := SessionSelected;
|
||||
lblTimeout.Enabled := SessionSelected;
|
||||
lblSession.Enabled := SessionSelected;
|
||||
lblSeconds.Enabled := SessionSelected;
|
||||
lblOnlyDBs.Enabled := SessionSelected;
|
||||
|
||||
radioNetTypeClick(Sender);
|
||||
grpDetails.Visible := SessionFocused;
|
||||
btnOpen.Enabled := SessionFocused;
|
||||
btnNew.Enabled := SessionExists;
|
||||
btnSave.Enabled := not SessionExists;
|
||||
btnDelete.Enabled := SessionFocused;
|
||||
FSessionModified := False;
|
||||
FSessionAdded := False;
|
||||
ListSessions.Repaint;
|
||||
|
||||
Screen.Cursor := crDefault;
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.Modified(Sender: TObject);
|
||||
procedure Tconnform.ListSessionsFocusChanging(Sender: TBaseVirtualTree; OldNode,
|
||||
NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex;
|
||||
var Allowed: Boolean);
|
||||
begin
|
||||
btnSave.Enabled := true;
|
||||
btnSaveAndConnect.Enabled := true;
|
||||
chkSorted.Enabled := editOnlyDBs.Text <> '';
|
||||
FinalizeModifications(Allowed);
|
||||
end;
|
||||
|
||||
|
||||
{ rename session }
|
||||
procedure Tconnform.ButtonEditDescClick(Sender: TObject);
|
||||
procedure Tconnform.ListSessionsNewText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; NewText: WideString);
|
||||
var
|
||||
newdesc, olddesc : String;
|
||||
idx : Integer;
|
||||
SessionKey: String;
|
||||
begin
|
||||
olddesc := comboSession.Text;
|
||||
newdesc := olddesc;
|
||||
if not InputQuery('Rename session ...', 'Rename session:', newdesc) then
|
||||
exit;
|
||||
if newdesc = olddesc then
|
||||
exit;
|
||||
if comboSession.Items.IndexOf(newdesc) > -1 then begin
|
||||
MessageDLG('Session "'+newdesc+'" already exists!', mtError, [mbCancel], 0);
|
||||
exit;
|
||||
// Rename session
|
||||
OpenRegistry;
|
||||
if MainReg.KeyExists(REGKEY_SESSIONS + NewText) then begin
|
||||
MessageDLG('Session "'+NewText+'" already exists!', mtError, [mbCancel], 0);
|
||||
NewText := SelectedSession;
|
||||
end else begin
|
||||
SessionKey := REGPATH + REGKEY_SESSIONS + SelectedSession;
|
||||
if MainReg.KeyExists(SessionKey) then
|
||||
MainReg.MoveKey(SessionKey, REGPATH + REGKEY_SESSIONS + NewText, true);
|
||||
FSessionNames[FSessionNames.IndexOf(SelectedSession)] := NewText;
|
||||
RefreshSessionList(False);
|
||||
end;
|
||||
end;
|
||||
|
||||
idx := comboSession.ItemIndex;
|
||||
try
|
||||
MainReg.MoveKey(REGPATH + REGKEY_SESSIONS + olddesc, REGPATH + REGKEY_SESSIONS + newdesc, true);
|
||||
comboSession.Items[comboSession.ItemIndex] := newdesc;
|
||||
comboSession.ItemIndex := idx;
|
||||
comboSessionSelect(Sender);
|
||||
except
|
||||
MessageDLG('Error on renaming.', mtError, [mbCancel], 0);
|
||||
|
||||
procedure Tconnform.Modification(Sender: TObject);
|
||||
var
|
||||
NetType: Byte;
|
||||
begin
|
||||
// Some modification -
|
||||
if FLoaded then begin
|
||||
if radioTypeTCPIP.Checked then NetType := NETTYPE_TCPIP
|
||||
else NetType := NETTYPE_NAMEDPIPE;
|
||||
FSessionModified := (FOrgHost <> editHost.Text) or (FOrgUser <> editUsername.Text)
|
||||
or (FOrgPassword <> editPassword.Text) or (FOrgPort <> updownPort.Position)
|
||||
or (FOrgCompressed <> chkCompressed.Checked) or (FOrgDatabases <> memoDatabases.Text)
|
||||
or (FOrgNetType <> NetType);
|
||||
ListSessions.Repaint;
|
||||
btnSave.Enabled := FSessionModified or FSessionAdded;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
@ -379,11 +440,32 @@ procedure Tconnform.radioNetTypeClick(Sender: TObject);
|
||||
begin
|
||||
// Toggle between TCP/IP and named pipes mode
|
||||
if radioTypeTCPIP.Checked then
|
||||
lblHost.Caption := 'Hostname / IP:'
|
||||
lblHost.Caption := '&Hostname / IP:'
|
||||
else
|
||||
lblHost.Caption := 'Socket name:';
|
||||
editPort.Enabled := radioTypeTCPIP.Checked;
|
||||
lblPort.Enabled := editPort.Enabled;
|
||||
updownPort.Enabled := editPort.Enabled;
|
||||
Modification(Sender);
|
||||
end;
|
||||
|
||||
|
||||
procedure Tconnform.FinalizeModifications(var CanProceed: Boolean);
|
||||
begin
|
||||
if FSessionModified or FSessionAdded then begin
|
||||
case MessageDlg('Save settings for "'+SelectedSession+'"?', mtConfirmation, [mbYes, mbNo, mbCancel], 0) of
|
||||
mrYes: begin
|
||||
btnSave.OnClick(Self);
|
||||
CanProceed := True;
|
||||
end;
|
||||
mrNo: begin
|
||||
RefreshSessionList(True);
|
||||
CanProceed := True;
|
||||
end;
|
||||
mrCancel: CanProceed := False;
|
||||
end;
|
||||
end else
|
||||
CanProceed := True;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@ interface
|
||||
uses Classes, SysUtils, Graphics, db, clipbrd, dialogs,
|
||||
forms, controls, ShellApi, checklst, windows, ZDataset, ZAbstractDataset,
|
||||
shlobj, ActiveX, WideStrUtils, VirtualTrees, SynRegExpr, Messages, WideStrings,
|
||||
TntCheckLst, Registry, SynEditHighlighter, mysql_structures;
|
||||
TntCheckLst, Registry, SynEditHighlighter, mysql_structures, DateUtils;
|
||||
|
||||
type
|
||||
|
||||
@ -181,6 +181,8 @@ type
|
||||
function CompareNumbers(List: TStringList; Index1, Index2: Integer): Integer;
|
||||
function ListIndexByRegExpr(List: TWideStrings; Expression: WideString): Integer;
|
||||
procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter);
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil);
|
||||
function DateBackFriendlyCaption(d: TDateTime): String;
|
||||
var
|
||||
MainReg : TRegistry;
|
||||
|
||||
@ -2973,6 +2975,46 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil);
|
||||
var
|
||||
Node: PVirtualNode;
|
||||
begin
|
||||
// Helper to focus and highlight a node by its index
|
||||
if Assigned(ParentNode) then
|
||||
Node := VT.GetFirstChild(ParentNode)
|
||||
else
|
||||
Node := VT.GetFirst;
|
||||
while Assigned(Node) do begin
|
||||
if Node.Index = idx then begin
|
||||
VT.FocusedNode := Node;
|
||||
VT.Selected[Node] := True;
|
||||
end else
|
||||
VT.Selected[Node] := False;
|
||||
Node := VT.GetNextSibling(Node);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function DateBackFriendlyCaption(d: TDateTime): String;
|
||||
var
|
||||
MonthsAgo, DaysAgo, HoursAgo, MinutesAgo: Int64;
|
||||
begin
|
||||
MonthsAgo := MonthsBetween(Now, d);
|
||||
DaysAgo := DaysBetween(Now, d);
|
||||
HoursAgo := HoursBetween(Now, d);
|
||||
MinutesAgo := MinutesBetween(Now, d);
|
||||
if MonthsAgo = 1 then Result := FormatNumber(MonthsAgo)+' month ago'
|
||||
else if MonthsAgo > 1 then Result := FormatNumber(MonthsAgo)+' months ago'
|
||||
else if DaysAgo = 1 then Result := FormatNumber(DaysAgo)+' day ago'
|
||||
else if DaysAgo > 1 then Result := FormatNumber(DaysAgo)+' days ago'
|
||||
else if HoursAgo = 1 then Result := FormatNumber(HoursAgo)+' hour ago'
|
||||
else if HoursAgo > 1 then Result := FormatNumber(HoursAgo)+' hours ago'
|
||||
else if MinutesAgo = 1 then Result := FormatNumber(MinutesAgo)+' minute ago'
|
||||
else if MinutesAgo > 0 then Result := FormatNumber(MinutesAgo)+' minutes ago'
|
||||
else Result := 'less than a minute ago';
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
@ -5888,6 +5888,36 @@ object MainForm: TMainForm
|
||||
260000000049454E44AE426082}
|
||||
Name = 'PngImage134'
|
||||
Background = clWindow
|
||||
end
|
||||
item
|
||||
PngImage.Data = {
|
||||
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
|
||||
610000001974455874536F6674776172650041646F626520496D616765526561
|
||||
647971C9653C000002B84944415478DAA5935F4853511CC7BFF3CF867FB7E91C
|
||||
2B6BB615A6D6126E20231A514249252B684118444660BD2AF42C41E04B3E0409
|
||||
B9CCF6D2DE0CC2502631436F66C3B69452B026EAB2A993B95DDDDDDDEE4EE7DE
|
||||
4A28AD970E1C0EF79CF3FD7C7FBFDFF95D052104FF33147F022626269EA4D3E9
|
||||
AB8220E4D015A9544A9EF45B5ADD0E87E3CA8E804020A0A602A746A3B9A452E5
|
||||
234945C864209FD23B5AAD0603032FD1D4D4A4D806F0FBFD0D9258A7D3951714
|
||||
14203817A26E69AA27C8900C051118769561746418CDCDCDDB013E9F8F188D46
|
||||
7983E793985F0C6332E0A380CCD63C7DE62C86BD43686969D90E605996D4D4D4
|
||||
20168B41CA7B31B422454D8D4510EA2E5240F96E03A646BA509BFF15D985166C
|
||||
AC0E43C187AEC900AFD74B2C160B388EA300110B8BCB08F8C7A9B328BB8BA288
|
||||
0B278B511C0F22AFCC06B5894134C8627AD01996011E8F87300C83783C4EAB9D
|
||||
92239072273F6B50248EA3CAB881C262066BB33350EBF64359A4C7A7572E5E06
|
||||
F4F7F713ABD52AA72001A41A4862E94CCC1B82B58440636E4072C98D444481E5
|
||||
E94DA47821C227B86332A0AFAF8FD86C3619C0F30216423F0079E9008E547C83
|
||||
FA801D7CA80B594ADA175C0522AFD9F01A97D3C0B40EF96580DBED26F5F5F572
|
||||
0A9B095EAE0189B0602AD7A13F7C918A1F222B370D216EC28AF74D5C4C70A72A
|
||||
DBC67D5BAFE072B988DD6E47341AA5517098FFF002A6D208AA4E3442083F8522
|
||||
5B00BFBE074BDE77B4F29CE960DBD8DC6FCFD8DDDDFDD66030D499CD664467BD
|
||||
D0E6869056E8515A3A0AAD5E49C57BB13AF6118FA774E878D0A3D8B1953B3B3B
|
||||
CFD15E6FDF47068F5EBEDD839967AD08CDB150196B21C652309DBF87F6FB8FE0
|
||||
743A7706FC1A776F1E4ADFB9712B1B5922FC9EE7F81C0CE2BDF238224995D40F
|
||||
D3BDBDBDD5FF04386C2509C6ACCFA9AB3681E426D9C4F2CAF5C68EC92F7FFB9D
|
||||
BF036CF1AC08344E5E1D0000000049454E44AE426082}
|
||||
Name = 'PngImage135'
|
||||
Background = clWindow
|
||||
end>
|
||||
PngOptions = [pngBlendOnDisabled, pngGrayscaleOnDisabled]
|
||||
Left = 104
|
||||
|
@ -23,7 +23,7 @@ uses
|
||||
TntStdCtrls, Tabs, SynUnicode, mysqlconn, EditVar, helpers, queryprogress,
|
||||
mysqlquery, createdatabase, table_editor, SynRegExpr,
|
||||
WideStrUtils, ZDbcLogging, ExtActns, CommCtrl, routine_editor, options,
|
||||
Contnrs, PngSpeedButton;
|
||||
Contnrs, PngSpeedButton, connections;
|
||||
|
||||
const
|
||||
// The InnoDB folks are raging over the lack of count(*) support
|
||||
@ -764,6 +764,7 @@ type
|
||||
SQLHelpForm: TfrmSQLhelp;
|
||||
RoutineEditor: TfrmRoutineEditor;
|
||||
OptionsForm: Toptionsform;
|
||||
SessionManager: TConnForm;
|
||||
DatabasesWanted,
|
||||
Databases : Widestrings.TWideStringList;
|
||||
TemporaryDatabase : WideString;
|
||||
@ -815,7 +816,7 @@ type
|
||||
procedure FillPopupQueryLoad;
|
||||
procedure PopupQueryLoadRemoveAbsentFiles( sender: TObject );
|
||||
procedure SessionConnect(Sender: TObject);
|
||||
function InitConnection(parNetType: Integer; parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases: WideString): Boolean;
|
||||
function InitConnection(parNetType: Integer; parHost, parPort, parUser, parPass, parDatabase, parCompress: WideString): Boolean;
|
||||
//procedure HandleQueryNotification(ASender : TMysqlQuery; AEvent : Integer);
|
||||
|
||||
function ExecUpdateQuery(sql: WideString; HandleErrors: Boolean = false; DisplayErrors: Boolean = false): Int64;
|
||||
@ -918,7 +919,6 @@ implementation
|
||||
|
||||
uses
|
||||
About,
|
||||
connections,
|
||||
exportsql,
|
||||
loaddata,
|
||||
printlist,
|
||||
@ -1433,7 +1433,7 @@ var
|
||||
curParam, parNetType: Byte;
|
||||
sValue,
|
||||
parHost, parPort, parUser, parPass, parDatabase,
|
||||
parTimeout, parCompress, parDescription : String;
|
||||
parCompress, parDescription : String;
|
||||
LastUpdatecheck, LastStatsCall, LastConnect: TDateTime;
|
||||
UpdatecheckInterval, i: Integer;
|
||||
DefaultLastrunDate, LastSession, StatsURL: String;
|
||||
@ -1530,8 +1530,6 @@ begin
|
||||
parNetType := StrToIntDef(sValue, NETTYPE_TCPIP)
|
||||
else if GetParamValue('C', 'compress', curParam, sValue) then
|
||||
parCompress := sValue
|
||||
else if GetParamValue('M', 'timeout', curParam, sValue) then
|
||||
parTimeout := sValue
|
||||
else if GetParamValue('u', 'user', curParam, sValue) then
|
||||
parUser := sValue
|
||||
else if GetParamValue('p', 'password', curParam, sValue) then
|
||||
@ -1550,7 +1548,6 @@ begin
|
||||
parUser := GetRegValue(REGNAME_USER, DEFAULT_USER, parDescription);
|
||||
parPass := decrypt(GetRegValue(REGNAME_PASSWORD, DEFAULT_PASSWORD, parDescription));
|
||||
parPort := GetRegValue(REGNAME_PORT, IntToStr(DEFAULT_PORT), parDescription);
|
||||
parTimeout := GetRegValue(REGNAME_TIMEOUT, IntToStr(DEFAULT_TIMEOUT), parDescription);
|
||||
parCompress := IntToStr(Integer(GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, parDescription)));
|
||||
parDatabase := GetRegValue(REGNAME_ONLYDBS, '', parDescription);
|
||||
end;
|
||||
@ -1558,7 +1555,7 @@ begin
|
||||
// Minimal parameter for command line mode is hostname
|
||||
CommandLineMode := parHost <> '';
|
||||
if CommandLineMode then begin
|
||||
Connected := InitConnection(parNetType, parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, IntToStr(Integer(DEFAULT_ONLYDBSSORTED)));
|
||||
Connected := InitConnection(parNetType, parHost, parPort, parUser, parPass, parDatabase, parCompress);
|
||||
if Connected then begin
|
||||
SessionName := parDescription;
|
||||
if SessionName = '' then
|
||||
@ -1578,9 +1575,7 @@ begin
|
||||
GetRegValue(REGNAME_USER, '', LastSession),
|
||||
decrypt(GetRegValue(REGNAME_PASSWORD, '', LastSession)),
|
||||
Utf8Decode(GetRegValue(REGNAME_ONLYDBS, '', LastSession)),
|
||||
GetRegValue(REGNAME_TIMEOUT, '', LastSession),
|
||||
IntToStr(Integer(GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, LastSession))),
|
||||
IntToStr(Integer(GetRegValue(REGNAME_ONLYDBSSORTED, DEFAULT_ONLYDBSSORTED, LastSession)))
|
||||
IntToStr(Integer(GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, LastSession)))
|
||||
);
|
||||
if Connected then
|
||||
SessionName := LastSession;
|
||||
@ -1609,13 +1604,11 @@ end;
|
||||
|
||||
|
||||
procedure TMainForm.actSessionManagerExecute(Sender: TObject);
|
||||
var
|
||||
ConnForm: TConnForm;
|
||||
begin
|
||||
ConnForm := TConnForm.Create(Self);
|
||||
if ConnForm.ShowModal <> mrCancel then
|
||||
if not Assigned(SessionManager) then
|
||||
SessionManager := TConnForm.Create(Self);
|
||||
if SessionManager.ShowModal <> mrCancel then
|
||||
DoAfterConnect;
|
||||
FreeAndNil(ConnForm);
|
||||
end;
|
||||
|
||||
|
||||
@ -1663,7 +1656,6 @@ begin
|
||||
Mainreg.WriteString(REGNAME_LASTCONNECT, DateTimeToStr(Now));
|
||||
|
||||
DatabasesWanted := explode(';', FConn.DatabaseList);
|
||||
if FConn.DatabaseListSort then
|
||||
DatabasesWanted.Sort;
|
||||
|
||||
DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, SessionName);
|
||||
@ -2520,7 +2512,7 @@ procedure TMainForm.SessionConnect(Sender: TObject);
|
||||
var
|
||||
Session: String;
|
||||
parNetType: Integer;
|
||||
parHost, parPort, parUser, parPass, parTimeout, parCompress, parDatabase, parSortDatabases: WideString;
|
||||
parHost, parPort, parUser, parPass, parCompress, parDatabase: WideString;
|
||||
begin
|
||||
Session := (Sender as TMenuItem).Caption;
|
||||
parNetType := GetRegValue(REGNAME_NETTYPE, DEFAULT_NETTYPE, Session);
|
||||
@ -2528,11 +2520,9 @@ begin
|
||||
parUser := GetRegValue(REGNAME_USER, '', Session);
|
||||
parPass := decrypt(GetRegValue(REGNAME_PASSWORD, '', Session));
|
||||
parPort := GetRegValue(REGNAME_PORT, '', Session);
|
||||
parTimeout := GetRegValue(REGNAME_TIMEOUT, '', Session);
|
||||
parCompress := IntToStr(Integer(GetRegValue(REGNAME_COMPRESSED, DEFAULT_COMPRESSED, Session)));
|
||||
parDatabase := Utf8Decode(GetRegValue(REGNAME_ONLYDBS, '', Session));
|
||||
parSortDatabases := IntToStr(Integer(GetRegValue(REGNAME_ONLYDBSSORTED, DEFAULT_ONLYDBSSORTED, Session)));
|
||||
if InitConnection(parNetType, parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases) then begin
|
||||
if InitConnection(parNetType, parHost, parPort, parUser, parPass, parDatabase, parCompress) then begin
|
||||
SessionName := Session;
|
||||
DoAfterConnect;
|
||||
end;
|
||||
@ -2543,7 +2533,7 @@ end;
|
||||
Receive connection parameters and create the mdi-window
|
||||
Paremeters are either sent by connection-form or by commandline.
|
||||
}
|
||||
function TMainform.InitConnection(parNetType: Integer; parHost, parPort, parUser, parPass, parDatabase, parTimeout, parCompress, parSortDatabases: WideString): Boolean;
|
||||
function TMainform.InitConnection(parNetType: Integer; parHost, parPort, parUser, parPass, parDatabase, parCompress: WideString): Boolean;
|
||||
var
|
||||
MysqlConnection: TMysqlConn;
|
||||
Profile: TOpenConnProf;
|
||||
@ -2562,12 +2552,10 @@ begin
|
||||
Profile.MysqlParams.PrpCompress := 'true'
|
||||
else
|
||||
Profile.MysqlParams.PrpCompress := 'false';
|
||||
Profile.MysqlParams.PrpTimeout := parTimeout;
|
||||
Profile.MysqlParams.PrpDbless := 'true';
|
||||
Profile.MysqlParams.PrpClientLocalFiles := 'true';
|
||||
Profile.MysqlParams.PrpClientInteractive := 'true';
|
||||
Profile.DatabaseList := parDatabase;
|
||||
Profile.DatabaseListSort := Boolean(StrToIntDef(parSortDatabases, 0));
|
||||
|
||||
MysqlConnection := TMysqlConn.Create(@Profile);
|
||||
|
||||
|
@ -66,7 +66,6 @@ begin
|
||||
FConn.Port := Port;
|
||||
|
||||
FConn.Properties.Values['compress'] := PrpCompress;
|
||||
FConn.Properties.Values['timeout'] := PrpTimeout;
|
||||
FConn.Properties.Values['dbless'] := PrpDbless;
|
||||
FConn.Properties.Values['CLIENT_LOCAL_FILES'] := PrpClientLocalFiles;
|
||||
FConn.Properties.Values['CLIENT_INTERACTIVE'] := PrpClientInteractive;
|
||||
|
@ -29,7 +29,6 @@ type
|
||||
Pass : String;
|
||||
Port : Integer;
|
||||
PrpCompress,
|
||||
PrpTimeout,
|
||||
PrpDbless,
|
||||
PrpClientLocalFiles,
|
||||
PrpClientInteractive : String;
|
||||
@ -42,7 +41,6 @@ type
|
||||
TOpenConnProf = record
|
||||
MysqlParams : TMysqlConnParams; // stuff that needs to be shipped over to the mysql driver.
|
||||
DatabaseList : WideString;
|
||||
DatabaseListSort : Boolean;
|
||||
MysqlConn : TZConnection;
|
||||
end;
|
||||
POpenConnProf = ^TOpenConnProf;
|
||||
|
@ -147,7 +147,6 @@ type
|
||||
procedure IndexesChange(Sender: TObject);
|
||||
procedure ValidateColumnControls;
|
||||
procedure ValidateIndexControls;
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil);
|
||||
procedure MoveFocusedColumn(NewIdx: Cardinal);
|
||||
procedure MoveFocusedIndexPart(NewIdx: Cardinal);
|
||||
procedure SetModified(Value: Boolean);
|
||||
@ -1227,25 +1226,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTableEditor.SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil);
|
||||
var Node: PVirtualNode;
|
||||
begin
|
||||
// Helper to focus and highlight a node by its index
|
||||
if Assigned(ParentNode) then
|
||||
Node := VT.GetFirstChild(ParentNode)
|
||||
else
|
||||
Node := VT.GetFirst;
|
||||
while Assigned(Node) do begin
|
||||
if Node.Index = idx then begin
|
||||
VT.FocusedNode := Node;
|
||||
VT.Selected[Node] := True;
|
||||
end else
|
||||
VT.Selected[Node] := False;
|
||||
Node := VT.GetNextSibling(Node);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTableEditor.MoveFocusedColumn(NewIdx: Cardinal);
|
||||
begin
|
||||
if listColumns.IsEditing then
|
||||
|
Reference in New Issue
Block a user