fix error in sort data at TRxMemDataset, add demo for use AutoSort from RxDBGrid and TRxMemDataSet

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@802 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2009-05-15 19:56:17 +00:00
parent 15e969fe76
commit 31f9f02355
11 changed files with 503 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,129 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="7"/>
<General>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="rxnew"/>
<MinVersion Major="1" Minor="2" Release="2" Build="103" Valid="True"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="6">
<Unit0>
<Filename Value="AutoSortDemo.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="AutoSortDemo"/>
<CursorPos X="1" Y="20"/>
<TopLine Value="1"/>
<UsageCount Value="20"/>
</Unit0>
<Unit1>
<Filename Value="asdmainunit.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="asdMainUnit"/>
<CursorPos X="20" Y="39"/>
<TopLine Value="22"/>
<EditorIndex Value="0"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../../../../../../../usr/local/share/lazarus/components/rxnew/rxsortmemds.pas"/>
<UnitName Value="rxsortmemds"/>
<CursorPos X="69" Y="52"/>
<TopLine Value="24"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<Filename Value="../../../../../../../../usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<UnitName Value="rxdbgrid"/>
<CursorPos X="1" Y="1410"/>
<TopLine Value="1393"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="../../../../../../../../usr/local/share/lazarus/lcl/dbgrids.pas"/>
<UnitName Value="DBGrids"/>
<CursorPos X="1" Y="688"/>
<TopLine Value="671"/>
<UsageCount Value="10"/>
</Unit4>
<Unit5>
<Filename Value="../../../../../../../../usr/local/share/lazarus/components/rxnew/rxmemds.pas"/>
<UnitName Value="rxmemds"/>
<CursorPos X="1" Y="1346"/>
<TopLine Value="1329"/>
<UsageCount Value="10"/>
</Unit5>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Source Value="../../../../../../../../usr/local/share/lazarus/components/rxnew/rxdbgrid.pas"/>
<Line Value="741"/>
</Item1>
</BreakPoints>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,41 @@
{ Demo application from RXFPC
Copyright (C) 2009 Lagunov Aleksey (alexs75@hotbox.ru)
This source is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This code 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. See the GNU General Public License for more
details.
A copy of the GNU General Public License is available on the World Wide Web
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
}
program AutoSortDemo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
rxsortmemds, //Include this unit for use auto sort data in TRxMemoryData with RxDBGrid
asdMainUnit;
{$IFDEF WINDOWS}{$R AutoSortDemo.rc}{$ENDIF}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="CompanyName.ProductName.YourApp" type="win32"/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,7 @@
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "AutoSortDemo.manifest"
MAINICON ICON "AutoSortDemo.ico"

View File

@ -0,0 +1,146 @@
object Form1: TForm1
Left = 366
Height = 524
Top = 217
Width = 780
Caption = 'Auto sort demo'
ClientHeight = 524
ClientWidth = 780
OnCreate = FormCreate
LCLVersion = '0.9.27'
object RxDBGrid1: TRxDBGrid
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CheckBox1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 6
Height = 456
Top = 62
Width = 768
TitleButtons = True
AutoSort = True
Columns = <
item
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Width = 88
FieldName = 'ID'
Filter.DropDownRows = 0
Filter.ItemIndex = -1
end
item
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Width = 350
FieldName = 'NAME'
Filter.DropDownRows = 0
Filter.ItemIndex = -1
end
item
Title.Alignment = taCenter
Title.Orientation = toHorizontal
Width = 100
FieldName = 'DATE_ENTER'
Filter.DropDownRows = 0
Filter.ItemIndex = -1
end>
OptionsRx = []
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
FocusColor = clRed
SelectedColor = clHighlight
GridLineStyle = psSolid
DataSource = Datasource1
ParentColor = False
TabOrder = 0
TitleStyle = tsNative
end
object CheckBox1: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CheckBox2
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 34
Width = 104
BorderSpacing.Around = 6
Caption = 'Title buttons'
OnChange = CheckBox2Change
TabOrder = 1
end
object CheckBox2: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 22
Top = 6
Width = 84
BorderSpacing.Around = 6
Caption = 'Auto sort'
OnChange = CheckBox2Change
TabOrder = 2
end
object RxMemoryData1: TRxMemoryData
AutoCalcFields = False
FieldDefs = <
item
Name = 'ID'
DataType = ftInteger
Precision = -1
Size = 0
end
item
Name = 'NAME'
DataType = ftString
Precision = -1
Size = 100
end
item
Name = 'DATE_ENTER'
DataType = ftDate
Precision = -1
Size = 0
end>
left = 192
top = 16
object RxMemoryData1ID: TLongintField
DisplayWidth = 10
FieldKind = fkData
FieldName = 'ID'
Index = 0
LookupCache = False
ProviderFlags = [pfInUpdate, pfInWhere]
ReadOnly = False
Required = False
end
object RxMemoryData1NAME: TStringField
DisplayWidth = 100
FieldKind = fkData
FieldName = 'NAME'
Index = 1
LookupCache = False
ProviderFlags = [pfInUpdate, pfInWhere]
ReadOnly = False
Required = False
Size = 100
end
object RxMemoryData1DATE_ENTER: TDateField
DisplayWidth = 10
FieldKind = fkData
FieldName = 'DATE_ENTER'
Index = 2
LookupCache = False
ProviderFlags = [pfInUpdate, pfInWhere]
ReadOnly = False
Required = False
end
end
object Datasource1: TDatasource
DataSet = RxMemoryData1
left = 152
top = 16
end
end

