From: Robert M. <mar...@us...> - 2003-01-15 18:02:30
|
Update of /cvsroot/jvcl/rm/source In directory sc8-pr-cvs1:/tmp/cvs-serv17593/source Modified Files: JvDBExcpt.pas JvDBFilter.pas JvDBIndex.pas JvDBLists.pas Log Message: cleaned Index: JvDBExcpt.pas =================================================================== RCS file: /cvsroot/jvcl/rm/source/JvDBExcpt.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JvDBExcpt.pas 9 Jan 2003 13:36:07 -0000 1.1 --- JvDBExcpt.pas 15 Jan 2003 18:02:28 -0000 1.2 *************** *** 13,21 **** The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. ! TJvBdeErrorDlg based on sample form ! DELPHI\DEMOS\DB\TOOLS\DBEXCEPT.PAS Last Modified: 2002-07-04 --- 13,21 ---- The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. ! TJvBdeErrorDlg based on sample form ! DELPHI\DEMOS\DB\TOOLS\DBEXCEPT.PAS Last Modified: 2002-07-04 *************** *** 31,45 **** unit JvDbExcpt; - - interface uses SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, ExtCtrls, DB, {$IFDEF COMPILER3_UP} DBTables, {$ENDIF} JvxCtrls, ! JvComponent; type ! TDBErrorEvent = procedure (Error: TDBError; var Msg: string) of object; TJvBdeErrorDlg = class(TForm) --- 31,46 ---- unit JvDbExcpt; interface uses SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, ! StdCtrls, ExtCtrls, DB, ! {$IFDEF COMPILER3_UP} ! DBTables, ! {$ENDIF} ! JvxCtrls, JvComponent; type ! TDBErrorEvent = procedure(Error: TDBError; var Msg: string) of object; TJvBdeErrorDlg = class(TForm) *************** *** 94,99 **** implementation ! uses {$IFDEF WIN32} Windows, BDE, {$ELSE} WinProcs, WinTypes, DbiErrs, ! JvStr16, {$ENDIF} Consts, JvxConst, JvVCLUtils; {$R *.DFM} --- 95,107 ---- implementation ! uses ! Consts, ! {$IFDEF WIN32} ! Windows, BDE, ! {$ELSE} ! WinProcs, WinTypes, DbiErrs, ! JvStr16, ! {$ENDIF} ! JvxConst, JvVCLUtils; {$R *.DFM} *************** *** 101,110 **** procedure DbErrorIntercept; begin ! if DbEngineErrorDlg <> nil then DbEngineErrorDlg.Free; DbEngineErrorDlg := TJvBdeErrorDlg.Create(Application); end; - { TJvBdeErrorDlg } - procedure TJvBdeErrorDlg.ShowException(Sender: TObject; E: Exception); begin --- 109,117 ---- procedure DbErrorIntercept; begin ! if DbEngineErrorDlg <> nil then ! DbEngineErrorDlg.Free; DbEngineErrorDlg := TJvBdeErrorDlg.Create(Application); end; procedure TJvBdeErrorDlg.ShowException(Sender: TObject; E: Exception); begin *************** *** 112,117 **** Application.NormalizeTopMosts; try ! if (E is EDbEngineError) and (DbException = nil) ! and not Application.Terminated then begin DbException := EDbEngineError(E); --- 119,124 ---- Application.NormalizeTopMosts; try ! if (E is EDbEngineError) and (DbException = nil) and ! not Application.Terminated then begin DbException := EDbEngineError(E); *************** *** 122,129 **** end; end ! else begin ! if Assigned(FPrevOnException) then FPrevOnException(Sender, E) ! else if NewStyleControls then Application.ShowException(E) ! else MessageDlg(E.Message + '.', mtError, [mbOk], 0); end; except --- 129,141 ---- end; end ! else ! begin ! if Assigned(FPrevOnException) then ! FPrevOnException(Sender, E) ! else ! if NewStyleControls then ! Application.ShowException(E) ! else ! MessageDlg(E.Message + '.', mtError, [mbOk], 0); end; except *************** *** 139,144 **** I: Integer; begin ! Back.Enabled := CurItem > 0; ! Next.Enabled := CurItem < DbException.ErrorCount - 1; BDEError := DbException.Errors[CurItem]; { Fill BDE error information } --- 151,156 ---- I: Integer; begin ! Back.Enabled := (CurItem > 0); ! Next.Enabled := (CurItem < DbException.ErrorCount - 1); BDEError := DbException.Errors[CurItem]; { Fill BDE error information } *************** *** 146,159 **** DbResult.Text := IntToStr(BDEError.ErrorCode); DbCatSub.Text := Format('[$%s] [$%s]', [IntToHex(BDEError.Category, 2), ! IntToHex(BDEError.SubCode, 2)]); { Fill native error information } NativeLabel.Enabled := BDEError.NativeError <> 0; if NativeLabel.Enabled then NativeResult.Text := IntToStr(BDEError.NativeError) ! else NativeResult.Clear; { The message text is common to both BDE and native errors } S := Trim(BDEError.Message); for I := 1 to Length(S) do ! if S[I] < ' ' then S[I] := ' '; {GetErrorMsg(BDEError, S);} DbMessageText.Text := Trim(S); --- 158,173 ---- DbResult.Text := IntToStr(BDEError.ErrorCode); DbCatSub.Text := Format('[$%s] [$%s]', [IntToHex(BDEError.Category, 2), ! IntToHex(BDEError.SubCode, 2)]); { Fill native error information } NativeLabel.Enabled := BDEError.NativeError <> 0; if NativeLabel.Enabled then NativeResult.Text := IntToStr(BDEError.NativeError) ! else ! NativeResult.Clear; { The message text is common to both BDE and native errors } S := Trim(BDEError.Message); for I := 1 to Length(S) do ! if S[I] < ' ' then ! S[I] := ' '; {GetErrorMsg(BDEError, S);} DbMessageText.Text := Trim(S); *************** *** 164,168 **** DisableAlign; try ! if Value then begin DetailsPanel.Height := DetailsHeight; ClientHeight := DetailsPanel.Height + BasicPanel.Height; --- 178,183 ---- DisableAlign; try ! if Value then ! begin DetailsPanel.Height := DetailsHeight; ClientHeight := DetailsPanel.Height + BasicPanel.Height; *************** *** 171,175 **** ShowError; end ! else begin ClientHeight := BasicPanel.Height; DetailsPanel.Height := 0; --- 186,191 ---- ShowError; end ! else ! begin ClientHeight := BasicPanel.Height; DetailsPanel.Height := 0; *************** *** 194,200 **** procedure TJvBdeErrorDlg.FormCreate(Sender: TObject); begin ! {$IFNDEF WIN32} BorderIcons := []; ! {$ENDIF} DetailsHeight := DetailsPanel.Height; Icon.Handle := LoadIcon(0, IDI_EXCLAMATION); --- 210,216 ---- procedure TJvBdeErrorDlg.FormCreate(Sender: TObject); begin ! {$IFNDEF WIN32} BorderIcons := []; ! {$ENDIF} DetailsHeight := DetailsPanel.Height; Icon.Handle := LoadIcon(0, IDI_EXCLAMATION); *************** *** 224,228 **** if DbException.HelpContext <> 0 then HelpContext := DbException.HelpContext ! else HelpContext := DbErrorHelpCtx; CurItem := 0; if (DbException.ErrorCount > 1) and --- 240,245 ---- if DbException.HelpContext <> 0 then HelpContext := DbException.HelpContext ! else ! HelpContext := DbErrorHelpCtx; CurItem := 0; if (DbException.ErrorCount > 1) and *************** *** 233,237 **** { Unknown username or password } ErrNo := 1 ! else ErrNo := 0; S := Trim(DbException.Errors[ErrNo].Message); GetErrorMsg(DbException.Errors[ErrNo], S); --- 250,255 ---- { Unknown username or password } ErrNo := 1 ! else ! ErrNo := 0; S := Trim(DbException.Errors[ErrNo].Message); GetErrorMsg(DbException.Errors[ErrNo], S); *************** *** 260,262 **** --- 278,282 ---- initialization DbEngineErrorDlg := nil; + end. + Index: JvDBFilter.pas =================================================================== RCS file: /cvsroot/jvcl/rm/source/JvDBFilter.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JvDBFilter.pas 9 Jan 2003 13:36:07 -0000 1.1 --- JvDBFilter.pas 15 Jan 2003 18:02:28 -0000 1.2 *************** *** 13,17 **** The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. --- 13,17 ---- The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. [...1442 lines suppressed...] WasActive: Boolean; begin ! if not FIgnoreDataEvents then ! begin WasActive := Active; DropFilters; ! if not (csDestroying in ComponentState) then ! begin RecreateExprFilter; RecreateFuncFilter; ! if WasActive then ! Activate; end; end; *************** *** 1608,1609 **** --- 1721,1723 ---- end. + Index: JvDBIndex.pas =================================================================== RCS file: /cvsroot/jvcl/rm/source/JvDBIndex.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JvDBIndex.pas 9 Jan 2003 13:36:07 -0000 1.1 --- JvDBIndex.pas 15 Jan 2003 18:02:28 -0000 1.2 *************** *** 13,17 **** The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. --- 13,17 ---- The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. *************** *** 30,53 **** interface - {$IFDEF WIN32} ! uses SysUtils, Windows, Messages, Classes, Controls, Forms, Graphics, Menus, StdCtrls, ExtCtrls, DB, DBTables; {$ELSE} ! uses SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Forms, Graphics, Menus, StdCtrls, ExtCtrls, DB, DBTables; {$ENDIF} type ! TIdxDisplayMode = (dmFieldLabels, dmFieldNames, dmIndexName); - { TJvDBIndexCombo } - TJvDBIndexCombo = class(TCustomComboBox) private FDataLink: TDataLink; FUpdate: Boolean; ! FNoIndexItem: String; FEnableNoIndex: Boolean; FChanging: Boolean; --- 30,52 ---- interface {$IFDEF WIN32} ! uses ! SysUtils, Windows, Messages, Classes, Controls, Forms, Graphics, Menus, StdCtrls, ExtCtrls, DB, DBTables; {$ELSE} ! uses ! SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Forms, Graphics, Menus, StdCtrls, ExtCtrls, DB, DBTables; {$ENDIF} type ! // (rom) needs Jv prefix TIdxDisplayMode = (dmFieldLabels, dmFieldNames, dmIndexName); TJvDBIndexCombo = class(TCustomComboBox) private FDataLink: TDataLink; FUpdate: Boolean; ! FNoIndexItem: string; FEnableNoIndex: Boolean; FChanging: Boolean; *************** *** 61,65 **** procedure SetDisplayMode(Value: TIdxDisplayMode); procedure ActiveChanged; ! procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED; protected procedure Loaded; override; --- 60,64 ---- procedure SetDisplayMode(Value: TIdxDisplayMode); procedure ActiveChanged; ! procedure CMEnabledChanged(var Msg: TMessage); message CM_ENABLEDCHANGED; protected procedure Loaded; override; *************** *** 73,77 **** destructor Destroy; override; published - { published properties } property DataSource: TDataSource read GetDataSource write SetDataSource; property NoIndexItem: string read GetNoIndexItem write SetNoIndexItem; --- 72,75 ---- *************** *** 85,89 **** property DropDownCount; property Font; ! {$IFDEF COMPILER4_UP} property Anchors; property BiDiMode; --- 83,87 ---- property DropDownCount; property Font; ! {$IFDEF COMPILER4_UP} property Anchors; property BiDiMode; *************** *** 91,101 **** property DragKind; property ParentBiDiMode; ! {$ENDIF} ! {$IFDEF WIN32} ! {$IFNDEF VER90} property ImeMode; property ImeName; ! {$ENDIF} ! {$ENDIF} property ItemHeight; property ParentCtl3D; --- 89,99 ---- property DragKind; property ParentBiDiMode; ! {$ENDIF} ! {$IFDEF WIN32} ! {$IFNDEF VER90} property ImeMode; property ImeName; ! {$ENDIF} ! {$ENDIF} property ItemHeight; property ParentCtl3D; *************** *** 119,140 **** property OnKeyPress; property OnKeyUp; ! {$IFDEF COMPILER5_UP} property OnContextPopup; ! {$ENDIF} ! {$IFDEF WIN32} property OnStartDrag; ! {$ENDIF} ! {$IFDEF COMPILER4_UP} property OnEndDock; property OnStartDock; ! {$ENDIF} end; implementation ! uses {$IFDEF WIN32} Bde, {$ELSE} DbiErrs, DbiTypes, DbiProcs, {$ENDIF} ! DBConsts, JvStrUtils, JvDBUtils, JvBdeUtils; ! ! { TJvKeyDataLink } type --- 117,142 ---- property OnKeyPress; property OnKeyUp; ! {$IFDEF COMPILER5_UP} property OnContextPopup; ! {$ENDIF} ! {$IFDEF WIN32} property OnStartDrag; ! {$ENDIF} ! {$IFDEF COMPILER4_UP} property OnEndDock; property OnStartDock; ! {$ENDIF} end; implementation ! uses ! {$IFDEF WIN32} ! Bde, ! {$ELSE} ! DbiErrs, DbiTypes, DbiProcs, ! {$ENDIF} ! DBConsts, ! JvStrUtils, JvDBUtils, JvBdeUtils; type *************** *** 165,174 **** procedure TJvKeyDataLink.ActiveChanged; begin ! if FCombo <> nil then FCombo.ActiveChanged; end; procedure TJvKeyDataLink.DataSetChanged; begin ! if FCombo <> nil then FCombo.ActiveChanged; end; --- 167,178 ---- procedure TJvKeyDataLink.ActiveChanged; begin ! if FCombo <> nil then ! FCombo.ActiveChanged; end; procedure TJvKeyDataLink.DataSetChanged; begin ! if FCombo <> nil then ! FCombo.ActiveChanged; end; *************** *** 178,183 **** end; - { TJvDBIndexCombo } - constructor TJvDBIndexCombo.Create(AOwner: TComponent); begin --- 182,185 ---- *************** *** 201,207 **** procedure TJvDBIndexCombo.SetNoIndexItem(const Value: string); begin ! if Value <> FNoIndexItem then begin FNoIndexItem := Value; ! if not (csLoading in ComponentState) then ActiveChanged; end; end; --- 203,211 ---- procedure TJvDBIndexCombo.SetNoIndexItem(const Value: string); begin ! if Value <> FNoIndexItem then ! begin FNoIndexItem := Value; ! if not (csLoading in ComponentState) then ! ActiveChanged; end; end; *************** *** 209,215 **** procedure TJvDBIndexCombo.SetEnableNoIndex(Value: Boolean); begin ! if FEnableNoIndex <> Value then begin FEnableNoIndex := Value; ! if not (csLoading in ComponentState) then ActiveChanged; end; end; --- 213,221 ---- procedure TJvDBIndexCombo.SetEnableNoIndex(Value: Boolean); begin ! if FEnableNoIndex <> Value then ! begin FEnableNoIndex := Value; ! if not (csLoading in ComponentState) then ! ActiveChanged; end; end; *************** *** 217,223 **** procedure TJvDBIndexCombo.SetDisplayMode(Value: TIdxDisplayMode); begin ! if (Value <> FDisplayMode) then begin FDisplayMode := Value; ! if not (csLoading in ComponentState) then UpdateList; end; end; --- 223,231 ---- procedure TJvDBIndexCombo.SetDisplayMode(Value: TIdxDisplayMode); begin ! if Value <> FDisplayMode then ! begin FDisplayMode := Value; ! if not (csLoading in ComponentState) then ! UpdateList; end; end; *************** *** 230,235 **** function TJvDBIndexCombo.GetDataSource: TDataSource; begin ! if FDataLink <> nil then Result := FDataLink.DataSource ! else Result := nil; end; --- 238,245 ---- function TJvDBIndexCombo.GetDataSource: TDataSource; begin ! if FDataLink <> nil then ! Result := FDataLink.DataSource ! else ! Result := nil; end; *************** *** 237,244 **** begin FDataLink.DataSource := Value; ! {$IFDEF WIN32} ! if Value <> nil then Value.FreeNotification(Self); ! {$ENDIF} ! if not (csLoading in ComponentState) then ActiveChanged; end; --- 247,256 ---- begin FDataLink.DataSource := Value; ! {$IFDEF WIN32} ! if Value <> nil then ! Value.FreeNotification(Self); ! {$ENDIF} ! if not (csLoading in ComponentState) then ! ActiveChanged; end; *************** *** 251,255 **** ItemIndex := -1; end ! else UpdateList; end; --- 263,268 ---- ItemIndex := -1; end ! else ! UpdateList; end; *************** *** 265,275 **** inherited Notification(AComponent, Operation); if (Operation = opRemove) and (FDataLink <> nil) and ! (AComponent = DataSource) then DataSource := nil; end; ! procedure TJvDBIndexCombo.CMEnabledChanged(var Message: TMessage); begin inherited; ! if not (csLoading in ComponentState) then ActiveChanged; end; --- 278,290 ---- inherited Notification(AComponent, Operation); if (Operation = opRemove) and (FDataLink <> nil) and ! (AComponent = DataSource) then ! DataSource := nil; end; ! procedure TJvDBIndexCombo.CMEnabledChanged(var Msg: TMessage); begin inherited; ! if not (csLoading in ComponentState) then ! ActiveChanged; end; *************** *** 277,285 **** begin Result := True; ! if ItemIndex >= 0 then begin ! if EnableNoIndex and (Items[ItemIndex] = NoIndexItem) then AName := '' ! else begin AName := TIndexDef(Items.Objects[ItemIndex]).Fields; ! if AName = '' then begin AName := TIndexDef(Items.Objects[ItemIndex]).Name; Result := False; --- 292,304 ---- begin Result := True; ! if ItemIndex >= 0 then ! begin ! if EnableNoIndex and (Items[ItemIndex] = NoIndexItem) then ! AName := '' ! else ! begin AName := TIndexDef(Items.Objects[ItemIndex]).Fields; ! if AName = '' then ! begin AName := TIndexDef(Items.Objects[ItemIndex]).Name; Result := False; *************** *** 287,291 **** end; end ! else AName := ''; end; --- 306,311 ---- end; end ! else ! AName := ''; end; *************** *** 297,311 **** begin List.Clear; ! if not FDataLink.Active then Exit; ! with FDataLink.DataSet as TTable do begin for I := 0 to IndexDefs.Count - 1 do with IndexDefs[I] do ! if not (ixExpression in Options) then begin ! if FDisplayMode = dmIndexName then AFld := Name ! else begin AFld := ''; Pos := 1; ! while Pos <= Length(Fields) do begin ! if AFld <> '' then AFld := AFld + '; '; case FDisplayMode of dmFieldLabels: --- 317,338 ---- begin List.Clear; ! if not FDataLink.Active then ! Exit; ! with FDataLink.DataSet as TTable do ! begin for I := 0 to IndexDefs.Count - 1 do with IndexDefs[I] do ! if not (ixExpression in Options) then ! begin ! if FDisplayMode = dmIndexName then ! AFld := Name ! else ! begin AFld := ''; Pos := 1; ! while Pos <= Length(Fields) do ! begin ! if AFld <> '' then ! AFld := AFld + '; '; case FDisplayMode of dmFieldLabels: *************** *** 316,324 **** end; end; ! if List.IndexOf(AFld) < 0 then List.AddObject(AFld, IndexDefs[I]); end; end; if EnableNoIndex then ! if List.IndexOf(NoIndexItem) < 0 then List.AddObject(NoIndexItem, nil); end; --- 343,353 ---- end; end; ! if List.IndexOf(AFld) < 0 then ! List.AddObject(AFld, IndexDefs[I]); end; end; if EnableNoIndex then ! if List.IndexOf(NoIndexItem) < 0 then ! List.AddObject(NoIndexItem, nil); end; *************** *** 333,346 **** begin ABookmark := nil; ! with FDataLink.DataSet as TTable do begin ! if Database.IsSQLBased then ABookmark := GetBookmark; try ! if GetIndexFieldName(AName) then begin IndexFieldNames := AName; if (AName = '') and (IndexDefs.Count > 0) then IndexName := ''; end ! else begin ! if AName = '' then IndexFieldNames := ''; IndexName := AName; end; --- 362,380 ---- begin ABookmark := nil; ! with FDataLink.DataSet as TTable do ! begin ! if Database.IsSQLBased then ! ABookmark := GetBookmark; try ! if GetIndexFieldName(AName) then ! begin IndexFieldNames := AName; if (AName = '') and (IndexDefs.Count > 0) then IndexName := ''; end ! else ! begin ! if AName = '' then ! IndexFieldNames := ''; IndexName := AName; end; *************** *** 348,352 **** SetToBookmark(TTable(Self.FDataLink.DataSet), ABookmark); finally ! if ABookmark <> nil then FreeBookmark(ABookmark); end; end; --- 382,387 ---- SetToBookmark(TTable(Self.FDataLink.DataSet), ABookmark); finally ! if ABookmark <> nil then ! FreeBookmark(ABookmark); end; end; *************** *** 365,373 **** IdxFields := ''; if Table.IndexFieldNames <> '' then ! for I := 0 to Table.IndexFieldCount - 1 do begin ! if IdxFields <> '' then IdxFields := IdxFields + ';'; IdxFields := IdxFields + Table.IndexFields[I].FieldName; end; ! for I := 0 to Items.Count - 1 do begin if (Items.Objects[I] <> nil) and (((IdxFields <> '') and --- 400,411 ---- IdxFields := ''; if Table.IndexFieldNames <> '' then ! for I := 0 to Table.IndexFieldCount - 1 do ! begin ! if IdxFields <> '' then ! IdxFields := IdxFields + ';'; IdxFields := IdxFields + Table.IndexFields[I].FieldName; end; ! for I := 0 to Items.Count - 1 do ! begin if (Items.Objects[I] <> nil) and (((IdxFields <> '') and *************** *** 387,407 **** begin if Enabled and FDataLink.Active then try ! Items.BeginUpdate; ! try ! if FDataLink.DataSet.InheritsFrom(TTable) then begin ! TTable(FDataLink.DataSet).IndexDefs.Update; ! FillIndexList(Items); ! ItemIndex := FindIndex(TTable(FDataLink.DataSet)); ! FChanging := True; ! end ! else Items.Clear; ! finally ! Items.EndUpdate; ! end; finally ! FChanging := False; end; end; end. --- 425,448 ---- begin if Enabled and FDataLink.Active then + try + Items.BeginUpdate; try ! if FDataLink.DataSet.InheritsFrom(TTable) then ! begin ! TTable(FDataLink.DataSet).IndexDefs.Update; ! FillIndexList(Items); ! ItemIndex := FindIndex(TTable(FDataLink.DataSet)); ! FChanging := True; ! end ! else ! Items.Clear; finally ! Items.EndUpdate; end; + finally + FChanging := False; + end; end; end. + Index: JvDBLists.pas =================================================================== RCS file: /cvsroot/jvcl/rm/source/JvDBLists.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JvDBLists.pas 9 Jan 2003 13:36:07 -0000 1.1 --- JvDBLists.pas 15 Jan 2003 18:02:28 -0000 1.2 *************** *** 13,17 **** The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. --- 13,17 ---- The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev ! Copyright (c) 2001,2002 SGB Software All Rights Reserved. *************** *** 28,46 **** unit JvDBLists; - interface ! uses SysUtils, Classes, DB, DBTables, JvDBUtils, JvBdeUtils, ! {$IFDEF WIN32} Windows, Bde; ! {$ELSE} WinTypes, WinProcs, DbiTypes, DbiProcs, DbiErrs; ! {$ENDIF} type ! ! { TJvBDEItems } ! ! TBDEItemType = (bdDatabases, bdDrivers, bdLangDrivers, bdUsers {$IFDEF WIN32}, bdRepositories {$ENDIF}); --- 28,43 ---- unit JvDBLists; interface ! uses ! SysUtils, Classes, DB, DBTables, JvDBUtils, JvBdeUtils, ! {$IFDEF WIN32} Windows, Bde; ! {$ELSE} WinTypes, WinProcs, DbiTypes, DbiProcs, DbiErrs; ! {$ENDIF} type ! TBDEItemType = (bdDatabases, bdDrivers, bdLangDrivers, bdUsers {$IFDEF WIN32}, bdRepositories {$ENDIF}); *************** *** 48,81 **** private FItemType: TBDEItemType; ! {$IFDEF WIN32} FSessionName: string; FSessionLink: TDatabase; function GetDBSession: TSession; procedure SetSessionName(const Value: string); ! {$ENDIF} procedure SetItemType(Value: TBDEItemType); protected ! {$IFDEF WIN32} ! function GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} ! Integer; override {$ENDIF}; ! procedure OpenCursor {$IFDEF COMPILER3_UP}(InfoQuery: Boolean){$ENDIF}; override; procedure CloseCursor; override; ! {$ENDIF} function CreateHandle: HDBICur; override; property ItemType: TBDEItemType read FItemType write SetItemType default bdDatabases; public ! {$IFDEF WIN32} ! {$IFDEF COMPILER3_UP} function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override; ! {$ENDIF} property DBSession: TSession read GetDBSession; ! {$IFNDEF COMPILER3_UP} property RecordCount: Longint read GetRecordCount; ! {$ENDIF} published property SessionName: string read FSessionName write SetSessionName; ! {$ENDIF WIN32} end; --- 45,77 ---- private FItemType: TBDEItemType; ! {$IFDEF WIN32} FSessionName: string; FSessionLink: TDatabase; function GetDBSession: TSession; procedure SetSessionName(const Value: string); ! {$ENDIF} procedure SetItemType(Value: TBDEItemType); protected ! {$IFDEF WIN32} ! function GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} Integer; override {$ENDIF}; ! procedure OpenCursor {$IFDEF COMPILER3_UP} (InfoQuery: Boolean) {$ENDIF}; override; procedure CloseCursor; override; ! {$ENDIF} function CreateHandle: HDBICur; override; property ItemType: TBDEItemType read FItemType write SetItemType default bdDatabases; public ! {$IFDEF WIN32} ! {$IFDEF COMPILER3_UP} function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override; ! {$ENDIF} property DBSession: TSession read GetDBSession; ! {$IFNDEF COMPILER3_UP} property RecordCount: Longint read GetRecordCount; ! {$ENDIF} published property SessionName: string read FSessionName write SetSessionName; ! {$ENDIF WIN32} end; *************** *** 85,107 **** end; - { TJvDBListDataSet } - TJvDBListDataSet = class(TDBDataSet) ! {$IFDEF WIN32} protected ! function GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} ! Integer; override {$ENDIF}; public ! {$IFDEF COMPILER3_UP} function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override; ! {$ELSE} property RecordCount: Longint read GetRecordCount; {$ENDIF} - {$ENDIF} end; - { TJvDatabaseItems } - TDBItemType = (dtTables, dtStoredProcs, dtFiles {$IFDEF WIN32}, dtFunctions {$ENDIF}); --- 81,98 ---- end; TJvDBListDataSet = class(TDBDataSet) ! {$IFDEF WIN32} protected ! function GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} Integer; override {$ENDIF}; public ! {$IFDEF COMPILER3_UP} function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; override; ! {$ELSE} property RecordCount: Longint read GetRecordCount; + {$ENDIF} {$ENDIF} end; TDBItemType = (dtTables, dtStoredProcs, dtFiles {$IFDEF WIN32}, dtFunctions {$ENDIF}); *************** *** 139,144 **** end; - { TJvTableItems } - TTabItemType = (dtFields, dtIndices, dtValChecks, dtRefInt, dtSecurity, dtFamily); --- 130,133 ---- *************** *** 168,173 **** end; - { TJvDatabaseDesc } - TJvDatabaseDesc = class(TObject) private --- 157,160 ---- *************** *** 178,183 **** end; - { TJvDriverDesc } - TJvDriverDesc = class(TObject) private --- 165,168 ---- *************** *** 194,198 **** type - TJvDatabaseList = class(TJvCustomBDEItems); --- 179,182 ---- *************** *** 228,232 **** implementation ! uses DBConsts, {$IFDEF COMPILER3_UP} BDEConst, {$ENDIF} JvxConst; { Utility routines } --- 212,221 ---- implementation ! uses ! DBConsts, ! {$IFDEF COMPILER3_UP} ! BDEConst, ! {$ENDIF} ! JvxConst; { Utility routines } *************** *** 234,242 **** function dsGetRecordCount(DataSet: TBDEDataSet): Longint; begin ! if DataSet.State = dsInactive then _DBError(SDataSetClosed); Check(DbiGetRecordCount(DataSet.Handle, Result)); end; {$IFDEF WIN32} type TJvSessionLink = class(TDatabase) --- 223,233 ---- function dsGetRecordCount(DataSet: TBDEDataSet): Longint; begin ! if DataSet.State = dsInactive then ! _DBError(SDataSetClosed); Check(DbiGetRecordCount(DataSet.Handle, Result)); end; {$IFDEF WIN32} + type TJvSessionLink = class(TDatabase) *************** *** 259,263 **** destructor TJvSessionLink.Destroy; begin ! if FList <> nil then begin FList.FSessionLink := nil; FList.Close; --- 250,255 ---- destructor TJvSessionLink.Destroy; begin ! if FList <> nil then ! begin FList.FSessionLink := nil; FList.Close; *************** *** 265,275 **** inherited Destroy; end; - {$ENDIF} ! { TJvCustomBDEItems } procedure TJvCustomBDEItems.SetItemType(Value: TBDEItemType); begin ! if ItemType <> Value then begin CheckInactive; FItemType := Value; --- 257,267 ---- inherited Destroy; end; ! {$ENDIF} procedure TJvCustomBDEItems.SetItemType(Value: TBDEItemType); begin ! if ItemType <> Value then ! begin CheckInactive; FItemType := Value; *************** *** 280,303 **** begin case FItemType of ! bdDatabases: Check(DbiOpenDatabaseList(Result)); ! bdDrivers: Check(DbiOpenDriverList(Result)); ! bdLangDrivers: Check(DbiOpenLdList(Result)); ! bdUsers: Check(DbiOpenUserList(Result)); ! {$IFDEF WIN32} ! bdRepositories: Check(DbiOpenRepositoryList(Result)); ! {$ENDIF} end; end; {$IFDEF WIN32} function TJvCustomBDEItems.GetDBSession: TSession; begin Result := Sessions.FindSession(SessionName); if Result = nil then ! {$IFDEF COMPILER3_UP} Result := DBTables.Session; ! {$ELSE} Result := DB.Session; ! {$ENDIF} end; --- 272,301 ---- begin case FItemType of ! bdDatabases: ! Check(DbiOpenDatabaseList(Result)); ! bdDrivers: ! Check(DbiOpenDriverList(Result)); ! bdLangDrivers: ! Check(DbiOpenLdList(Result)); ! bdUsers: ! Check(DbiOpenUserList(Result)); ! {$IFDEF WIN32} ! bdRepositories: ! Check(DbiOpenRepositoryList(Result)); ! {$ENDIF} end; end; {$IFDEF WIN32} + function TJvCustomBDEItems.GetDBSession: TSession; begin Result := Sessions.FindSession(SessionName); if Result = nil then ! {$IFDEF COMPILER3_UP} Result := DBTables.Session; ! {$ELSE} Result := DB.Session; ! {$ENDIF} end; *************** *** 319,323 **** try TJvSessionLink(FSessionLink).FList := Self; ! inherited OpenCursor{$IFDEF COMPILER3_UP}(InfoQuery){$ENDIF}; except FSessionLink.Free; --- 317,321 ---- try TJvSessionLink(FSessionLink).FList := Self; ! inherited OpenCursor {$IFDEF COMPILER3_UP} (InfoQuery) {$ENDIF}; except FSessionLink.Free; *************** *** 330,334 **** begin inherited CloseCursor; ! if FSessionLink <> nil then begin TJvSessionLink(FSessionLink).FList := nil; FSessionLink.Free; --- 328,333 ---- begin inherited CloseCursor; ! if FSessionLink <> nil then ! begin TJvSessionLink(FSessionLink).FList := nil; FSessionLink.Free; *************** *** 336,349 **** end; end; - {$ENDIF WIN32} - {$IFDEF WIN32} function TJvCustomBDEItems.GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} Integer {$ENDIF}; begin Result := dsGetRecordCount(Self); end; {$ENDIF WIN32} {$IFDEF COMPILER3_UP} function TJvCustomBDEItems.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; --- 335,348 ---- end; end; function TJvCustomBDEItems.GetRecordCount: {$IFNDEF COMPILER3_UP} Longint {$ELSE} Integer {$ENDIF}; begin Result := dsGetRecordCount(Self); end; + {$ENDIF WIN32} {$IFDEF COMPILER3_UP} + function TJvCustomBDEItems.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; *************** *** 351,364 **** DoBeforeScroll; Result := DataSetLocateThrough(Self, KeyFields, KeyValues, Options); ! if Result then begin DataEvent(deDataSetChange, 0); DoAfterScroll; end; end; - {$ENDIF COMPILER3_UP} - { TJvDBListDataSet } - - {$IFDEF COMPILER3_UP} function TJvDBListDataSet.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; --- 350,360 ---- DoBeforeScroll; Result := DataSetLocateThrough(Self, KeyFields, KeyValues, Options); ! if Result then ! begin DataEvent(deDataSetChange, 0); DoAfterScroll; end; end; function TJvDBListDataSet.Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; *************** *** 366,374 **** DoBeforeScroll; Result := DataSetLocateThrough(Self, KeyFields, KeyValues, Options); ! if Result then begin DataEvent(deDataSetChange, 0); DoAfterScroll; end; end; {$ENDIF COMPILER3_UP} --- 362,372 ---- DoBeforeScroll; Result := DataSetLocateThrough(Self, KeyFields, KeyValues, Options); ! if Result then ! begin DataEvent(deDataSetChange, 0); DoAfterScroll; end; end; + {$ENDIF COMPILER3_UP} *************** *** 380,388 **** {$ENDIF WIN32} - { TJvCustomDatabaseItems } - procedure TJvCustomDatabaseItems.SetItemType(Value: TDBItemType); begin ! if ItemType <> Value then begin CheckInactive; FItemType := Value; --- 378,385 ---- {$ENDIF WIN32} procedure TJvCustomDatabaseItems.SetItemType(Value: TDBItemType); begin ! if ItemType <> Value then ! begin CheckInactive; FItemType := Value; *************** *** 393,398 **** procedure TJvCustomDatabaseItems.SetFileMask(const Value: string); begin ! if FileMask <> Value then begin ! if Active and (FItemType in [dtTables, dtFiles]) then begin DisableControls; try --- 390,397 ---- procedure TJvCustomDatabaseItems.SetFileMask(const Value: string); begin ! if FileMask <> Value then ! begin ! if Active and (FItemType in [dtTables, dtFiles]) then ! begin DisableControls; try *************** *** 404,408 **** end; end ! else FFileMask := Value; DataEvent(dePropertyChange, 0); end; --- 403,408 ---- end; end ! else ! FFileMask := Value; DataEvent(dePropertyChange, 0); end; *************** *** 411,415 **** procedure TJvCustomDatabaseItems.SetExtendedInfo(Value: Boolean); begin ! if FExtended <> Value then begin CheckInactive; FExtended := Value; --- 411,416 ---- procedure TJvCustomDatabaseItems.SetExtendedInfo(Value: Boolean); begin ! if FExtended <> Value then ! begin CheckInactive; FExtended := Value; *************** *** 420,425 **** procedure TJvCustomDatabaseItems.SetSystemItems(Value: Boolean); begin ! if FSystemItems <> Value then begin ! if Active and (FItemType in [dtTables, dtStoredProcs]) then begin DisableControls; try --- 421,428 ---- procedure TJvCustomDatabaseItems.SetSystemItems(Value: Boolean); begin ! if FSystemItems <> Value then ! begin ! if Active and (FItemType in [dtTables, dtStoredProcs]) then ! begin DisableControls; try *************** *** 431,435 **** end; end ! else FSystemItems := Value; DataEvent(dePropertyChange, 0); end; --- 434,439 ---- end; end ! else ! FSystemItems := Value; DataEvent(dePropertyChange, 0); end; *************** *** 439,443 **** var WildCard: PChar; ! Pattern: array[0..DBIMAXTBLNAMELEN] of Char; begin WildCard := nil; --- 443,447 ---- var WildCard: PChar; ! Pattern: array [0..DBIMAXTBLNAMELEN] of Char; begin WildCard := nil; *************** *** 445,460 **** WildCard := AnsiToNative(DBLocale, FileMask, Pattern, SizeOf(Pattern) - 1); case FItemType of ! dtTables: Check(DbiOpenTableList(DBHandle, FExtended, FSystemItems, WildCard, Result)); dtStoredProcs: if DataBase.IsSQLBased then Check(DbiOpenSPList(DBHandle, FExtended, FSystemItems, nil, Result)) ! else DatabaseError(SLocalDatabase); ! dtFiles: Check(DbiOpenFileList(DBHandle, WildCard, Result)); ! {$IFDEF WIN32} dtFunctions: if DataBase.IsSQLBased then Check(DbiOpenFunctionList(DBHandle, DBIFUNCOpts(FExtended), @Result)) ! else DatabaseError(SLocalDatabase); ! {$ENDIF} end; end; --- 449,468 ---- WildCard := AnsiToNative(DBLocale, FileMask, Pattern, SizeOf(Pattern) - 1); case FItemType of ! dtTables: ! Check(DbiOpenTableList(DBHandle, FExtended, FSystemItems, WildCard, Result)); dtStoredProcs: if DataBase.IsSQLBased then Check(DbiOpenSPList(DBHandle, FExtended, FSystemItems, nil, Result)) ! else ! DatabaseError(SLocalDatabase); ! dtFiles: ! Check(DbiOpenFileList(DBHandle, WildCard, Result)); ! {$IFDEF WIN32} dtFunctions: if DataBase.IsSQLBased then Check(DbiOpenFunctionList(DBHandle, DBIFUNCOpts(FExtended), @Result)) ! else ! DatabaseError(SLocalDatabase); ! {$ENDIF} end; end; *************** *** 464,468 **** sObjListNameField = 'NAME'; sFileNameField = 'FILENAME'; ! sTabListExtField = 'EXTENSION'; var Temp: string; --- 472,476 ---- sObjListNameField = 'NAME'; sFileNameField = 'FILENAME'; ! sTabListExtField = 'EXTENSION'; var Temp: string; *************** *** 470,484 **** begin Result := ''; ! if not Active then Exit; ! if FItemType = dtFiles then Field := FindField(sFileNameField) ! else Field := FindField(sObjListNameField); ! if Field = nil then Exit; Result := Field.AsString; ! if FItemType in [dtTables, dtFiles] then begin Field := FindField(sTabListExtField); ! if Field = nil then Exit; Temp := Field.AsString; ! if Temp <> '' then begin ! if Temp[1] <> '.' then Temp := '.' + Temp; Result := Result + Temp; end; --- 478,500 ---- begin Result := ''; ! if not Active then ! Exit; ! if FItemType = dtFiles then ! Field := FindField(sFileNameField) ! else ! Field := FindField(sObjListNameField); ! if Field = nil then ! Exit; Result := Field.AsString; ! if FItemType in [dtTables, dtFiles] then ! begin Field := FindField(sTabListExtField); ! if Field = nil then ! Exit; Temp := Field.AsString; ! if Temp <> '' then ! begin ! if Temp[1] <> '.' then ! Temp := '.' + Temp; Result := Result + Temp; end; *************** *** 486,494 **** end; - { TJvCustomTableItems } - procedure TJvCustomTableItems.SetItemType(Value: TTabItemType); begin ! if ItemType <> Value then begin CheckInactive; FItemType := Value; --- 502,509 ---- end; procedure TJvCustomTableItems.SetItemType(Value: TTabItemType); begin ! if ItemType <> Value then ! begin CheckInactive; FItemType := Value; *************** *** 499,504 **** procedure TJvCustomTableItems.SetPhysTypes(Value: Boolean); begin ! if Value <> PhysTypes then begin ! if Active and (ItemType = dtFields) then begin DisableControls; try --- 514,521 ---- procedure TJvCustomTableItems.SetPhysTypes(Value: Boolean); begin ! if Value <> PhysTypes then ! begin ! if Active and (ItemType = dtFields) then ! begin DisableControls; try *************** *** 510,514 **** end; end ! else FPhysTypes := Value; DataEvent(dePropertyChange, 0); end; --- 527,532 ---- end; end ! else ! FPhysTypes := Value; DataEvent(dePropertyChange, 0); end; *************** *** 517,532 **** procedure TJvCustomTableItems.SetTableName(const Value: TFileName); begin ! if Value <> FTableName then begin ! if Active then begin DisableControls; try Close; FTableName := Value; ! if FTableName <> '' then Open; finally EnableControls; end; end ! else FTableName := Value; DataEvent(dePropertyChange, 0); end; --- 535,554 ---- procedure TJvCustomTableItems.SetTableName(const Value: TFileName); begin ! if Value <> FTableName then ! begin ! if Active then ! begin DisableControls; try Close; FTableName := Value; ! if FTableName <> '' then ! Open; finally EnableControls; end; end ! else ! FTableName := Value; DataEvent(dePropertyChange, 0); end; *************** *** 537,541 **** STableName: PChar; begin ! if FTableName = '' then _DBError(SNoTableName); STableName := StrAlloc(Length(FTableName) + 1); try --- 559,564 ---- STableName: PChar; begin ! if FTableName = '' then ! _DBError(SNoTableName); STableName := StrAlloc(Length(FTableName) + 1); try *************** *** 544,563 **** dtFields: while not CheckOpen(DbiOpenFieldList(DBHandle, STableName, nil, ! FPhysTypes, Result)) do {Retry}; dtIndices: while not CheckOpen(DbiOpenIndexList(DBHandle, STableName, nil, ! Result)) do {Retry}; dtValChecks: while not CheckOpen(DbiOpenVchkList(DBHandle, STableName, nil, ! Result)) do {Retry}; dtRefInt: while not CheckOpen(DbiOpenRintList(DBHandle, STableName, nil, ! Result)) do {Retry}; dtSecurity: while not CheckOpen(DbiOpenSecurityList(DBHandle, STableName, nil, ! Result)) do {Retry}; dtFamily: while not CheckOpen(DbiOpenFamilyList(DBHandle, STableName, nil, ! Result)) do {Retry}; end; finally --- 567,592 ---- dtFields: while not CheckOpen(DbiOpenFieldList(DBHandle, STableName, nil, ! FPhysTypes, Result)) do {Retry} ! ; dtIndices: while not CheckOpen(DbiOpenIndexList(DBHandle, STableName, nil, ! Result)) do {Retry} ! ; dtValChecks: while not CheckOpen(DbiOpenVchkList(DBHandle, STableName, nil, ! Result)) do {Retry} ! ; dtRefInt: while not CheckOpen(DbiOpenRintList(DBHandle, STableName, nil, ! Result)) do {Retry} ! ; dtSecurity: while not CheckOpen(DbiOpenSecurityList(DBHandle, STableName, nil, ! Result)) do {Retry} ! ; dtFamily: while not CheckOpen(DbiOpenFamilyList(DBHandle, STableName, nil, ! Result)) do {Retry} ! ; end; finally *************** *** 566,575 **** end; - { TJvDatabaseDesc } - constructor TJvDatabaseDesc.Create(const DatabaseName: string); var Buffer: PChar; begin Buffer := StrPCopy(StrAlloc(Length(DatabaseName) + 1), DatabaseName); try --- 595,603 ---- end; constructor TJvDatabaseDesc.Create(const DatabaseName: string); var Buffer: PChar; begin + // (rom) no inherited ? Buffer := StrPCopy(StrAlloc(Length(DatabaseName) + 1), DatabaseName); try *************** *** 580,589 **** end; - { TJvDriverDesc } - constructor TJvDriverDesc.Create(const DriverType: string); var Buffer: PChar; begin Buffer := StrPCopy(StrAlloc(Length(DriverType) + 1), DriverType); try --- 608,616 ---- end; constructor TJvDriverDesc.Create(const DriverType: string); var Buffer: PChar; begin + // (rom) no inherited ? Buffer := StrPCopy(StrAlloc(Length(DriverType) + 1), DriverType); try *************** *** 598,603 **** {$IFNDEF CBUILDER} - { TJvLangDrivList } - constructor TJvLangDrivList.Create(AOwner: TComponent); begin --- 625,628 ---- *************** *** 606,611 **** end; - { TJvTableList } - function TJvTableList.GetTableName: string; begin --- 631,634 ---- *************** *** 613,618 **** end; - { TJvStoredProcList } - constructor TJvStoredProcList.Create(AOwner: TComponent); begin --- 636,639 ---- *************** *** 621,626 **** end; - { TJvIndexList } - constructor TJvIndexList.Create(AOwner: TComponent); begin --- 642,645 ---- *************** *** 632,633 **** --- 651,653 ---- end. + |