📄 main.pas
字号:
var i,grpInd : Integer;
begin
grpInd:= GroupComboBox.ItemIndex;
if (grpInd=-1) then Exit;
for i:=0 to UnassignedViewsListBox.Items.Count-1 do
begin
if UnassignedViewsListBox.Selected[i] then
Output.AssignViewToGroup(TGroup(GroupComboBox.Items.Objects[grpInd]),TView(UnassignedViewsListBox.Items.Objects[i]));
end;
RefreshGroupTab;
end;
procedure TMainForm.RABtnClick(Sender: TObject);
var i, grpInd : Integer;
begin
grpInd:= GroupComboBox.ItemIndex;
if (grpInd=-1) then Exit;
for i:=0 to ViewsFromGroupListBox.Items.Count-1 do
begin
if (ViewsFromGroupListBox.Selected[i]) then
Output.UnassignViewFromGroup(TGroup(GroupComboBox.Items.Objects[grpInd]),TView(ViewsFromGroupListBox.Items.Objects[i]));
end;
RefreshGroupTab;
end;
//*****************************************
//**********4th page(Grid)*****************
//*****************************************
procedure TMainForm.RefreshGridTab;
var stringList : TStringList;
tmpGrp : TGroup;
begin
stringList := TStringList.Create;
Output.GetGroupNames(stringList);
Group2ComboBox.Items.Assign(stringList);
if (stringList.Count = 0) then
begin
Group2ComboBox.Enabled := false;
Group2ComboBox.ItemIndex:= -1;
end
else
begin
Group2ComboBox.Enabled := true;
if ((Group2ComboBox.ItemIndex = -1) or (Group2ComboBox.ItemIndex >= Group2ComboBox.Items.Count)) then Group2ComboBox.ItemIndex:= 0;
end;
stringList.Clear;
if (Group2ComboBox.ItemIndex = -1) then //meaning we have no groups
begin
ViewComboBox.Clear;
ViewComboBox.Enabled := False;
end
else
begin
tmpGrp := TGroup(Group2ComboBox.Items.Objects[Group2ComboBox.ItemIndex]);
Output.GetViewNamesFromGroup(tmpGrp,stringList);
ViewComboBox.Items.Assign(stringList);
if (stringList.Count = 0) then
begin
ViewComboBox.Enabled := false;
ViewComboBox.ItemIndex := -1;
end
else
begin
ViewComboBox.Enabled := True;
ViewComboBox.ItemIndex := 0;
end;
end;
stringList.Free;
RefreshViewInfo;
end;
//This method refreshes all controls that are dependent on the selected View
//The method is called when the currently selected view changes. (meaning when the view-pulldownbox changes)
procedure TMainForm.RefreshViewInfo;
var stringList : TStringList;
tmpView : TView;
i : Integer;
begin
//3 Controls need to be taken care of:
// FieldsVisibleCheckListBox, RowsPerPageEd, CompoundColNamesCheckBox
if (ViewComboBox.ItemIndex = -1) then
begin
FieldsVisibleCheckListBox.Clear;
FieldsVisibleCheckListBox.Enabled := false;
RowsPerPageEd.Text := '';
RowsPerPageEd.Enabled := false;
CompoundColNamesCheckBox.Checked := false;
CompoundColNamesCheckBox.Enabled := false;
EditViewSettingsBtn.Enabled := false;
end
else
begin
tmpView := TView(ViewComboBox.Items.Objects[ViewComboBox.ItemIndex]);
stringList := TStringList.Create;
tmpView.GetGridSortedColumns(stringList);
FieldsVisibleCheckListBox.Enabled := True;
FieldsVisibleCheckListBox.Items.Assign(stringList);
for i:=0 to FieldsVisibleCheckListBox.Items.Count-1 do
begin
FieldsVisibleCheckListBox.Checked[i] := SW_Column(stringList.Objects[i]).selectedForGrid;
end;
stringList.Clear;
RowsPerPageEd.Enabled := True;
RowsPerPageEd.Text := IntToStr(tmpView.RowsPerPage);
CompoundColNamesCheckBox.Enabled := True;
CompoundColNamesCheckBox.Checked := tmpView.UseCompoundColNames;
EditViewSettingsBtn.Enabled := TGroup(Group2ComboBox.Items.Objects[Group2ComboBox.ItemIndex]).ViewsAsPopup;
end;
RefreshColInfo;
end;
//This method refreshes all controls that are dependent on the selected Column
procedure TMainForm.RefreshColInfo;
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) then
begin
ColNameEd.Text := '';
ColNameEd.Enabled := false;
FixedWidthCheckBox.Enabled := false;
ColWidthEd.Text := '';
ColWidthEd.Enabled := false;
TruncateCheckBox.Enabled := false;
ColTruncateCharsEd.Text := '';
ColTruncateCharsEd.Enabled := false;
exit;
end;
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
//we show the correct values, but the user cannot change them
if (column.selectedForGrid = false) then
begin
ColNameEd.Text := column.GridName;
ColNameEd.Enabled := false;
FixedWidthCheckBox.Enabled := false;
if (column.FixedWidth = -1) then
begin
ColWidthEd.Text := '50';
FixedWidthCheckBox.Checked := false;
end
else
begin
ColWidthEd.Text := IntToStr(column.FixedWidth);
FixedWidthCheckBox.Checked := true;
end;
ColWidthEd.Enabled := false;
TruncateCheckBox.Enabled := false;
if (column.TruncateChars = -1) then
begin
ColTruncateCharsEd.Text := '10';
TruncateCheckBox.Checked := false;
end
else
begin
ColTruncateCharsEd.Text := IntToStr(column.TruncateChars);
TruncateCheckBox.Checked := true;
end;
ColTruncateCharsEd.Enabled := false;
exit;
end;
ColNameEd.Enabled := true;
FixedWidthCheckBox.Enabled := true;
TruncateCheckBox.Enabled := true;
ColNameEd.Text := column.GridName;
if (column.fixedWidth = -1) then
begin
FixedWidthCheckBox.Checked := false;
ColWidthEd.Text := '50';
ColWidthEd.Enabled := false;
end
else
begin
FixedWidthCheckBox.Checked := true;
ColWidthEd.Enabled := true;
ColWidthEd.Text := IntToStr(column.fixedWidth);
end;
if (column.truncateChars = -1) then
begin
TruncateCheckBox.Checked := false;
ColTruncateCharsEd.Text := '10';
ColTruncateCharsEd.Enabled := false;
end
else
begin
TruncateCheckBox.Checked := true;
ColTruncateCharsEd.Enabled := true;
ColTruncateCharsEd.Text := IntToStr(column.truncateChars);
end;
if (Output.InputComplete) then
ActivateRun
else
DeactivateRun;
end;
procedure TMainForm.RowsPerPageEdExit(Sender: TObject);
var vInd: Integer;
view: TView;
begin
//what view is selected?
vInd := ViewComboBox.ItemIndex;
if (vInd = -1) then exit;
view := TView(ViewComboBox.Items.Objects[vInd]);
view.RowsPerPage := StrToInt(RowsPerPageEd.Text);
end;
procedure TMainForm.CompoundColNamesCheckBoxClick(Sender: TObject);
var vInd: Integer;
view: TView;
cols : TStringList;
i: Integer;
col: SW_Column;
begin
//what view is selected?
vInd := ViewComboBox.ItemIndex;
if (vInd = -1) then exit;
view := TView(ViewComboBox.Items.Objects[vInd]);
view.UseCompoundColNames := CompoundColNamesCheckBox.Checked;
cols := TStringList.Create;
view.GetGridSortedColumns(cols);
for i:=0 to cols.Count-1 do
begin
col := SW_Column(cols.Objects[i]);
if (view.UseCompoundColNames) then
begin
if (col.GridName = col.name) then //we only change the names that have not been altered by the user
col.GridName := col.Table.name + '.' + col.name;
end
else
begin
if (col.GridName = col.table.name +'.'+ col.name) then
col.GridName := col.name;
end;
end;
cols.Free;
RefreshColInfo;
end;
procedure TMainForm.Group2ComboBoxChange(Sender: TObject);
begin
RefreshGridTab;
end;
procedure TMainForm.ViewComboBoxChange(Sender: TObject);
begin
RefreshViewInfo;
end;
procedure TMainForm.FieldsVisibleCheckListBoxClick(Sender: TObject);
begin
RefreshColInfo;
end;
procedure TMainForm.FieldsVisibleCheckListBoxClickCheck(Sender: TObject);
var col : SW_Column;
begin
col := SW_Column(FieldsVisibleCheckListBox.Items.Objects[FieldsVisibleCheckListBox.ItemIndex]);
col.ToggleGridSelected;
RefreshColInfo;
end;
procedure TMainForm.FixedWidthCheckBoxClick(Sender: TObject);
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) then exit; //just to be on the safe side..(it should be deactivated actually)
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
if (FixedWidthCheckBox.Checked) then
begin
ColWidthEd.Enabled := True;
if (column.FixedWidth = -1) then //supply a default value
begin
ColWidthEd.Text := '50';
column.fixedWidth := 50;
end
else
begin
ColWidthEd.Text := IntToStr(column.fixedWidth);
end;
end
else
begin
ColWidthEd.Enabled := false;
column.fixedWidth := -1;
end;
end;
procedure TMainForm.ColWidthEdExit(Sender: TObject);
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) then exit;
//we also call this method from TakeSettings, so we need the following check
if (FixedWidthCheckBox.Checked = false) then exit;
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
column.fixedWidth := StrToInt(ColWidthEd.Text);
end;
procedure TMainForm.ColnameEdExit(Sender: TObject);
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) then exit;
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
column.GridName := ColnameEd.Text;
end;
procedure TMainForm.ColTruncateCharsEdExit(Sender: TObject);
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) then exit;
//we also call this method from TakeSettings, so we need the following check
if (TruncateCheckBox.Checked = false) then exit;
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
column.TruncateChars := StrToInt(ColTruncateCharsEd.Text);
end;
procedure TMainForm.TruncateCheckBoxClick(Sender: TObject);
var cInd : Integer;
column : SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
assert(cInd <> -1);
column := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
if (TruncateCheckBox.Checked) then
begin
ColTruncateCharsEd.Enabled := True;
if (column.TruncateChars = -1) then //supply a default value
begin
ColTruncateCharsEd.Text := '10';
column.truncateChars := 10;
end
else
begin
ColTruncateCharsEd.Text := IntToStr(column.TruncateChars);
end;
end
else
begin
ColTruncateCharsEd.Enabled := false;
column.truncateChars := -1;
end;
end;
procedure TMainForm.PopupBtnClick(Sender: TObject);
var vInd : Integer;
view: TView;
begin
//what view is selected?
vInd := ViewComboBox.ItemIndex;
assert (vInd <> -1);
view := TView(ViewComboBox.Items.Objects[vInd]);
DialogPopupSettingsForm:= TDialogPopupSettingsForm.Create(nil);
DialogPopupSettingsForm.SetView(view);
DialogPopupSettingsForm.ShowModal;
DialogPopupSettingsForm.Release;
end;
procedure TMainForm.Grid_UpBtnClick(Sender: TObject);
var cInd,vInd : Integer;
view: TView;
col1,col2 :SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) or (cInd-1 = -1) then exit;
vInd := ViewComboBox.ItemIndex;
assert(vInd <> -1);
view := TView(ViewComboBox.Items.Objects[vInd]);
col1 := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
col2 := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd-1]);
view.ExchangeGridSortedColumns(cInd, cInd-1);
// FieldsVisibleCheckListBox.Items.Exchange(cInd, cInd-1);
FieldsVisibleCheckListBox.Items[cInd] := col2.table.name+'.'+col2.name;
FieldsVisibleCheckListBox.Items[cInd-1] := col1.Table.name+'.'+col1.name;
FieldsVisibleCheckListBox.Items.Objects[cInd] := col2;
FieldsVisibleCheckListBox.Items.Objects[cInd-1] := col1;
FieldsVisibleChecklistBox.Checked[cInd]:=col2.selectedForGrid;
FieldsVisibleChecklistBox.Checked[cInd-1]:=col1.selectedForGrid;
FieldsVisibleCheckListBox.Selected[cInd]:= false;
FieldsVisibleCheckListBox.Selected[cInd-1] := true;
end;
procedure TMainForm.Grid_DownBtnClick(Sender: TObject);
var cInd,vInd : Integer;
view: TView;
col1,col2 :SW_Column;
begin
cInd := FieldsVisibleCheckListBox.ItemIndex;
if (cInd = -1) or (cInd+1 >= FieldsVisibleCheckListBox.Items.Count) then exit;
vInd := ViewComboBox.ItemIndex;
assert(vInd <> -1);
view := TView(ViewComboBox.Items.Objects[vInd]);
col1 := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd]);
col2 := SW_Column(FieldsVisibleCheckListBox.Items.Objects[cInd+1]);
view.ExchangeGridSortedColumns(cInd, cInd+1);
//FieldsVisibleCheckListBox.Items.Exchange(cInd, cInd-1);
FieldsVisibleCheckListBox.Items[cInd] := col2.table.name+'.'+col2.name;
FieldsVisibleCheckListBox.Items[cInd+1] := col1.Table.name+'.'+col1.name;
FieldsVisibleCheckListBox.Items.Objects[cInd] := col2;
FieldsVisibleCheckListBox.Items.Objects[cInd+1] := col1;
FieldsVisibleChecklistBox.Checked[cInd]:=col2.selectedForGrid;
FieldsVisibleChecklistBox.Checked[cInd+1]:=col1.selectedForGrid;
FieldsVisibleCheckListBox.Selected[cInd]:= false;
FieldsVisibleCheckListBox.Selected[cInd+1] := true;
end;
//*****************************************
//**********5th page(Form)*****************
//*****************************************
procedure TMainForm.RefreshFormTab;
var stringList : TStringList;
tmpGrp : TGroup;
begin
//show all groups in the GroupComboBox
stringList := TStringList.Create;
Output.GetGroupNames(stringList);
Form_GroupComboBox.Items.Assign(stringList);
if (stringList.Count = 0) then
begin
Form_GroupComboBox.Enabled := false;
Form_GroupComboBox.ItemIndex:= -1;
end
else
begin
Form_GroupComboBox.Enabled := true;
if ((Form_GroupComboBox.ItemIndex = -1) or (Form_GroupComboBox.ItemIndex >= Form_GroupComboBox.Items.Count)) then Form_GroupComboBox.ItemIndex:= 0;
end;
stringList.Clear;
//if no group is chosen
if (Form_GroupComboBox.ItemIndex = -1) then
begin
Form_ViewComboBox.Clear;
Form_ViewComboBox.Enabled := False;
end
else
begin
tmpGrp := TGroup(Form_GroupComboBox.Items.Objects[Form_GroupComboBox.ItemIndex]);
Output.GetViewNamesFromGroup(tmpGrp,stringList);
Form_ViewComboBox.Items.Assign(stringList);
if (stringList.Count = 0) then
begin
Form_ViewComboBox.Enabled := false;
Form_ViewComboBox.ItemIndex := -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -