Changeset 3
- Timestamp:
- Feb 2, 2011, 2:14:37 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 lib 2 2 FreePascalManager.exe 3 SourceList.xml 4 Config.xml
-
- Property svn:ignore
-
trunk/FreePascalManager.lpi
r2 r3 30 30 </local> 31 31 </RunParams> 32 <RequiredPackages Count=" 1">32 <RequiredPackages Count="2"> 33 33 <Item1> 34 <PackageName Value="synapse"/> 35 </Item1> 36 <Item2> 34 37 <PackageName Value="LCL"/> 35 </Item 1>38 </Item2> 36 39 </RequiredPackages> 37 <Units Count=" 7">40 <Units Count="11"> 38 41 <Unit0> 39 42 <Filename Value="FreePascalManager.lpr"/> 40 43 <IsPartOfProject Value="True"/> 41 44 <UnitName Value="FreePascalManager"/> 42 <UsageCount Value="2 2"/>45 <UsageCount Value="27"/> 43 46 </Unit0> 44 47 <Unit1> 45 48 <Filename Value="UMainForm.pas"/> 46 49 <IsPartOfProject Value="True"/> 47 <ComponentName Value=" Form1"/>50 <ComponentName Value="MainForm"/> 48 51 <ResourceBaseClass Value="Form"/> 49 52 <UnitName Value="UMainForm"/> 50 <IsVisibleTab Value="True"/>51 53 <EditorIndex Value="0"/> 52 54 <WindowIndex Value="0"/> 53 <TopLine Value="1 17"/>54 <CursorPos X=" 45" Y="122"/>55 <UsageCount Value="2 2"/>55 <TopLine Value="1"/> 56 <CursorPos X="33" Y="18"/> 57 <UsageCount Value="27"/> 56 58 <Loaded Value="True"/> 57 59 <LoadedDesigner Value="True"/> … … 63 65 <ResourceBaseClass Value="Form"/> 64 66 <UnitName Value="UOptions"/> 65 <EditorIndex Value=" 1"/>66 <WindowIndex Value="0"/> 67 <TopLine Value=" 1"/>68 <CursorPos X=" 3" Y="9"/>69 <UsageCount Value="2 2"/>67 <EditorIndex Value="2"/> 68 <WindowIndex Value="0"/> 69 <TopLine Value="37"/> 70 <CursorPos X="29" Y="52"/> 71 <UsageCount Value="27"/> 70 72 <Loaded Value="True"/> 71 73 <LoadedDesigner Value="True"/> … … 75 77 <IsPartOfProject Value="True"/> 76 78 <UnitName Value="UInstance"/> 77 <EditorIndex Value=" 2"/>78 <WindowIndex Value="0"/> 79 <TopLine Value=" 23"/>80 <CursorPos X=" 3" Y="44"/>81 <UsageCount Value="2 2"/>79 <EditorIndex Value="4"/> 80 <WindowIndex Value="0"/> 81 <TopLine Value="4"/> 82 <CursorPos X="1" Y="18"/> 83 <UsageCount Value="27"/> 82 84 <Loaded Value="True"/> 83 85 </Unit3> … … 86 88 <IsPartOfProject Value="True"/> 87 89 <UnitName Value="USource"/> 88 <EditorIndex Value="3"/> 89 <WindowIndex Value="0"/> 90 <TopLine Value="16"/> 91 <CursorPos X="1" Y="40"/> 92 <UsageCount Value="22"/> 90 <IsVisibleTab Value="True"/> 91 <EditorIndex Value="5"/> 92 <WindowIndex Value="0"/> 93 <TopLine Value="49"/> 94 <CursorPos X="14" Y="54"/> 95 <UsageCount Value="27"/> 93 96 <Loaded Value="True"/> 94 97 </Unit4> … … 98 101 <TopLine Value="1670"/> 99 102 <CursorPos X="14" Y="1683"/> 100 <UsageCount Value="1 1"/>103 <UsageCount Value="10"/> 101 104 </Unit5> 102 105 <Unit6> … … 106 109 <TopLine Value="5"/> 107 110 <CursorPos X="20" Y="47"/> 108 <UsageCount Value=" 10"/>111 <UsageCount Value="9"/> 109 112 </Unit6> 113 <Unit7> 114 <Filename Value="E:\Programy\Lazarus\0.9.31_2.5.1\fpc\2.5.1\source\packages\fcl-xml\src\dom.pp"/> 115 <UnitName Value="DOM"/> 116 <EditorIndex Value="1"/> 117 <WindowIndex Value="0"/> 118 <TopLine Value="233"/> 119 <CursorPos X="14" Y="246"/> 120 <UsageCount Value="13"/> 121 <Loaded Value="True"/> 122 </Unit7> 123 <Unit8> 124 <Filename Value="E:\Projekty\Knihovny\Free Pascal\synapse\httpsend.pas"/> 125 <UnitName Value="httpsend"/> 126 <EditorIndex Value="3"/> 127 <WindowIndex Value="0"/> 128 <TopLine Value="749"/> 129 <CursorPos X="3" Y="753"/> 130 <UsageCount Value="11"/> 131 <Loaded Value="True"/> 132 </Unit8> 133 <Unit9> 134 <Filename Value="FPCSourceList.xml"/> 135 <WindowIndex Value="0"/> 136 <TopLine Value="58"/> 137 <CursorPos X="72" Y="81"/> 138 <UsageCount Value="21"/> 139 <DefaultSyntaxHighlighter Value="XML"/> 140 </Unit9> 141 <Unit10> 142 <Filename Value="IDESourceList.xml"/> 143 <WindowIndex Value="0"/> 144 <TopLine Value="1"/> 145 <CursorPos X="46" Y="49"/> 146 <UsageCount Value="20"/> 147 <DefaultSyntaxHighlighter Value="XML"/> 148 </Unit10> 110 149 </Units> 111 <JumpHistory Count="30" HistoryIndex="2 8">150 <JumpHistory Count="30" HistoryIndex="29"> 112 151 <Position1> 113 <Filename Value="U MainForm.pas"/>114 <Caret Line=" 165" Column="36" TopLine="144"/>152 <Filename Value="USource.pas"/> 153 <Caret Line="79" Column="1" TopLine="65"/> 115 154 </Position1> 116 155 <Position2> 117 <Filename Value="U MainForm.pas"/>118 <Caret Line=" 102" Column="9" TopLine="87"/>156 <Filename Value="USource.pas"/> 157 <Caret Line="80" Column="1" TopLine="65"/> 119 158 </Position2> 120 159 <Position3> 121 <Filename Value="U MainForm.pas"/>122 <Caret Line=" 127" Column="33" TopLine="106"/>160 <Filename Value="USource.pas"/> 161 <Caret Line="78" Column="36" TopLine="65"/> 123 162 </Position3> 124 163 <Position4> 125 <Filename Value="U MainForm.pas"/>126 <Caret Line=" 96" Column="1" TopLine="83"/>164 <Filename Value="USource.pas"/> 165 <Caret Line="77" Column="1" TopLine="65"/> 127 166 </Position4> 128 167 <Position5> 129 <Filename Value="U MainForm.pas"/>130 <Caret Line=" 97" Column="19" TopLine="89"/>168 <Filename Value="USource.pas"/> 169 <Caret Line="79" Column="1" TopLine="65"/> 131 170 </Position5> 132 171 <Position6> 133 <Filename Value="U MainForm.pas"/>134 <Caret Line=" 106" Column="17" TopLine="93"/>172 <Filename Value="USource.pas"/> 173 <Caret Line="80" Column="1" TopLine="65"/> 135 174 </Position6> 136 175 <Position7> 137 <Filename Value="U MainForm.pas"/>138 <Caret Line=" 127" Column="54" TopLine="114"/>176 <Filename Value="USource.pas"/> 177 <Caret Line="85" Column="1" TopLine="65"/> 139 178 </Position7> 140 179 <Position8> 141 <Filename Value="U MainForm.pas"/>142 <Caret Line=" 159" Column="16" TopLine="137"/>180 <Filename Value="USource.pas"/> 181 <Caret Line="78" Column="17" TopLine="65"/> 143 182 </Position8> 144 183 <Position9> 145 <Filename Value="U MainForm.pas"/>146 <Caret Line=" 97" Column="8" TopLine="84"/>184 <Filename Value="UOptions.pas"/> 185 <Caret Line="48" Column="16" TopLine="37"/> 147 186 </Position9> 148 187 <Position10> 149 <Filename Value="U MainForm.pas"/>150 <Caret Line=" 3" Column="14" TopLine="1"/>188 <Filename Value="UOptions.pas"/> 189 <Caret Line="52" Column="29" TopLine="37"/> 151 190 </Position10> 152 191 <Position11> 153 <Filename Value="U MainForm.pas"/>154 <Caret Line=" 152" Column="17" TopLine="130"/>192 <Filename Value="USource.pas"/> 193 <Caret Line="76" Column="19" TopLine="59"/> 155 194 </Position11> 156 195 <Position12> 157 <Filename Value="U MainForm.pas"/>158 <Caret Line=" 161" Column="30" TopLine="138"/>196 <Filename Value="USource.pas"/> 197 <Caret Line="85" Column="1" TopLine="72"/> 159 198 </Position12> 160 199 <Position13> 161 200 <Filename Value="USource.pas"/> 162 <Caret Line=" 25" Column="45" TopLine="1"/>201 <Caret Line="97" Column="54" TopLine="78"/> 163 202 </Position13> 164 203 <Position14> 165 204 <Filename Value="USource.pas"/> 166 <Caret Line=" 35" Column="13" TopLine="13"/>205 <Caret Line="83" Column="1" TopLine="78"/> 167 206 </Position14> 168 207 <Position15> 169 208 <Filename Value="USource.pas"/> 170 <Caret Line=" 24" Column="23" TopLine="11"/>209 <Caret Line="84" Column="1" TopLine="78"/> 171 210 </Position15> 172 211 <Position16> 173 212 <Filename Value="USource.pas"/> 174 <Caret Line="8 " Column="29" TopLine="1"/>213 <Caret Line="85" Column="1" TopLine="78"/> 175 214 </Position16> 176 215 <Position17> 177 <Filename Value="U MainForm.pas"/>178 <Caret Line=" 45" Column="25" TopLine="11"/>216 <Filename Value="USource.pas"/> 217 <Caret Line="86" Column="1" TopLine="78"/> 179 218 </Position17> 180 219 <Position18> 181 <Filename Value="U MainForm.pas"/>182 <Caret Line=" 61" Column="21" TopLine="48"/>220 <Filename Value="USource.pas"/> 221 <Caret Line="87" Column="1" TopLine="78"/> 183 222 </Position18> 184 223 <Position19> 185 <Filename Value="U MainForm.pas"/>186 <Caret Line=" 73" Column="49" TopLine="69"/>224 <Filename Value="USource.pas"/> 225 <Caret Line="88" Column="1" TopLine="78"/> 187 226 </Position19> 188 227 <Position20> 189 <Filename Value="U MainForm.pas"/>190 <Caret Line="89" Column=" 35" TopLine="75"/>228 <Filename Value="USource.pas"/> 229 <Caret Line="89" Column="1" TopLine="78"/> 191 230 </Position20> 192 231 <Position21> 193 <Filename Value="U Instance.pas"/>194 <Caret Line=" 23" Column="21" TopLine="1"/>232 <Filename Value="USource.pas"/> 233 <Caret Line="90" Column="1" TopLine="78"/> 195 234 </Position21> 196 235 <Position22> 197 <Filename Value="U MainForm.pas"/>198 <Caret Line=" 77" Column="1" TopLine="65"/>236 <Filename Value="USource.pas"/> 237 <Caret Line="91" Column="1" TopLine="78"/> 199 238 </Position22> 200 239 <Position23> 201 <Filename Value="U MainForm.pas"/>202 <Caret Line=" 78" Column="1" TopLine="71"/>240 <Filename Value="USource.pas"/> 241 <Caret Line="92" Column="1" TopLine="78"/> 203 242 </Position23> 204 243 <Position24> 205 <Filename Value="U Instance.pas"/>206 <Caret Line=" 24" Column="20" TopLine="11"/>244 <Filename Value="USource.pas"/> 245 <Caret Line="93" Column="1" TopLine="78"/> 207 246 </Position24> 208 247 <Position25> 209 <Filename Value="U MainForm.pas"/>210 <Caret Line="94" Column=" 56" TopLine="81"/>248 <Filename Value="USource.pas"/> 249 <Caret Line="94" Column="1" TopLine="78"/> 211 250 </Position25> 212 251 <Position26> 213 <Filename Value="U Instance.pas"/>214 <Caret Line=" 25" Column="22" TopLine="11"/>252 <Filename Value="USource.pas"/> 253 <Caret Line="95" Column="1" TopLine="78"/> 215 254 </Position26> 216 255 <Position27> 217 <Filename Value="U MainForm.pas"/>218 <Caret Line="96" Column=" 56" TopLine="83"/>256 <Filename Value="USource.pas"/> 257 <Caret Line="96" Column="1" TopLine="78"/> 219 258 </Position27> 220 259 <Position28> 221 <Filename Value="U MainForm.pas"/>222 <Caret Line=" 44" Column="15" TopLine="30"/>260 <Filename Value="USource.pas"/> 261 <Caret Line="99" Column="1" TopLine="78"/> 223 262 </Position28> 224 263 <Position29> 225 <Filename Value="U MainForm.pas"/>226 <Caret Line="1 19" Column="19" TopLine="117"/>264 <Filename Value="USource.pas"/> 265 <Caret Line="100" Column="1" TopLine="79"/> 227 266 </Position29> 228 267 <Position30> 229 <Filename Value="U MainForm.pas"/>230 <Caret Line=" 44" Column="15" TopLine="31"/>268 <Filename Value="USource.pas"/> 269 <Caret Line="99" Column="30" TopLine="80"/> 231 270 </Position30> 232 271 </JumpHistory> … … 254 293 </CompilerOptions> 255 294 <Debugging> 295 <BreakPoints Count="3"> 296 <Item1> 297 <Source Value="UMainForm.pas"/> 298 <Line Value="240"/> 299 </Item1> 300 <Item2> 301 <Source Value="USource.pas"/> 302 <Line Value="83"/> 303 </Item2> 304 <Item3> 305 <Source Value="USource.pas"/> 306 <Line Value="52"/> 307 </Item3> 308 </BreakPoints> 256 309 <Exceptions Count="3"> 257 310 <Item1> -
trunk/FreePascalManager.lpr
r2 r3 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UMainForm, UOptions, UInstance, USource 10 Forms, UMainForm, UOptions, UInstance, USource, synapse 11 11 { you can add units after this }; 12 12 … … 15 15 begin 16 16 Application.Initialize; 17 Application.CreateForm(T Form1, Form1);17 Application.CreateForm(TMainForm, MainForm); 18 18 Application.CreateForm(TOptionsForm, OptionsForm); 19 19 Application.Run; -
trunk/UMainForm.lfm
r2 r3 1 object Form1: TForm11 object MainForm: TMainForm 2 2 Left = 266 3 3 Height = 363 -
trunk/UMainForm.pas
r2 r3 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 9 StdCtrls, ActnList, Contnrs, USource, UInstance, UOptions, 10 DOM, XMLWrite, XMLRead ;10 DOM, XMLWrite, XMLRead, HTTPSend; 11 11 12 12 const 13 13 ConfigFileName = 'Config.xml'; 14 SourceURL = 'http://tv.zdechov.net/fpc/SourceList.xml'; 14 15 15 16 type 16 17 17 { T Form1}18 19 T Form1= class(TForm)18 { TMainForm } 19 20 TMainForm = class(TForm) 20 21 AAdd: TAction; 21 22 ACompile: TAction; … … 51 52 Instances: TObjectList; 52 53 Sources: TSourceList; 53 end; 54 end; 54 55 55 56 var 56 Form1: TForm1;57 MainForm: TMainForm; 57 58 58 59 implementation … … 60 61 {$R *.lfm} 61 62 62 { T Form1}63 64 procedure T Form1.FormCreate(Sender: TObject);63 { TMainForm } 64 65 procedure TMainForm.FormCreate(Sender: TObject); 65 66 begin 66 67 Instances := TObjectList.Create; 67 68 Sources := TSourceList.Create; 68 end; 69 70 procedure TForm1.AAddExecute(Sender: TObject); 69 LoadInstanceList; 70 end; 71 72 procedure TMainForm.AAddExecute(Sender: TObject); 71 73 begin 72 74 OptionsForm.ShowModal; 73 75 end; 74 76 75 procedure T Form1.ACompileExecute(Sender: TObject);77 procedure TMainForm.ACompileExecute(Sender: TObject); 76 78 begin 77 79 if Assigned(ListView1.Selected) then … … 82 84 end; 83 85 84 procedure T Form1.ARemoveExecute(Sender: TObject);86 procedure TMainForm.ARemoveExecute(Sender: TObject); 85 87 begin 86 88 if Assigned(ListView1.Selected) then … … 91 93 end; 92 94 93 procedure T Form1.AStartExecute(Sender: TObject);95 procedure TMainForm.AStartExecute(Sender: TObject); 94 96 begin 95 97 if Assigned(ListView1.Selected) then … … 100 102 end; 101 103 102 procedure T Form1.AUpdateExecute(Sender: TObject);104 procedure TMainForm.AUpdateExecute(Sender: TObject); 103 105 begin 104 106 if Assigned(ListView1.Selected) then … … 109 111 end; 110 112 111 procedure TForm1.FormDestroy(Sender: TObject); 112 begin 113 procedure TMainForm.FormDestroy(Sender: TObject); 114 begin 115 SaveInstanceList; 113 116 Instances.Free; 114 117 Sources.Free; 115 118 end; 116 119 117 procedure T Form1.FormShow(Sender: TObject);120 procedure TMainForm.FormShow(Sender: TObject); 118 121 begin 119 122 ListView1SelectItem(nil, nil, False); 120 123 end; 121 124 122 procedure T Form1.ListView1Data(Sender: TObject; Item: TListItem);125 procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem); 123 126 begin 124 127 if Item.Index < Instances.Count then … … 131 134 end; 132 135 133 procedure T Form1.ListView1SelectItem(Sender: TObject; Item: TListItem;136 procedure TMainForm.ListView1SelectItem(Sender: TObject; Item: TListItem; 134 137 Selected: Boolean); 135 138 begin … … 141 144 end; 142 145 143 procedure T Form1.ReloadList;146 procedure TMainForm.ReloadList; 144 147 begin 145 148 ListView1.Items.Count := Instances.Count; … … 147 150 end; 148 151 149 procedure T Form1.LoadInstanceList;152 procedure TMainForm.LoadInstanceList; 150 153 var 151 154 Doc: TXMLDocument; … … 157 160 Child: TDOMNode; 158 161 begin 162 if FileExistsUTF8(ConfigFileName) then 159 163 try 160 164 ReadXMLFile(Doc, UTF8Decode(ConfigFileName)); … … 177 181 if Assigned(NewNode) then 178 182 SubversionURL := UTF8Encode(string(NewNode.TextContent)); 179 NewNode := Doc.DocumentElement.FindNode('Version ');180 if Assigned(NewNode) then 181 Version := UTF8Encode(string(NewNode.TextContent));182 NewNode := Doc.DocumentElement.FindNode('V ariation');183 if Assigned(NewNode) then 184 V ariation:= UTF8Encode(string(NewNode.TextContent));183 NewNode := Doc.DocumentElement.FindNode('VersionNumber'); 184 if Assigned(NewNode) then 185 VersionNumber := UTF8Encode(string(NewNode.TextContent)); 186 NewNode := Doc.DocumentElement.FindNode('VersionType'); 187 if Assigned(NewNode) then 188 VersionType := UTF8Encode(string(NewNode.TextContent)); 185 189 NewNode := Doc.DocumentElement.FindNode('SourceType'); 186 190 if Assigned(NewNode) then … … 227 231 end; 228 232 229 procedure T Form1.SaveInstanceList;233 procedure TMainForm.SaveInstanceList; 230 234 var 231 235 I: Integer; … … 270 274 AppendChild(NewNode); 271 275 end; 272 AppendChild( RootNode);276 AppendChild(NewNode); 273 277 274 278 NewNode := OwnerDocument.CreateElement('Sources'); … … 285 289 NewNode2.TextContent := UTF8Decode(SubversionURL); 286 290 AppendChild(NewNode); 287 NewNode2 := OwnerDocument.CreateElement('Version ');288 NewNode2.TextContent := UTF8Decode(Version );289 AppendChild(NewNode); 290 NewNode2 := OwnerDocument.CreateElement('V ariation');291 NewNode2.TextContent := UTF8Decode(V ariation);291 NewNode2 := OwnerDocument.CreateElement('VersionType'); 292 NewNode2.TextContent := UTF8Decode(VersionType); 293 AppendChild(NewNode); 294 NewNode2 := OwnerDocument.CreateElement('VersionNumber'); 295 NewNode2.TextContent := UTF8Decode(VersionNumber); 292 296 AppendChild(NewNode); 293 297 NewNode2 := OwnerDocument.CreateElement('SourceType'); … … 295 299 AppendChild(NewNode); 296 300 end; 297 AppendChild( RootNode);301 AppendChild(NewNode); 298 302 end; 299 303 WriteXMLFile(Doc, UTF8Decode(ConfigFileName)); … … 303 307 end; 304 308 309 procedure DownloadFile(const Url, PathToSaveTo: string); 310 var 311 fs: TFileStream; 312 begin 313 fs := TFileStream.Create(PathToSaveTo, fmOpenWrite or fmCreate); 314 try 315 HttpGetBinary(Url, fs); 316 finally 317 fs.Free; 318 end; 319 end; 320 305 321 end. 306 322 -
trunk/UOptions.lfm
r2 r3 102 102 TabOrder = 3 103 103 end 104 object ButtonUpdateSource: TButton 105 Left = 10 106 Height = 25 107 Top = 381 108 Width = 75 109 Caption = 'Update list' 110 OnClick = ButtonUpdateSourceClick 111 TabOrder = 4 112 end 104 113 end -
trunk/UOptions.pas
r2 r3 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls ;9 ComCtrls, DOM, XMLWrite, XMLRead, HTTPSend; 10 10 11 11 type … … 14 14 15 15 TOptionsForm = class(TForm) 16 ButtonUpdateSource: TButton; 16 17 ButtonCancel: TButton; 17 18 ButtonOk: TButton; … … 20 21 ListView1: TListView; 21 22 ListView2: TListView; 23 procedure ButtonUpdateSourceClick(Sender: TObject); 22 24 private 23 { private declarations }25 procedure ReloadList; 24 26 public 25 27 { public declarations } … … 33 35 {$R *.lfm} 34 36 37 uses 38 UMainForm; 39 40 { TOptionsForm } 41 42 procedure TOptionsForm.ButtonUpdateSourceClick(Sender: TObject); 43 var 44 fs: TFileStream; 45 begin 46 fs := TFileStream.Create(ExtractFileName(SourceURL), fmOpenWrite or fmCreate); 47 try 48 HttpGetBinary(SourceURL, fs); 49 finally 50 fs.Free; 51 end; 52 MainForm.Sources.UpdateFormFile(ExtractFileName(SourceURL)); 53 ReloadList; 54 end; 55 56 procedure TOptionsForm.ReloadList; 57 begin 58 ListView1.Items.Count := MainForm.Sources.Count; 59 ListView1.Refresh; 60 end; 61 35 62 end. 36 63 -
trunk/USource.pas
r2 r3 6 6 7 7 uses 8 Classes, SysUtils, Contnrs; 8 Classes, SysUtils, Contnrs, FileUtil, 9 DOM, XMLWrite, XMLRead, HTTPSend; 9 10 10 11 type 11 12 TSourceType = (stFPC, stIDE); 13 14 { TSource } 12 15 13 16 TSource = class … … 15 18 Name: string; 16 19 SubversionURL: string; 17 Version : string;18 V ariation: string;20 VersionNumber: string; 21 VersionType: string; 19 22 SourceType: TSourceType; 23 procedure Assign(Source: TSource); 20 24 end; 21 25 … … 24 28 TSourceList = class(TObjectList) 25 29 function FindById(Id: Integer): TSource; 30 procedure UpdateFormFile(FileName: string); 26 31 end; 27 32 28 33 implementation 34 35 { TSource } 36 37 procedure TSource.Assign(Source: TSource); 38 begin 39 Id := Source.Id; 40 Name := Source.Name; 41 VersionNumber := Source.VersionNumber; 42 VersionType := Source.VersionType; 43 SubversionURL := Source.SubversionURL; 44 SourceType := Source.SourceType; 45 end; 29 46 30 47 { TSourceList } … … 40 57 end; 41 58 59 procedure TSourceList.UpdateFormFile(FileName: string); 60 var 61 Doc: TXMLDocument; 62 NewNode: TDOMNode; 63 NewSubNode: TDOMNode; 64 I: Integer; 65 NewSource: TSource; 66 Child: TDOMNode; 67 ExistedSource: TSource; 68 begin 69 if FileExistsUTF8(FileName) then 70 try 71 ReadXMLFile(Doc, UTF8Decode(FileName)); 72 73 NewNode := Doc.DocumentElement.FindNode('Items'); 74 Child := NewNode.FirstChild; 75 while Assigned(Child) do 76 with Child do begin 77 try 78 NewSource := TSource.Create; 79 with NewSource do begin 80 NewSubNode := Child.FindNode('Name'); 81 if Assigned(NewSubNode) then 82 Name := UTF8Encode(string(NewSubNode.TextContent)); 83 NewSubNode := Child.FindNode('Id'); 84 if Assigned(NewSubNode) then 85 Id := StrToInt(NewSubNode.TextContent); 86 NewSubNode := Child.FindNode('SubversionURL'); 87 if Assigned(NewSubNode) then 88 SubversionURL := UTF8Encode(string(NewSubNode.TextContent)); 89 NewSubNode := Child.FindNode('VersionNumber'); 90 if Assigned(NewSubNode) then 91 VersionNumber := UTF8Encode(string(NewSubNode.TextContent)); 92 NewSubNode := Child.FindNode('VersionType'); 93 if Assigned(NewSubNode) then 94 VersionType := UTF8Encode(string(NewSubNode.TextContent)); 95 NewSubNode := Child.FindNode('SourceType'); 96 if Assigned(NewSubNode) then 97 SourceType := TSourceType(StrToInt(NewSubNode.TextContent)); 98 end; 99 ExistedSource := FindById(NewSource.Id); 100 if Assigned(ExistedSource) then begin 101 ExistedSource.Assign(NewSource); 102 end else begin 103 Add(NewSource); 104 FreeAndNil(NewSource); 105 end; 106 finally 107 NewSource.Free; 108 end; 109 Child := Child.NextSibling; 110 end; 111 finally 112 Doc.Free; 113 end; 114 end; 115 42 116 end. 43 117
Note:
See TracChangeset
for help on using the changeset viewer.