Changeset 14 for trunk/UAcronym.pas
- Timestamp:
- Apr 28, 2016, 10:56:31 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UAcronym.pas
r13 r14 15 15 Name: string; 16 16 URL: string; 17 end; 18 19 TAcronymSources = class(TObjectList) 20 17 21 end; 18 22 … … 57 61 TAcronymCategory = class 58 62 Name: string; 59 Acronym s: TObjectList; // TObjectList<TAcronym>63 AcronymMeanings: TAcronymMeanings; 60 64 constructor Create; 61 65 destructor Destroy; override; … … 86 90 TAcronymDb = class 87 91 FileName: string; 88 Sources: T ObjectList; // TObjectList<TAcronymSource>92 Sources: TAcronymSources; 89 93 Acronyms: TAcronyms; 90 94 Categories: TAcronymCategories; … … 148 152 149 153 destructor TAcronymMeaning.Destroy; 150 begin 154 var 155 I: Integer; 156 begin 157 for I := 0 to Categories.Count - 1 do 158 TAcronymCategory(Categories[I]).AcronymMeanings.Remove(Self); 151 159 FreeAndNil(Categories); 152 160 inherited Destroy; … … 205 213 begin 206 214 Clear; 207 for I := 0 to Strings.Count - 1 do 215 for I := 0 to Strings.Count - 1 do begin 208 216 Add(TAcronymCategory(Strings.Objects[I])); 217 end; 209 218 end; 210 219 … … 227 236 constructor TAcronymCategory.Create; 228 237 begin 229 Acronym s := TObjectList.Create(False);238 AcronymMeanings := TAcronymMeanings.Create(False); 230 239 end; 231 240 232 241 destructor TAcronymCategory.Destroy; 233 begin 234 FreeAndNil(Acronyms); 242 var 243 I: Integer; 244 begin 245 for I := 0 to AcronymMeanings.Count - 1 do 246 TAcronymMeaning(AcronymMeanings[I]).Categories.Remove(Self); 247 FreeAndNil(AcronymMeanings); 235 248 inherited Destroy; 236 249 end; … … 240 253 constructor TAcronymDb.Create; 241 254 begin 242 Sources := T ObjectList.Create;255 Sources := TAcronymSources.Create; 243 256 Acronyms := TAcronyms.Create; 244 257 Categories := TAcronymCategories.Create; 245 TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Internet';246 TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Software';247 TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Chat';248 258 end; 249 259 … … 260 270 F: TStringList; 261 271 Line: TStringList; 262 C ontext: TStringList;272 CategoryStrings: TStringList; 263 273 NewAcronym: TAcronym; 264 274 NewMeaning: TAcronymMeaning; 265 275 I: Integer; 266 276 J: Integer; 267 AcronymC ontext: TAcronymCategory;277 AcronymCategory: TAcronymCategory; 268 278 begin 269 279 Self.FileName := FileName; … … 272 282 Line := TStringList.Create; 273 283 Line.StrictDelimiter := True; 274 C ontext:= TStringList.Create;275 C ontext.Delimiter := ';';284 CategoryStrings := TStringList.Create; 285 CategoryStrings.Delimiter := ';'; 276 286 try 277 287 F.LoadFromFile(FileName); … … 291 301 NewAcronym.Meanings.Add(NewMeaning); 292 302 end; 293 C ontext.DelimitedText := Line[2];294 for J := 0 to C ontext.Count - 1 do begin295 AcronymC ontext := Categories.SearchByName(Context[J]);296 if not Assigned(AcronymC ontext) then begin297 AcronymC ontext:= TAcronymCategory.Create;298 AcronymC ontext.Name := Context[J];299 Categories.Add(AcronymC ontext);303 CategoryStrings.DelimitedText := Line[2]; 304 for J := 0 to CategoryStrings.Count - 1 do begin 305 AcronymCategory := Categories.SearchByName(CategoryStrings[J]); 306 if not Assigned(AcronymCategory) then begin 307 AcronymCategory := TAcronymCategory.Create; 308 AcronymCategory.Name := CategoryStrings[J]; 309 Categories.Add(AcronymCategory); 300 310 end; 301 NewMeaning.Categories.Add(AcronymContext); 311 NewMeaning.Categories.Add(AcronymCategory); 312 AcronymCategory.AcronymMeanings.Add(NewMeaning); 302 313 end; 303 314 end; … … 305 316 F.Free; 306 317 Line.Free; 307 C ontext.Free;318 CategoryStrings.Free; 308 319 end; 309 320 Modified := False;
Note:
See TracChangeset
for help on using the changeset viewer.