View File

@ -0,0 +1,46 @@
{ Это - файл ресурсов, автоматически созданный lazarus }
LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'n'#1#6'Height'#3#12#2#3'Top'#3#217#0#5'Wi'
+'dth'#3#12#3#7'Caption'#6#14'Auto sort demo'#12'ClientHeight'#3#12#2#11'Clie'
+'ntWidth'#3#12#3#8'OnCreate'#7#10'FormCreate'#10'LCLVersion'#6#6'0.9.27'#0#9
+'TRxDBGrid'#9'RxDBGrid1'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSide'
+'Top.Control'#7#9'CheckBox1'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'Anchor'
+'SideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'An'
+'chorSideBottom.Control'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'
+#4'Left'#2#6#6'Height'#3#200#1#3'Top'#2'>'#5'Width'#3#0#3#12'TitleButtons'#9
+#8'AutoSort'#9#7'Columns'#14#1#15'Title.Alignment'#7#8'taCenter'#17'Title.Or'
+'ientation'#7#12'toHorizontal'#5'Width'#2'X'#9'FieldName'#6#2'ID'#19'Filter.'
+'DropDownRows'#2#0#16'Filter.ItemIndex'#2#255#0#1#15'Title.Alignment'#7#8'ta'
+'Center'#17'Title.Orientation'#7#12'toHorizontal'#5'Width'#3'^'#1#9'FieldNam'
+'e'#6#4'NAME'#19'Filter.DropDownRows'#2#0#16'Filter.ItemIndex'#2#255#0#1#15
+'Title.Alignment'#7#8'taCenter'#17'Title.Orientation'#7#12'toHorizontal'#5'W'
+'idth'#2'd'#9'FieldName'#6#10'DATE_ENTER'#19'Filter.DropDownRows'#2#0#16'Fil'
+'ter.ItemIndex'#2#255#0#0#9'OptionsRx'#11#0#7'Anchors'#11#5'akTop'#6'akLeft'
+#7'akRight'#8'akBottom'#0#20'BorderSpacing.Around'#2#6#10'FocusColor'#7#5'cl'
+'Red'#13'SelectedColor'#7#11'clHighlight'#13'GridLineStyle'#7#7'psSolid'#10
+'DataSource'#7#11'Datasource1'#11'ParentColor'#8#8'TabOrder'#2#0#10'TitleSty'
+'le'#7#8'tsNative'#0#0#9'TCheckBox'#9'CheckBox1'#22'AnchorSideLeft.Control'#7
+#5'Owner'#21'AnchorSideTop.Control'#7#9'CheckBox2'#18'AnchorSideTop.Side'#7#9
+'asrBottom'#4'Left'#2#6#6'Height'#2#22#3'Top'#2'"'#5'Width'#2'h'#20'BorderSp'
+'acing.Around'#2#6#7'Caption'#6#13'Title buttons'#8'OnChange'#7#15'CheckBox2'
+'Change'#8'TabOrder'#2#1#0#0#9'TCheckBox'#9'CheckBox2'#22'AnchorSideLeft.Con'
+'trol'#7#5'Owner'#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#2#6#6'Height'
+#2#22#3'Top'#2#6#5'Width'#2'T'#20'BorderSpacing.Around'#2#6#7'Caption'#6#9'A'
+'uto sort'#8'OnChange'#7#15'CheckBox2Change'#8'TabOrder'#2#2#0#0#13'TRxMemor'
+'yData'#13'RxMemoryData1'#14'AutoCalcFields'#8#9'FieldDefs'#14#1#4'Name'#6#2
+'ID'#8'DataType'#7#9'ftInteger'#9'Precision'#2#255#4'Size'#2#0#0#1#4'Name'#6
+#4'NAME'#8'DataType'#7#8'ftString'#9'Precision'#2#255#4'Size'#2'd'#0#1#4'Nam'
+'e'#6#10'DATE_ENTER'#8'DataType'#7#6'ftDate'#9'Precision'#2#255#4'Size'#2#0#0
+#0#4'left'#3#192#0#3'top'#2#16#0#13'TLongintField'#15'RxMemoryData1ID'#12'Di'
+'splayWidth'#2#10#9'FieldKind'#7#6'fkData'#9'FieldName'#6#2'ID'#5'Index'#2#0
+#11'LookupCache'#8#13'ProviderFlags'#11#10'pfInUpdate'#9'pfInWhere'#0#8'Read'
+'Only'#8#8'Required'#8#0#0#12'TStringField'#17'RxMemoryData1NAME'#12'Display'
+'Width'#2'd'#9'FieldKind'#7#6'fkData'#9'FieldName'#6#4'NAME'#5'Index'#2#1#11
+'LookupCache'#8#13'ProviderFlags'#11#10'pfInUpdate'#9'pfInWhere'#0#8'ReadOnl'
+'y'#8#8'Required'#8#4'Size'#2'd'#0#0#10'TDateField'#23'RxMemoryData1DATE_ENT'
+'ER'#12'DisplayWidth'#2#10#9'FieldKind'#7#6'fkData'#9'FieldName'#6#10'DATE_E'
+'NTER'#5'Index'#2#2#11'LookupCache'#8#13'ProviderFlags'#11#10'pfInUpdate'#9
+'pfInWhere'#0#8'ReadOnly'#8#8'Required'#8#0#0#0#11'TDatasource'#11'Datasourc'
+'e1'#7'DataSet'#7#13'RxMemoryData1'#4'left'#3#152#0#3'top'#2#16#0#0#0
]);

