Changeset 43 for trunk/Forms/UFormLoginProfile.pas
- Timestamp:
- Mar 9, 2012, 1:09:52 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormLoginProfile.pas
r42 r43 10 10 11 11 type 12 TConnectProtocol = (cpXMLRPC, cpDirect );12 TConnectProtocol = (cpXMLRPC, cpDirect, cpMySQL); 13 13 14 14 { TConnectProfile } … … 51 51 Label5: TLabel; 52 52 LabelServer: TLabel; 53 ListBox 1: TListBox;53 ListBoxProfiles: TListBox; 54 54 Panel1: TPanel; 55 55 SpinEditPort: TSpinEdit; … … 65 65 procedure FormDestroy(Sender: TObject); 66 66 procedure FormShow(Sender: TObject); 67 procedure ListBox 1SelectionChange(Sender: TObject; User: boolean);67 procedure ListBoxProfilesSelectionChange(Sender: TObject; User: boolean); 68 68 procedure SpinEditPortChange(Sender: TObject); 69 69 private … … 76 76 SProfile = 'Profile'; 77 77 SProtocolXMLRPC = 'XML-RPC'; 78 SProtocolMySQL = 'MySQL'; 79 SProtocolDirect = 'Direct'; 78 80 79 81 var 80 82 LoginProfileForm: TLoginProfileForm; 83 ProtocolTypeText: array[TConnectProtocol] of string; 84 85 procedure UpdateTranslation; 81 86 82 87 implementation … … 123 128 procedure TLoginProfileForm.ComboBoxProtocolChange(Sender: TObject); 124 129 begin 125 if ListBox1.ItemIndex <> - 1 then 126 TConnectProfile(ProfileList[ListBox1.ItemIndex]).Protocol := TConnectProtocol(ComboBoxProtocol.ItemIndex); 130 if ListBoxProfiles.ItemIndex <> - 1 then 131 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Protocol := 132 TConnectProtocol(ComboBoxProtocol.Items.Objects[ComboBoxProtocol.ItemIndex]); 127 133 end; 128 134 129 135 procedure TLoginProfileForm.EditNameChange(Sender: TObject); 130 136 begin 131 if ListBox 1.ItemIndex <> - 1 then begin132 TConnectProfile(ProfileList[ListBox 1.ItemIndex]).Name := EditName.Text;133 ListBox 1.Items[ListBox1.ItemIndex] := EditName.Text;137 if ListBoxProfiles.ItemIndex <> - 1 then begin 138 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Name := EditName.Text; 139 ListBoxProfiles.Items[ListBoxProfiles.ItemIndex] := EditName.Text; 134 140 end; 135 141 end; … … 137 143 procedure TLoginProfileForm.EditDatabaseChange(Sender: TObject); 138 144 begin 139 if ListBox 1.ItemIndex <> - 1 then140 TConnectProfile(ProfileList[ListBox 1.ItemIndex]).Database := EditDatabase.Text;145 if ListBoxProfiles.ItemIndex <> - 1 then 146 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Database := EditDatabase.Text; 141 147 end; 142 148 143 149 procedure TLoginProfileForm.EditServerChange(Sender: TObject); 144 150 begin 145 if ListBox 1.ItemIndex <> - 1 then146 TConnectProfile(ProfileList[ListBox 1.ItemIndex]).HostName := EditServer.Text;151 if ListBoxProfiles.ItemIndex <> - 1 then 152 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).HostName := EditServer.Text; 147 153 end; 148 154 … … 156 162 begin 157 163 ProfileList.AddNew(TConnectProfile.Create); 158 ListBox 1.Items.AddObject(TConnectProfile(ProfileList.Last).Name,164 ListBoxProfiles.Items.AddObject(TConnectProfile(ProfileList.Last).Name, 159 165 TConnectProfile(ProfileList.Last)); 160 166 end; … … 162 168 procedure TLoginProfileForm.ButtonDeleteClick(Sender: TObject); 163 169 begin 164 if ListBox 1.ItemIndex <> - 1 then begin165 ProfileList.Delete(ListBox 1.ItemIndex);166 ListBox 1.Items.Delete(ListBox1.ItemIndex);170 if ListBoxProfiles.ItemIndex <> - 1 then begin 171 ProfileList.Delete(ListBoxProfiles.ItemIndex); 172 ListBoxProfiles.Items.Delete(ListBoxProfiles.ItemIndex); 167 173 end; 168 174 end; … … 178 184 begin 179 185 ComboBoxProtocol.Clear; 180 ComboBoxProtocol.Items.Add(SProtocolXMLRPC); 186 for I := 0 to Integer(High(ProtocolTypeText)) do 187 ComboBoxProtocol.Items.AddObject(ProtocolTypeText[TConnectProtocol(I)], 188 Pointer(I)); 181 189 182 190 MainForm.PersistentForm.Load(Self); 183 191 ProfileList.Assign(Core.Profiles); 184 ProfileList.FillStrings(ListBox 1.Items);185 if Core.LastProfile < ListBox 1.Count then186 ListBox 1.ItemIndex := Core.LastProfile;187 if (ListBox 1.Items.Count > 0) and188 (ListBox 1.ItemIndex = -1) then ListBox1.ItemIndex := 0;189 end; 190 191 procedure TLoginProfileForm.ListBox 1SelectionChange(Sender: TObject;192 ProfileList.FillStrings(ListBoxProfiles.Items); 193 if Core.LastProfile < ListBoxProfiles.Count then 194 ListBoxProfiles.ItemIndex := Core.LastProfile; 195 if (ListBoxProfiles.Items.Count > 0) and 196 (ListBoxProfiles.ItemIndex = -1) then ListBoxProfiles.ItemIndex := 0; 197 end; 198 199 procedure TLoginProfileForm.ListBoxProfilesSelectionChange(Sender: TObject; 192 200 User: boolean); 193 201 begin 194 if ListBox 1.ItemIndex <> -1 then195 with TConnectProfile(ProfileList[ListBox 1.ItemIndex]) do begin202 if ListBoxProfiles.ItemIndex <> -1 then 203 with TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]) do begin 196 204 EditServer.Text := HostName; 197 205 EditDatabase.Text := Database; 198 ComboBoxProtocol.ItemIndex := Integer(Protocol);206 ComboBoxProtocol.ItemIndex := ComboBoxProtocol.Items.IndexOfObject(Pointer(Protocol)); 199 207 SpinEditPort.Value := Port; 200 208 EditName.Text := Name; … … 204 212 procedure TLoginProfileForm.SpinEditPortChange(Sender: TObject); 205 213 begin 206 if ListBox 1.ItemIndex <> - 1 then207 TConnectProfile(ProfileList[ListBox 1.ItemIndex]).Port := SpinEditPort.Value;214 if ListBoxProfiles.ItemIndex <> - 1 then 215 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Port := SpinEditPort.Value; 208 216 end; 209 217 … … 281 289 end; 282 290 291 procedure UpdateTranslation; 292 begin 293 ProtocolTypeText[cpXMLRPC] := SProtocolXMLRPC; 294 ProtocolTypeText[cpMySQL] := SProtocolMySQL; 295 ProtocolTypeText[cpDirect] := SProtocolDirect; 296 end; 297 283 298 end. 284 299
Note:
See TracChangeset
for help on using the changeset viewer.