mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 00:19:50 +02:00
added dbpropedits.pas property editors for db controls
git-svn-id: trunk@6488 -
This commit is contained in:
parent
f0a505b202
commit
9ad079b291
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -789,6 +789,7 @@ ideintf/componenteditors.pas svneol=native#text/pascal
|
||||
ideintf/componentreg.pas svneol=native#text/pascal
|
||||
ideintf/componenttreeview.pas svneol=native#text/pascal
|
||||
ideintf/configstorage.pas svneol=native#text/pascal
|
||||
ideintf/dbpropedits.pas svneol=native#text/pascal
|
||||
ideintf/formeditingintf.pas svneol=native#text/pascal
|
||||
ideintf/graphpropedits.pas svneol=native#text/pascal
|
||||
ideintf/helpfpdoc.pas svneol=native#text/pascal
|
||||
|
@ -21,10 +21,10 @@ interface
|
||||
|
||||
uses
|
||||
IDECommands, PropEdits, ObjInspStrConsts, ObjectInspector, ColumnDlg,
|
||||
ComponentEditors, GraphPropEdits, ListViewPropEdit, ImageListEditor,
|
||||
ComponentTreeView, ActionsEditor, HelpIntf, TextTools, FormEditingIntf,
|
||||
SrcEditorIntf, ComponentReg, PackageIntf, HelpHTML, ConfigStorage,
|
||||
HelpFPDoc, ProjectIntf, LazIDEIntf, NewItemIntf, MacroIntf;
|
||||
ComponentEditors, GraphPropEdits, DBPropEdits, ListViewPropEdit,
|
||||
ImageListEditor, ComponentTreeView, ActionsEditor, HelpIntf, TextTools,
|
||||
FormEditingIntf, SrcEditorIntf, ComponentReg, PackageIntf, HelpHTML,
|
||||
ConfigStorage, HelpFPDoc, ProjectIntf, LazIDEIntf, NewItemIntf, MacroIntf;
|
||||
|
||||
implementation
|
||||
|
||||
|
97
ideintf/dbpropedits.pas
Normal file
97
ideintf/dbpropedits.pas
Normal file
@ -0,0 +1,97 @@
|
||||
{ Copyright (C) 2004
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* See the file COPYING.modifiedLGPL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
Author: Andrew Haines
|
||||
|
||||
Abstract:
|
||||
Property Editors for Database components of FCL and LCL.
|
||||
}
|
||||
unit DBPropEdits;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, PropEdits, Componenteditors, TypInfo;
|
||||
|
||||
type
|
||||
TFieldProperty = class(TStringProperty)
|
||||
public
|
||||
function GetAttributes: TPropertyAttributes; override;
|
||||
procedure GetValues(Proc: TGetStrProc); override;
|
||||
procedure FillValues(const Values: TStringList); virtual;
|
||||
end;
|
||||
|
||||
TDBGridFieldProperty = class(TFieldProperty)
|
||||
public
|
||||
procedure FillValues(const Values: TStringList); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses DB, SysUtils, DBGrids;
|
||||
|
||||
{ TFieldProperty }
|
||||
|
||||
function TFieldProperty.GetAttributes: TPropertyAttributes;
|
||||
begin
|
||||
Result:= [paValueList, paSortList, paMultiSelect];
|
||||
end;
|
||||
|
||||
procedure TFieldProperty.GetValues(Proc: TGetStrProc);
|
||||
var
|
||||
I: Integer;
|
||||
Values: TStringList;
|
||||
begin
|
||||
Values := TStringList.Create;
|
||||
try
|
||||
FillValues(Values);
|
||||
for I := 0 to Values.Count - 1 do Proc(Values[I]);
|
||||
finally
|
||||
Values.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFieldProperty.FillValues(const Values: TStringList);
|
||||
var
|
||||
DataSource: TDataSource;
|
||||
begin
|
||||
DataSource := GetObjectProp(GetComponent(0), 'DataSource') as TDataSource;
|
||||
if (DataSource is TDataSource) and Assigned(DataSource.DataSet) then
|
||||
DataSource.DataSet.GetFieldNames(Values);
|
||||
end;
|
||||
|
||||
{ TDBGridFieldProperty }
|
||||
|
||||
procedure TDBGridFieldProperty.FillValues(const Values: TStringList);
|
||||
var
|
||||
Column: TColumn;
|
||||
Grid: TdbGrid;
|
||||
DataSource: TDataSource;
|
||||
begin
|
||||
Column:=TColumn(GetComponent(0));
|
||||
if not (Column is TColumn) then exit;
|
||||
Grid:=TdbGrid(Column.Grid);
|
||||
if not (Grid is TdbGrid) then exit;
|
||||
DataSource := Grid.DataSource;
|
||||
if Assigned(DataSource) and Assigned(DataSource.DataSet) then
|
||||
DataSource.DataSet.GetFieldNames(Values);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPropertyEditor(TypeInfo(string), TComponent, 'DataField', TFieldProperty);
|
||||
RegisterPropertyEditor(TypeInfo(string), TColumn, 'FieldName', TDBGridFieldProperty);
|
||||
|
||||
end.
|
||||
|
@ -1365,7 +1365,7 @@ var
|
||||
GReferenceExpandable: Boolean;
|
||||
GShowReadOnlyProps: Boolean;
|
||||
|
||||
// default Hook
|
||||
// default Hook - set by IDE
|
||||
var
|
||||
GlobalDesignHook: TPropertyEditorHook;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user