Skip to content
Permalink
Browse files

Issue #12: On "Host" tab, prefer visible filename over visible file path

  • Loading branch information
ansgarbecker committed Dec 25, 2019
1 parent ed89b54 commit 91f973caed299679256a2fcc9edeadfecd3718aa
Showing with 22 additions and 6 deletions.
  1. +9 −4 source/apphelpers.pas
  2. +7 −0 source/dbconnection.pas
  3. +6 −2 source/main.pas
@@ -271,7 +271,7 @@ TAppSettings = class(TObject)
function implodestr(seperator: String; a: TStrings) :String;
function Explode(Separator, Text: String) :TStringList;
procedure ExplodeQuotedList(Text: String; var List: TStringList);
function StrEllipsis(const S: String; MaxLen: Integer): String;
function StrEllipsis(const S: String; MaxLen: Integer; FromLeft: Boolean=True): String;
function encrypt(str: String): String;
function decrypt(str: String): String;
function HTMLSpecialChars(str: String): String;
@@ -456,13 +456,18 @@ function Explode(Separator, Text: String): TStringList;
@param integer Wished Length of string
@return string
}
function StrEllipsis(const S: String; MaxLen: Integer): String;
function StrEllipsis(const S: String; MaxLen: Integer; FromLeft: Boolean=True): String;
begin
Result := S;
if Length(Result) <= MaxLen then
Exit;
SetLength(Result, MaxLen);
Result[MaxLen] := '…';
if FromLeft then begin
SetLength(Result, MaxLen);
Result[MaxLen] := '…';
end else begin
Result := Copy(Result, Length(Result)-MaxLen, Length(Result));
Result := '…' + Result;
end;
end;


@@ -239,6 +239,7 @@ TConnectionParameters = class(TObject)
function IsMySQL: Boolean;
function IsMSSQL: Boolean;
function IsPostgreSQL: Boolean;
function IsSQLite: Boolean;
function IsMariaDB: Boolean;
function IsPercona: Boolean;
function IsTokudb: Boolean;
@@ -1456,6 +1457,12 @@ function TConnectionParameters.IsPostgreSQL: Boolean;
end;


function TConnectionParameters.IsSQLite;
begin
Result := NetTypeGroup = ngSQLite;
end;


function TConnectionParameters.IsMariaDB: Boolean;
begin
Result := IsMySQL and (Pos('-mariadb', LowerCase(ServerVersion)) > 0);
@@ -8551,7 +8551,7 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
var
DBObj, PrevDBObj, ParentDBObj: PDBObject;
MainTabToActivate: TTabSheet;
DummyStr: String;
DummyStr, TabHostName: String;
begin
// Set wanted main tab and call SetMainTab later, when all lists have been invalidated
MainTabToActivate := nil;
@@ -8664,7 +8664,11 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
if FActiveDbObj.NodeType = lntGroup then
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
SetTabCaption(tabHost.PageIndex, _('Host')+': '+FActiveDbObj.Connection.Parameters.HostName);
if FActiveDbObj.Connection.Parameters.IsSQLite then // Prefer visible filename over visible left part of path
TabHostName := StrEllipsis(FActiveDbObj.Connection.Parameters.HostName, 60, False)
else
TabHostName := FActiveDbObj.Connection.Parameters.HostName;
SetTabCaption(tabHost.PageIndex, _('Host')+': '+TabHostName);
SetTabCaption(tabDatabase.PageIndex, _('Database')+': '+FActiveDbObj.Connection.Database);
ShowStatusMsg(FActiveDbObj.Connection.Parameters.NetTypeName(False)+' '+FActiveDbObj.Connection.ServerVersionStr, 3);
end else begin

0 comments on commit 91f973c

Please sign in to comment.
You can’t perform that action at this time.