working on selectors
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
<Unit1>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ComponentName Value="ScanForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
|
||||
@@ -15,7 +15,7 @@ uses
|
||||
begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.CreateForm(TScanForm, ScanForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
||||
@@ -3,24 +3,22 @@
|
||||
<ProjectSession>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="4">
|
||||
<Units Count="5">
|
||||
<Unit0>
|
||||
<Filename Value="Belegscanner.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<WindowIndex Value="-1"/>
|
||||
<TopLine Value="-1"/>
|
||||
<CursorPos X="-1" Y="-1"/>
|
||||
<CursorPos X="17" Y="10"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ComponentName Value="ScanForm"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="51"/>
|
||||
<CursorPos X="51" Y="86"/>
|
||||
<TopLine Value="136"/>
|
||||
<CursorPos X="22" Y="183"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
@@ -28,8 +26,8 @@
|
||||
<Unit2>
|
||||
<Filename Value="/usr/share/fpcsrc/3.0.4/rtl/objpas/sysutils/syshelph.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="252"/>
|
||||
<CursorPos X="14" Y="292"/>
|
||||
<TopLine Value="119"/>
|
||||
<CursorPos X="14" Y="151"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
@@ -40,139 +38,136 @@
|
||||
<CursorPos X="29" Y="215"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="/usr/lib/lazarus/1.8.2/lcl/stdctrls.pp"/>
|
||||
<UnitName Value="StdCtrls"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="389"/>
|
||||
<CursorPos X="14" Y="437"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="64" Column="35"/>
|
||||
<Caret Line="55" Column="16"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="59" Column="26" TopLine="3"/>
|
||||
<Caret Line="51" Column="38" TopLine="2"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="71" Column="42" TopLine="10"/>
|
||||
<Caret Line="56" Column="19" TopLine="25"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="49" Column="3" TopLine="8"/>
|
||||
<Caret Line="51" Column="54"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="56" Column="3" TopLine="8"/>
|
||||
<Caret Line="117" Column="77" TopLine="112"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="46" TopLine="6"/>
|
||||
<Caret Line="141" Column="148" TopLine="114"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="25" Column="15"/>
|
||||
<Caret Line="13" Column="140"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="68" Column="27" TopLine="11"/>
|
||||
<Caret Column="13"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="65" Column="3" TopLine="14"/>
|
||||
<Caret Line="19" Column="53" TopLine="38"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="70" Column="6" TopLine="14"/>
|
||||
<Caret Line="165" Column="35" TopLine="120"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="49" Column="33" TopLine="17"/>
|
||||
<Caret Line="145" Column="74" TopLine="128"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="47" Column="26" TopLine="13"/>
|
||||
<Caret Line="71" Column="52" TopLine="31"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="81" Column="61" TopLine="28"/>
|
||||
<Caret Line="161" Column="117" TopLine="127"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="68" Column="3" TopLine="28"/>
|
||||
<Caret Line="151" Column="70" TopLine="118"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="67" Column="19" TopLine="28"/>
|
||||
<Caret Line="34" Column="160" TopLine="26"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="49" Column="29" TopLine="27"/>
|
||||
<Caret Line="100" Column="100" TopLine="76"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="47" Column="3" TopLine="14"/>
|
||||
<Caret Line="163" Column="12" TopLine="126"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="48" TopLine="13"/>
|
||||
<Caret Line="158" Column="14" TopLine="126"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="49" Column="10" TopLine="16"/>
|
||||
<Caret Line="164" Column="3" TopLine="125"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="81" Column="26" TopLine="28"/>
|
||||
<Caret Line="158" Column="13" TopLine="125"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="64" Column="85" TopLine="4"/>
|
||||
<Caret Line="166" Column="5" TopLine="125"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="66" Column="85" TopLine="4"/>
|
||||
<Caret Line="164" Column="38" TopLine="130"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="84" Column="21" TopLine="38"/>
|
||||
<Caret Line="166" Column="46" TopLine="130"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="95" Column="81" TopLine="38"/>
|
||||
<Caret Line="171" TopLine="130"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="96" Column="25" TopLine="42"/>
|
||||
<Caret Line="172" Column="11" TopLine="71"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="95" Column="67" TopLine="42"/>
|
||||
<Caret Line="173" Column="45" TopLine="120"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="79" Column="16" TopLine="42"/>
|
||||
<Caret Line="179" TopLine="139"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="101" Column="62" TopLine="44"/>
|
||||
<Caret Line="175" TopLine="138"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="84" Column="17" TopLine="51"/>
|
||||
<Caret Line="154" Column="5" TopLine="138"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="scanner.pas"/>
|
||||
<Caret Line="83" Column="76" TopLine="51"/>
|
||||
<Caret Line="30" Column="73"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
<Debugging>
|
||||
<BreakPoints Count="1">
|
||||
<Item1>
|
||||
<Kind Value="bpkSource"/>
|
||||
<WatchScope Value="wpsLocal"/>
|
||||
<WatchKind Value="wpkWrite"/>
|
||||
<Source Value="scanner.pas"/>
|
||||
<Line Value="127"/>
|
||||
</Item1>
|
||||
</BreakPoints>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
object Form1: TForm1
|
||||
object ScanForm: TScanForm
|
||||
Left = 2207
|
||||
Height = 95
|
||||
Top = 221
|
||||
Width = 664
|
||||
Caption = 'Form1'
|
||||
Caption = 'Belegscanner'
|
||||
ClientHeight = 95
|
||||
ClientWidth = 664
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.8.2.0'
|
||||
object DateView: TLabel
|
||||
Left = 8
|
||||
|
||||
139
scanner.pas
139
scanner.pas
@@ -10,9 +10,9 @@ uses
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
{ TScanForm }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
TScanForm = class(TForm)
|
||||
ScnaButton: TButton;
|
||||
Product: TComboBox;
|
||||
Destination: TComboBox;
|
||||
@@ -22,14 +22,19 @@ type
|
||||
dateButton: TButton;
|
||||
DateSelector: TCalendarDialog;
|
||||
DateView: TLabel;
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure ProductChange(Sender: TObject);
|
||||
procedure DestinationChange(Sender: TObject);
|
||||
procedure dateButtonClick(Sender: TObject);
|
||||
procedure OriginChange(Sender: TObject);
|
||||
procedure ScnaButtonClick(Sender: TObject);
|
||||
procedure TypeSelectorChange(Sender: TObject);
|
||||
function ExportConfig(): string;
|
||||
function ExportOptions(dropDown: TComboBox): string;
|
||||
procedure UpdateTypes();
|
||||
procedure UpdateFolder();
|
||||
procedure MixLocations(d1: TComboBox; d2: TComboBox);
|
||||
private
|
||||
date: TDateTime;
|
||||
public
|
||||
@@ -37,15 +42,58 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
ScanForm: TScanForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
{ TScanForm }
|
||||
|
||||
procedure TForm1.TypeSelectorChange(Sender: TObject);
|
||||
procedure TScanForm.MixLocations(d1: TComboBox; d2: TComboBox);
|
||||
var
|
||||
list: TStringList;
|
||||
begin
|
||||
list := TStringList.Create;
|
||||
list.Sorted := True;
|
||||
d1.Items.Add(d1.Text);
|
||||
d2.Items.Add(d2.Text);
|
||||
list.Assign(d1.Items);
|
||||
list.AddStrings(d2.Items);
|
||||
d1.Items.Assign(list);
|
||||
d2.Items.Assign(list);
|
||||
end;
|
||||
|
||||
function TScanForm.ExportConfig(): string;
|
||||
begin
|
||||
Result := 'types:' + ExportOptions(TypeSelector) + #13;
|
||||
Result := Result + 'items:' + ExportOptions(Product) + #13;
|
||||
MixLocations(Origin, Destination);
|
||||
Result := Result + 'locations:' + ExportOPtions(Origin) + #13;
|
||||
end;
|
||||
|
||||
function TScanForm.ExportOptions(dropDown: TComboBox): string;
|
||||
var
|
||||
list: TStringList;
|
||||
begin
|
||||
// make sure the current text appears in future lists
|
||||
dropDown.Items.Add(dropDown.Text);
|
||||
// create a StringList to sort and concatenate
|
||||
list := TStringList.Create;
|
||||
list.StrictDelimiter := True;
|
||||
list.Sorted := True;
|
||||
|
||||
// put all items in the list, will sort and remove duplicates
|
||||
list.Assign(dropDown.Items);
|
||||
|
||||
// update dropdown
|
||||
dropDown.Items.Assign(list);
|
||||
|
||||
// return json array
|
||||
Result := list.DelimitedText
|
||||
end;
|
||||
|
||||
procedure TScanForm.TypeSelectorChange(Sender: TObject);
|
||||
var
|
||||
state: boolean;
|
||||
begin
|
||||
@@ -59,69 +107,106 @@ begin
|
||||
UpdateFolder();
|
||||
end;
|
||||
|
||||
procedure TForm1.dateButtonClick(Sender: TObject);
|
||||
procedure TScanForm.dateButtonClick(Sender: TObject);
|
||||
begin
|
||||
DateSelector.Execute;
|
||||
date := DateSelector.Date;
|
||||
DateView.Caption := FormatDateTime('YYYY-MM-DD', date);
|
||||
UpdateTypes();
|
||||
TypeSelector.enabled := true;
|
||||
TypeSelector.Enabled := True;
|
||||
UpdateFolder();
|
||||
end;
|
||||
|
||||
procedure TForm1.OriginChange(Sender: TObject);
|
||||
procedure TScanForm.OriginChange(Sender: TObject);
|
||||
begin
|
||||
Origin.Tag := 1;
|
||||
UpdateFolder();
|
||||
end;
|
||||
|
||||
procedure TForm1.ScnaButtonClick(Sender: TObject);
|
||||
procedure TScanForm.ScnaButtonClick(Sender: TObject);
|
||||
var
|
||||
config: TFileStream;
|
||||
filename: String;
|
||||
filename: string;
|
||||
json: string;
|
||||
begin
|
||||
filename := GetEnvironmentVariable('HOME') + '/.config/belegscanner.conf';
|
||||
FolderName.Caption:=filename;
|
||||
json := ExportConfig();
|
||||
try
|
||||
config := TFilestream.Create(filename, fmCreate);
|
||||
config.Write(filename[1],filename.Length);
|
||||
config.Write(json[1], json.Length);
|
||||
finally
|
||||
config.Free;
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
procedure TForm1.DestinationChange(Sender: TObject);
|
||||
procedure TScanForm.DestinationChange(Sender: TObject);
|
||||
begin
|
||||
Destination.Tag := 1;
|
||||
UpdateFolder();
|
||||
end;
|
||||
|
||||
procedure TForm1.ProductChange(Sender: TObject);
|
||||
procedure TScanForm.ProductChange(Sender: TObject);
|
||||
begin
|
||||
Product.Tag := 1;
|
||||
UpdateFolder();
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateFolder();
|
||||
procedure TScanForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
tx: String;
|
||||
filename: String;
|
||||
lines: TStringList;
|
||||
line: String;
|
||||
index: integer;
|
||||
begin
|
||||
tx := FormatDateTime('YYYY-MM-DD',date);
|
||||
if (TypeSelector.Tag > 0) then tx := tx + ' - ' + TypeSelector.Text;
|
||||
if (Origin.Enabled AND (Origin.Tag > 0)) then tx := tx + ': ' + Origin.Text;
|
||||
if (Destination.Enabled AND (Destination.Tag > 0)) then tx := tx + ' - ' + Destination.Text;
|
||||
if (Product.Enabled AND (Product.Tag > 0)) then tx := tx + ' von ' + Product.Text;
|
||||
filename := GetEnvironmentVariable('HOME') + '/.config/belegscanner.conf';
|
||||
lines := TStringList.Create;
|
||||
try
|
||||
lines.LoadFromFile(filename);
|
||||
for index := 0 to lines.Count-1 do
|
||||
begin
|
||||
line:=lines.Strings[index];
|
||||
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('locations:') then
|
||||
begin
|
||||
line := line.Substring(10);
|
||||
Origin.Items.AddStrings(line.Split(','));
|
||||
Destination.Items.AddStrings(line.Split(','));
|
||||
end;
|
||||
end
|
||||
finally
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TScanForm.UpdateFolder();
|
||||
var
|
||||
tx: string;
|
||||
begin
|
||||
tx := FormatDateTime('YYYY-MM-DD', date) + ' - ';
|
||||
if (Product.Enabled and (Product.Tag > 0)) then
|
||||
tx := tx + Product.Text + ' von ';
|
||||
if (TypeSelector.Tag > 0) then
|
||||
tx := tx + TypeSelector.Text;
|
||||
if (Origin.Enabled and (Origin.Tag > 0)) then
|
||||
tx := tx + ': ' + Origin.Text;
|
||||
if (Destination.Enabled and (Destination.Tag > 0)) then
|
||||
tx := tx + ' - ' + Destination.Text;
|
||||
FolderName.Caption := tx;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdateTypes();
|
||||
procedure TScanForm.UpdateTypes();
|
||||
begin
|
||||
WriteLn('Test');
|
||||
TypeSelector.Items.Clear;
|
||||
TypeSelector.Items.Add('Ticket');
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user