View File

@ -0,0 +1,82 @@
{ Demo application from RXFPC
Copyright (C) 2009 Lagunov Aleksey (alexs75@hotbox.ru)
This source is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This code 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. See the GNU General Public License for more
details.
A copy of the GNU General Public License is available on the World Wide Web
at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
}
unit asdMainUnit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, db, FileUtil, LResources, Forms, Controls, Graphics,
Dialogs, StdCtrls, rxmemds, rxdbgrid;
type
{ TForm1 }
TForm1 = class(TForm)
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Datasource1: TDatasource;
RxDBGrid1: TRxDBGrid;
RxMemoryData1: TRxMemoryData;
RxMemoryData1DATE_ENTER: TDateField;
RxMemoryData1ID: TLongintField;
RxMemoryData1NAME: TStringField;
procedure CheckBox2Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
RxMemoryData1.Open;
RxMemoryData1.AppendRecord([1, 'Delphi', EncodeDate(1995, 8, 1)]);
RxMemoryData1.AppendRecord([2, 'Turbo Pascal', EncodeDate(1983, 8, 1)]);
RxMemoryData1.AppendRecord([3, 'Free Pascal', EncodeDate(1993, 1, 1)]);
RxMemoryData1.AppendRecord([4, 'Lazarus', Now]);
CheckBox2.Checked:=RxDBGrid1.AutoSort;
CheckBox1.Checked:=RxDBGrid1.TitleButtons;
end;
procedure TForm1.CheckBox2Change(Sender: TObject);
begin
RxDBGrid1.AutoSort:=CheckBox2.Checked;
RxDBGrid1.TitleButtons:=CheckBox1.Checked;
end;
initialization
{$I asdmainunit.lrs}
end.

View File

@ -17,6 +17,8 @@
Изменён дизайн формы
+ Улучшена отриосвка вертикальных заголовков в гриде. Код из TAChart
+ Опубликова BorderSpacing в TRxLabel
+ Добавлен пример для использования автоматической сортировки в RxDBGrid
- Исправлена сортировка при использовании TRxMemDataSet
22.05.2008 - версия 2.0.0.136 (svn revision 100)
+ У объекта TRxCustomDBLookupCombo введён контроль на CircularDataLink
+ У объекта TRxCustomDBLookupCombo ускорена отрисовка данных

View File

@ -25,7 +25,7 @@ translate to Lazarus by alexs in 2005 - 2009
"/>
<License Value="free ware
"/>
<Version Major="1" Minor="2" Release="2" Build="103"/>
<Version Major="2" Release="1" Build="103"/>
<Files Count="51">
<Item1>
<Filename Value="rxlookup.pas"/>

View File

@ -1,3 +1,33 @@
{ This module from FPC port of RX components library
Copyright (C) 2006-2009 Lagunov Aleksey (alexs75@hotbox.ru)
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version with the following modification:
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,and
to copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the terms
and conditions of the license of that module. An independent module is a
module which is not derived from or based on this library. If you modify
this library, you may extend this exception to your version of the library,
but you are not obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
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. See the GNU Library General Public License
for more details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
unit rxsortmemds;
{$mode objfpc}{$H+}
@ -5,13 +35,7 @@ unit rxsortmemds;
interface
uses
Classes, SysUtils, DB,
{$IFDEF FPC}
RxDBGrid
{$ELSE}
exDBGrid
{$ENDIF}
;
Classes, SysUtils, DB, RxDBGrid;
type
TRxMemoryDataSortEngine = class(TExDBGridSortEngine)
@ -25,7 +49,7 @@ uses rxmemds;
procedure TRxMemoryDataSortEngine.Sort(Field:TField; ADataSet:TDataSet; Asc:boolean);
begin
if Assigned(ADataSet) then
(ADataSet as TRxMemoryData).SortOnFields(Field.FieldName, Asc);
(ADataSet as TRxMemoryData).SortOnFields(Field.FieldName, true, Asc);
end;
initialization