📄 weboutput.pas
字号:
end;
end;
finally
realnmTables.Free;
end;
end;
//returns the Columns from all tables in a stringlist consisting of (name,SW_Column) pairs
//moreover the stringlist is ordered after the way the columns shall appear on the GridList
procedure TView.GetGridSortedColumns(stringList: TStringList);
begin
stringList.Assign(self.GridSortedColumnList);
end;
//returns the Columns from all tables in a stringlist consisting of (name,SW_Column) pairs
//moreover the stringlist is ordered after the way the columns shall appear on the Form
procedure TView.GetFormSortedColumns(stringList: TStringList);
begin
stringList.Assign(self.FormSortedColumnList);
end;
procedure TView.ExchangeGridSortedColumns(ind1, ind2 :Integer);
begin
GridSortedColumnList.Exchange(ind1,ind2);
end;
procedure TView.ExchangeFormSortedColumns(ind1, ind2 :Integer);
begin
FormSortedColumnList.Exchange(ind1,ind2);
end;
constructor TView.Create(Viewname, WhereClause :String; Table : SW_Table;
JoinTables, NMTables: TObjectList;IconImage: TPicture;
IconFilename, OrderBy: String; RowsPerPage:Integer);
var i: Integer;
begin
inherited Create();
Name:= Viewname;
self.WhereClause:=WhereClause;
self.RowsPerPage:= RowsPerPage; //default value
FormHeight := 400;
FormWidth := 600;
FormX := 50;
FormY := 50;
GridPopupWidth := 800;
GridPopupHeight := 600;
GridPopupX := 200;
GridPopupY := 100;
self.OrderBy := OrderBy;
FIcon := TPicture.Create;
FIcon.Assign(IconImage);
FIconFilename := IconFilename;
self.Table := Table.DeepCopy;
FJoinTables := TObjectList.Create();
FNMTables := TObjectList.Create();
if (JoinTables <> nil) then
begin
for i:=0 to JoinTables.Count-1 do
begin
self.JoinTables.Add(SW_Table(JoinTables[i]).DeepCopy() );
end;
end;
if (NMTables <> nil) then
begin
for i:=0 to NMTables.Count-1 do
begin
self.NMTables.Add(SW_Table(NMTables[i]).DeepCopy() );
end;
end;
GridSortedColumnList:= TStringList.Create;
GetColumns(GridSortedColumnList);
FormSortedColumnList:= TStringList.Create;
GetColumns(FormSortedColumnList);
end;
//not for public use
constructor TView.Create();
begin
inherited Create();
end;
destructor TView.Destroy;
begin
JoinTables.Free;
NMTables.Free;
Icon.Free;
GridSortedColumnList.Free;
FormSortedColumnList.Free;
end;
function TView.OneGridColVisible() : Boolean;
var stringList: TStringList;
i: Integer;
col : SW_Column;
begin
OneGridColVisible:= false;
stringList := TStringList.Create;
self.GetColumns(stringList); //get all columns
for i:= 0 to stringList.Count-1 do
begin
col := SW_Column(stringList.Objects[i]);
if (col.selectedForGrid) then
begin
OneGridColVisible:= True;
break;
end;
end;
stringList.Free;
end;
procedure TView.GetColumns(stringList: TStringList);
var i, j: Integer;
name : String;
tmpTable: SW_Table;
begin
for i:=0 to Table.columns.Count-1 do
begin
name := SW_Column(Table.columns[i]).table.name+'.'+ SW_Column(Table.columns[i]).name;
stringList.AddObject( name , Table.columns[i] );
end;
for i:= 0 to JoinTables.Count-1 do
begin
tmpTable := SW_Table(JoinTables[i]);
for j:= 0 to tmpTable.columns.Count-1 do
begin
name := SW_Column(tmpTable.columns[j]).table.name+'.'+ SW_Column(tmpTable.columns[j]).name;
stringList.AddObject( name , tmpTable.columns[j] );
end;
end;
for i:= 0 to NMTables.Count-1 do
begin
tmpTable := SW_Table(NMTables[i]);
for j:= 0 to tmpTable.columns.Count-1 do
begin
name := SW_Column(tmpTable.columns[j]).table.name+'.'+ SW_Column(tmpTable.columns[j]).name;
stringList.AddObject( name , tmpTable.columns[j] );
end;
end;
end;
class procedure TView.GetColumns(stringList: TStringList; view:TView);
var i, j: Integer;
name : String;
tmpTable: SW_Table;
begin
for i:=0 to view.Table.columns.Count-1 do
begin
name := SW_Column(view.Table.columns[i]).table.name+'.'+ SW_Column(view.Table.columns[i]).name;
stringList.AddObject( name , view.Table.columns[i] );
end;
for i:= 0 to view.JoinTables.Count-1 do
begin
tmpTable := SW_Table(view.JoinTables[i]);
for j:= 0 to tmpTable.columns.Count-1 do
begin
name := SW_Column(tmpTable.columns[j]).table.name+'.'+ SW_Column(tmpTable.columns[j]).name;
stringList.AddObject( name , tmpTable.columns[j] );
end;
end;
for i:= 0 to view.NMTables.Count-1 do
begin
tmpTable := SW_Table(view.NMTables[i]);
for j:= 0 to tmpTable.columns.Count-1 do
begin
name := SW_Column(tmpTable.columns[j]).table.name+'.'+ SW_Column(tmpTable.columns[j]).name;
stringList.AddObject( name , tmpTable.columns[j] );
end;
end;
end;
//*************************************************************
//**Implementations for TWeboutput*****************************
//*************************************************************
constructor TWeboutput.Create;
begin
inherited Create;
GroupList := TObjectList.Create;
UnassignedViewsList := TObjectList.Create;
end;
destructor TWeboutput.Destroy;
begin
GroupList.Free; //frees the list including all objects it contains
UnassignedViewsList.Free;
inherited Destroy;
end;
procedure TWeboutput.LoadFromXMLNode(node :IXMLSWF_DataType);
var groups :IXMLSWF_GroupsType;
group : IXMLSWF_GroupType;
realGroup : TGroup;
views :IXMLUnassignedViewsType;
view: Ixmlswf_ViewType;
realView :TView;
i: Integer;
begin
assert(node.Hostname <> '');
hostname := node.Hostname;
username := node.Username;
databasename := node.databaseName;
heading := node.Heading;
layout := node.Layout;
{$IFDEF MSWINDOWS}
saveDir := node.WinSaveDir;
{$ELSE}
saveDir := node.LinuxSaveDir;
{$ENDIF}
groups := node.SWF_Groups;
GroupList := TObjectList.Create;
for i:= 0 to groups.Count-1 do
begin
group := groups[i];
realGroup := TGroup.LoadFromXMLNode(group);
GroupList.Add(realGroup);
end;
views := node.UnassignedViews;
self.UnassignedViewsList := TObjectList.Create;
for i:= 0 to views.Count-1 do
begin
view := views[i];
realView := TView.LoadFromXMLNode(view);
if (realView <> nil) then
UnassignedViewsList.Add(realView);
end;
end;
procedure TWeboutput.SaveToXmlNode(node :IXMLSWF_DataType);
var i: Integer;
xmlGroup : IXMLSWF_GroupType;
group :TGroup;
xmlView :IXMLSWF_ViewType;
view :TView;
begin
node.hostname := hostname;
node.Username := username;
node.databasename := databasename;
node.heading := heading;
node.layout := layout;
{$IFDEF MSWINDOWS}
node.WinSavedir := SaveDir;
{$ELSE}
node.LinuxSaveDir := SaveDir;
{$ENDIF}
for i:=0 to self.GroupList.Count-1 do
begin
xmlGroup := node.SWF_Groups.Add;
group := TGroup(GroupList[i]);
group.SaveToXMLNode(xmlGroup);
end;
for i:= 0 to self.UnassignedViewsList.Count-1 do
begin
xmlView := node.UnassignedViews.Add;
view := TView(UnassignedViewsList[i]);
view.SaveToXMLNode(xmlView);
end;
end;
procedure TWeboutput.SetSaveDir(s: String);
begin
FsaveDir := IncludeTrailingPathDelimiter(s);
if (NOT DirectoryExists(FSaveDir)) THEN
FdirDoesntExist := True
else
FdirDoesntExist := False;
end;
//**********************************
//Group/View - Mangement functions*
//**********************************
procedure TWeboutput.AddGroup(group: TGroup);
begin
GroupList.Add(group);
end;
procedure TWeboutput.DeleteGroup(group: TGroup);
begin
GroupList.Remove(group);
end;
function TWeboutput.GroupPositionFree(lineNo, colNo : Integer) : Boolean;
var i : Integer;
tmpGrp : TGroup;
begin
GroupPositionFree := true;
for i:=0 to GroupList.Count-1 do
begin
tmpGrp := TGroup(GroupList[i]);
if ( (tmpGrp.showOnLine=lineNo) and (tmpGrp.showInColumn=colNo) ) then
begin
GroupPositionFree := false;
break;
end;
end;
end;
function TWeboutput.GetGroupAtPosition(lineNo, ColNo : Integer) : TGroup;
var i : Integer;
tmpGrp : TGroup;
begin
GetGroupAtPosition := nil;
for i:=0 to GroupList.Count-1 do
begin
tmpGrp := TGroup(GroupList[i]);
if ( (tmpGrp.showOnLine=lineNo) and (tmpGrp.showInColumn=colNo)) then
begin
GetGroupAtPosition := tmpGrp;
exit;
end;
end;
end;
//adds a view to the list of unassigned views
procedure TWeboutput.AddView(view: TView);
begin
UnassignedViewsList.Add(view);
end;
procedure TWeboutput.DeleteView(view: TView);
var i,j: Integer;
views: TList;
begin
for i:=0 to UnassignedViewsList.Count-1 do
begin
if (UnassignedViewsList[i] = view) then
begin
UnassignedViewsList.Delete(i);
Exit;
end;
end;
for i:=0 to GroupList.Count-1 do
begin
views := TGroup(GroupList[i]).Views;
for j:=0 to views.Count-1 do
begin
if (views[j] = view) then
begin
views.Delete(j);
Exit;
end;
end;
end;
end;
procedure TWeboutput.AssignViewToGroup(group :TGroup; view: TView);
begin
self.UnassignedViewsList.Extract(view);
group.Views.Add(view);
end;
procedure TWeboutput.UnassignViewFromGroup(group :TGroup; view :TView);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -