Changeset 31 for trunk/Forms/UMainForm.pas
- Timestamp:
- Nov 24, 2011, 10:03:48 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UMainForm.pas
r30 r31 29 29 AObjectGroupAddGroup: TAction; 30 30 AObjectGroupDelete: TAction; 31 AItemView: TAction;32 AItemEdit: TAction;33 AItemAdd: TAction;34 AItemDelete: TAction;35 31 ActionListItem: TActionList; 36 ButtonEdit: TButton;37 ButtonView: TButton;38 ButtonAdd: TButton;39 ButtonDelete: TButton;40 32 ImageListActions: TImageList; 41 33 Label1: TLabel; 42 Label2: TLabel;43 ListView1: TListView;44 34 MainMenu1: TMainMenu; 45 35 MenuItem1: TMenuItem; … … 64 54 MenuItem8: TMenuItem; 65 55 MenuItem9: TMenuItem; 56 PageControl1: TPageControl; 66 57 Panel1: TPanel; 67 58 Panel2: TPanel; … … 76 67 procedure AExitExecute(Sender: TObject); 77 68 procedure AImportStructureExecute(Sender: TObject); 78 procedure AItemAddExecute(Sender: TObject);79 procedure AItemDeleteExecute(Sender: TObject);80 procedure AItemEditExecute(Sender: TObject);81 procedure AItemViewExecute(Sender: TObject);82 69 procedure AObjectEditExecute(Sender: TObject); 83 70 procedure AObjectGroupAddGroupExecute(Sender: TObject); … … 85 72 procedure ASettingsExecute(Sender: TObject); 86 73 procedure AToggleFullscreenExecute(Sender: TObject); 87 procedure ButtonAddClick(Sender: TObject);88 74 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 89 75 procedure FormCreate(Sender: TObject); 90 76 procedure FormDestroy(Sender: TObject); 91 77 procedure FormShow(Sender: TObject); 92 procedure ListView1Data(Sender: TObject; Item: TListItem);93 procedure ListView1DblClick(Sender: TObject);94 procedure ListView1KeyPress(Sender: TObject; var Key: char);95 procedure ListView1Resize(Sender: TObject);96 procedure ListView1SelectItem(Sender: TObject; Item: TListItem;97 Selected: Boolean);98 78 procedure MenuItem17Click(Sender: TObject); 99 79 procedure MenuItem19Click(Sender: TObject); 100 80 procedure TreeView1Change(Sender: TObject; Node: TTreeNode); 81 procedure TreeView1DblClick(Sender: TObject); 101 82 private 102 83 OriginalBounds: TRect; … … 106 87 procedure SaveToRegistry; 107 88 public 108 SelectedObjectId: Integer;109 SelectedObject: TChronisObject;110 SelectedItem: Integer;111 89 PersistentForm: TPersistentForm; 112 90 TreeState: TTreeState; 113 91 Report: TReport; 92 TabForms: TListObject; // TListObject<TForm> 114 93 procedure UpdateInterface; 115 94 procedure LoadTree; 116 procedure LoadItemList;117 end; 95 procedure AddTabForm(Form: TForm); 96 end; 118 97 119 98 var … … 132 111 uses 133 112 UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo, 134 UCore, UImportStructureForm, UAboutForm, ULoginProfileForm, UChronisClientDirect; 113 UCore, UImportStructureForm, UAboutForm, ULoginProfileForm, UChronisClientDirect, 114 UItemList; 135 115 136 116 {$R *.lfm} … … 175 155 procedure TMainForm.FormCreate(Sender: TObject); 176 156 begin 157 TabForms := TListObject.Create; 158 TabForms.OwnsObjects := False; 177 159 TreeState := TTreeState.Create; 178 160 Report := TReport.Create; 179 161 Report.Base := Core.System; 180 SelectedObject := TChronisObject.Create;181 SelectedObject.Base := Core.System;182 162 PersistentForm := TPersistentForm.Create; 183 163 PersistentForm.RegistryKey := Core.RegistryKey; … … 189 169 TreeState.Free; 190 170 PersistentForm.Free; 171 TabForms.Free; 191 172 end; 192 173 193 174 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 194 175 begin 176 ADisconnect.Execute; 195 177 PersistentForm.Save(Self); 196 178 SaveToRegistry; 197 179 end; 198 180 199 procedure TMainForm.ButtonAddClick(Sender: TObject);200 begin201 202 end;203 204 procedure TMainForm.AItemViewExecute(Sender: TObject);205 begin206 if Assigned(ListView1.Selected) then207 ItemViewForm.Show;208 end;209 210 181 procedure TMainForm.AObjectEditExecute(Sender: TObject); 211 182 begin 212 if Assigned(TreeView1.Selected) then begin183 (* if Assigned(TreeView1.Selected) then begin 213 184 SelectedObjectId := 9; 214 185 SelectedItem := Integer(TreeView1.Selected.Data); 215 186 ItemEditForm.Show; 216 end; 187 end;*) 217 188 end; 218 189 … … 224 195 procedure TMainForm.AObjectGroupEditExecute(Sender: TObject); 225 196 begin 226 if Assigned(TreeView1.Selected) then begin197 (* if Assigned(TreeView1.Selected) then begin 227 198 SelectedObjectId := 8; 228 199 SelectedItem := Integer(TreeView1.Selected.Data); 229 200 ItemEditForm.Show; 230 end; 201 end;*) 231 202 end; 232 203 … … 263 234 end; 264 235 265 procedure TMainForm.AItemEditExecute(Sender: TObject);266 begin267 ItemEditForm.Show;268 end;269 270 236 procedure TMainForm.AExitExecute(Sender: TObject); 271 237 begin … … 276 242 begin 277 243 ImportStructureForm.ShowModal; 278 end;279 280 procedure TMainForm.AItemAddExecute(Sender: TObject);281 begin282 ItemAddForm.ShowModal;283 end;284 285 procedure TMainForm.AItemDeleteExecute(Sender: TObject);286 begin287 if MessageDlg(SItemDeletion, SReallyWantToDelete, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin288 289 end;290 244 end; 291 245 … … 315 269 procedure TMainForm.ADisconnectExecute(Sender: TObject); 316 270 begin 317 Core.System.Database.Disconnect; 318 TreeView1.Items.Clear; 319 ListView1.Items.Clear; 320 Core.System.Types.Clear; 321 FreeAndNil(Core.Client); 271 if Core.System.Database.Connected then begin 272 Core.System.Database.Disconnect; 273 TreeView1.Items.Clear; 274 Core.System.Types.Clear; 275 FreeAndNil(Core.Client); 276 end; 322 277 end; 323 278 324 279 procedure TMainForm.AAboutExecute(Sender: TObject); 325 280 begin 326 AboutForm.ShowModal; 281 try 282 AboutForm := TAboutForm.Create(nil); 283 AboutForm.ShowModal; 284 finally 285 FreeAndNil(AboutForm); 286 end; 327 287 end; 328 288 … … 332 292 LoadFromRegistry; 333 293 AConnect.Execute; 334 end;335 336 procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem);337 var338 I: Integer;339 begin340 if Item.Index < Report.Count then341 with TReportLine(Report[Item.Index]) do begin342 Item.Caption := Items[0];343 for I := 1 to Report.Columns.Count - 1 do344 if not TReportColumn(Report.Columns[I]).VirtualItem then begin345 Item.SubItems.Add(Items[I]);346 end;347 end;348 end;349 350 procedure TMainForm.ListView1DblClick(Sender: TObject);351 begin352 AItemViewExecute(Self);353 end;354 355 procedure TMainForm.ListView1KeyPress(Sender: TObject; var Key: char);356 begin357 if Key = #13 then AItemViewExecute(Self);358 end;359 360 procedure TMainForm.ListView1Resize(Sender: TObject);361 var362 I: Integer;363 begin364 for I := 0 to ListView1.Columns.Count - 1 do365 ListView1.Columns[I].Width := ListView1.Width div ListView1.Columns.Count;366 end;367 368 procedure TMainForm.ListView1SelectItem(Sender: TObject; Item: TListItem;369 Selected: Boolean);370 begin371 if Assigned(ListView1.Selected) then372 SelectedItem := TReportLine(Report[ListView1.Selected.Index]).Id373 else SelectedItem := 0;374 375 ButtonDelete.Enabled := Assigned(ListView1.Selected);376 ButtonView.Enabled := Assigned(ListView1.Selected);377 ButtonEdit.Enabled := Assigned(ListView1.Selected);378 294 end; 379 295 … … 395 311 if TreeView1.Selected.ImageIndex = 0 then begin 396 312 TreeView1.PopupMenu := PopupMenuObjectGroup; 397 ListView1.Visible := False;313 PageControl1.Visible := False; 398 314 end; 399 315 if TreeView1.Selected.ImageIndex = 1 then begin 400 316 TreeView1.PopupMenu := PopupMenuObject; 401 LoadItemList; 402 end; 317 //LoadItemList; 318 end; 319 end; 320 end; 321 322 procedure TMainForm.TreeView1DblClick(Sender: TObject); 323 var 324 NewItemListForm: TItemListForm; 325 begin 326 if Assigned(TreeView1.Selected) then begin 327 NewItemListForm := TItemListForm.Create(Self); 328 NewItemListForm.SelectedObject.Id := Integer(TreeView1.Selected.Data); 329 AddTabForm(NewItemListForm); 403 330 end; 404 331 end; … … 448 375 end; 449 376 450 procedure TMainForm. LoadItemList;377 procedure TMainForm.AddTabForm(Form: TForm); 451 378 var 452 NewColumn: TListColumn; 453 I: Integer; 454 begin 455 SelectedObjectId := 0; 456 if Assigned(TreeView1.Selected) then 457 with ListView1 do begin 458 Visible := True; 459 SelectedObject.Load(Integer(TreeView1.Selected.Data)); 460 Report.Load(SelectedObject); 461 462 Report.FillListColumns(Columns); 463 Items.Count := Report.Count; 464 Refresh; 465 end; 466 ListView1Resize(Self); 467 ListView1SelectItem(Self, nil, False); 379 NewTabSheet: TTabSheet; 380 begin 381 TabForms.Add(Form); 382 NewTabSheet := PageControl1.AddTabSheet; 383 NewTabSheet.DockSite := True; 384 NewTabSheet.UseDockManager := True; 385 NewTabSheet.Caption := Form.Caption; 386 Form.DragKind := dkDock; 387 Form.DragMode := dmAutomatic; 388 Form.Show; 389 Form.ManualDock(NewTabSheet); 390 PageControl1.TabIndex := PageControl1.PageCount - 1; 468 391 end; 469 392
Note:
See TracChangeset
for help on using the changeset viewer.