@ -25,6 +25,8 @@ type
@@ -25,6 +25,8 @@ type
{ TScanForm }
TScanForm = class(TForm)
dropBtn: TButton;
OpenDir: TButton;
extButton: TButton;
Swap: TButton;
DropButton: TButton;
@ -44,10 +46,12 @@ type
@@ -44,10 +46,12 @@ type
TypeSelector: TComboBox;
procedure BaseFolderClick(Sender: TObject);
procedure dropBtnClick(Sender: TObject);
procedure extButtonClick(Sender: TObject);
procedure DropButtonClick(Sender: TObject);
procedure CalendarChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OpenDirClick(Sender: TObject);
procedure ProductChange(Sender: TObject);
procedure DestinationChange(Sender: TObject);
procedure OriginChange(Sender: TObject);
@ -57,8 +61,11 @@ type
@@ -57,8 +61,11 @@ type
procedure TypeSelectorChange(Sender: TObject);
function ExportConfig(): string;
function ExportOptions(dropDown: TComboBox): string;
procedure ComboKey(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure UpdateFolder();
procedure MixLocations(d1: TComboBox; d2: TComboBox; d3: TComboBox);
procedure DeleteStationFrom(combo: TComboBox; station: string; defaultName : string);
procedure DeleteStation(station : string);
private
date: TDateTime;
function getSize(): TPoint;
@ -161,11 +168,25 @@ end;
@@ -161,11 +168,25 @@ end;
function TScanForm.ExportOptions(dropDown: TComboBox): string;
var
list: TStringList;
tx: string;
item, current: string;
i: integer;
drop: Boolean;
begin
// make sure the current text appears in future lists
tx := dropDown.Text;
if (tx[1] <> ' ') then dropDown.Items.Add(tx);
item := dropDown.Text;
drop := item.StartsWith(' ');
if drop then
begin
i := 0;
while i < dropDown.Items.Count do
begin
item := Trim(item);
current := Trim(dropDown.Items[i]);
if current = item then dropDown.Items.Delete(i) else i := i+1;
end;
end else dropDown.Items.Add(item);
// create a StringList to sort and concatenate
list := TStringList.Create;
list.StrictDelimiter := True;
@ -181,6 +202,30 @@ begin
@@ -181,6 +202,30 @@ begin
Result := list.DelimitedText
end;
procedure TScanForm.ComboKey(Sender: TObject; var Key: Word; Shift: TShiftState);
var
combo : TComboBox;
index : integer;
tx : string;
begin
if key = 40 then
begin
if TObject(Sender) is TComboBox then
begin
combo := TComboBox(Sender);
tx := combo.Text;
for index := 0 to combo.Items.Count-1 do
begin
if combo.Items[index].StartsWith(tx,true) then
begin
combo.ItemIndex:=index-1;
Exit;
end;
end;
end;
end;
end;
procedure TScanForm.TypeSelectorChange(Sender: TObject);
var
state: boolean;
@ -276,6 +321,20 @@ begin
@@ -276,6 +321,20 @@ begin
UpdateFolder();
end;
procedure addItemsTo(combo: TComboBox; line: String);
var
parts: TStringArray;
fixed, part: string;
begin
parts := line.Split(',');
for part in parts do
begin
fixed := part.Replace('"','');
if (fixed <> '') then combo.Items.Add(fixed);
end;
end;
procedure TScanForm.FormCreate(Sender: TObject);
var
filename: String;
@ -297,33 +356,27 @@ begin
@@ -297,33 +356,27 @@ begin
line:=line.Substring(7);
BaseFolder.Caption:=line;
end;
if line.StartsWith('types:') then
begin
line := line.Substring(6);
TypeSelector.Items.AddStrings(line.Split(','));
end;
if line.StartsWith('items:') then
begin
line := line.Substring(6);
Product.Items.AddStrings(line.Split(','));
end;
if line.StartsWith('sizes:') then
begin
line := line.Substring(6);
PicSize.Items.AddStrings(line.Split(','));
end;
if line.StartsWith('types:') then addItemsTo(TypeSelector,line.Substring(6));
if line.StartsWith('items:') then addItemsTo(Product,line.Substring(6));
if line.StartsWith('sizes:') then addItemsTo(PicSize,line.Substring(6));
if line.StartsWith('locations:') then
begin
line := line.Substring(10);
Origin.Items.AddStrings(line.Split(',') );
Destination.Items.AddStrings(line.Split(',') );
Stop.Items.AddStrings(line.Split(',') );
addItemsTo(Origin,line);
addItemsTo(Destination,line);
addItemsTo(Stop,line);
end;
end
finally
end;
end;
procedure TScanForm.OpenDirClick(Sender: TObject);
begin
WriteLn(BaseFolder.Caption);
fpSystem('gio open "'+BaseFolder.Caption+'"');
end;
procedure TScanForm.BaseFolderClick(Sender: TObject);
begin
BaseFolderDialog.FileName:=BaseFolder.Caption;
@ -331,6 +384,48 @@ begin
@@ -331,6 +384,48 @@ begin
BaseFolder.Caption := BaseFolderDialog.FileName;
end;
procedure TScanForm.DeleteStationFrom(combo: TComboBox; station : string; defaultName : string);
var
index : integer;
begin
index := combo.Items.IndexOf(station);
if index > -1 then
begin
combo.Items.Delete(index);
combo.Text := defaultName;
end;
end;
procedure TScanForm.DeleteStation(station : string);
begin
DeleteStationFrom(Origin,station,'Start');
DeleteStationFrom(Stop,station,'Zwischenhalt');
DeleteStationFrom(Destination,station,'Ziel');
end;
procedure TScanForm.dropBtnClick(Sender: TObject);
var
tx : string;
begin
tx := TypeSelector.Text;
if (tx <> 'Herkunft') and (tx <> 'Ticket') then
begin
TypeSelector.Items.Delete(TypeSelector.ItemIndex);
TypeSelector.Text := 'Herkunft';
end;
tx := Product.Text;
if Product.Enabled and (tx <> 'Produkt') then
begin
Product.Items.Delete(Product.ItemIndex);
Product.Text := 'Produkt';
end;
if Origin.Enabled and (Origin.Text <> 'Start') then deleteStation(Origin.Text);
if Stop.Enabled and (Stop.Text <> 'Zwischenhalt') then deleteStation(Stop.Text);
if Destination.Enabled and (Destination.Text <> 'Ziel') then deleteStation(Destination.Text);
end;
procedure TScanForm.extButtonClick(Sender: TObject);
var
cmd: string;
@ -353,16 +448,11 @@ var
@@ -353,16 +448,11 @@ var
tx: string;
begin
tx := FormatDateTime('YYYY-MM-DD', date) + ' - ';
if (Product.Enabled and (Product.Tag > 0) and not( Product.Text = '') and not (Product.Text = 'Produkt')) then
tx := tx + Trim(Product.Text) + ' von ';
if (TypeSelector.Tag > 0) then
tx := tx + Trim(TypeSelector.Text);
if (Origin.Enabled and (Origin.Tag > 0)) then
tx := tx + ': ' + Trim(Origin.Text);
if (Stop.Enabled and (Stop.Tag > 0) and not (Stop.Text = '')and not (Stop.Text = 'Zwischenhalt')) then
tx := tx + ' - ' + Trim(Stop.Text);
if (Destination.Enabled and (Destination.Tag > 0)) then
tx := tx + ' - ' + Trim(Destination.Text);
if (Product.Enabled and (Product.Tag > 0) and not( Product.Text = '') and not (Product.Text = 'Produkt')) then tx := tx + Trim(Product.Text) + ' von ';
if (TypeSelector.Tag > 0) then tx := tx + Trim(TypeSelector.Text);
if (Origin.Enabled and (Origin.Tag > 0)) then tx := tx + ': ' + Trim(Origin.Text);
if (Stop.Enabled and (Stop.Tag > 0) and not (Stop.Text = '')and not (Stop.Text = 'Zwischenhalt')) then tx := tx + ' - ' + Trim(Stop.Text);
if (Destination.Enabled and (Destination.Tag > 0)) then tx := tx + ' - ' + Trim(Destination.Text);
FolderName.Caption := tx;
end;