@@ -47,6 +47,10 @@ void ConnectionWindow::loadValuesFromConfig(const RedisClient::ConnectionConfig&
47
47
ui.connectionTimeout ->setValue (config.connectionTimeout ());
48
48
ui.executionTimeout ->setValue (config.executeTimeout ());
49
49
50
+ if (!config.keysPattern ().isEmpty ()) {
51
+ ui.keysPattern ->setText (config.keysPattern ());
52
+ }
53
+
50
54
if (config.useSshTunnel ()) {
51
55
ui.useSshTunnel ->setCheckState (Qt::Checked);
52
56
ui.sshHost ->setText (config.param <QString>(" ssh_host" ));
@@ -68,6 +72,16 @@ void ConnectionWindow::loadValuesFromConfig(const RedisClient::ConnectionConfig&
68
72
}
69
73
}
70
74
75
+ void ConnectionWindow::markFieldInvalid (QWidget* w)
76
+ {
77
+ w->setStyleSheet (" border: 1px solid red;" );
78
+ }
79
+
80
+ void ConnectionWindow::markFieldValid (QWidget* w)
81
+ {
82
+ w->setStyleSheet (" " );
83
+ }
84
+
71
85
void ConnectionWindow::OnOkButtonClick ()
72
86
{
73
87
ui.validationWarning ->hide ();
@@ -107,9 +121,8 @@ void ConnectionWindow::OnBrowseSshKeyClick()
107
121
{
108
122
QString fileName = QFileDialog::getOpenFileName (this , " Select private key file" , " " , tr (" All Files (*.*)" ));
109
123
110
- if (fileName.isEmpty ()) {
111
- return ;
112
- }
124
+ if (fileName.isEmpty ())
125
+ return ;
113
126
114
127
ui.privateKeyPath ->setText (fileName);
115
128
}
@@ -148,92 +161,85 @@ bool ConnectionWindow::isFormDataValid()
148
161
149
162
bool ConnectionWindow::isConnectionSettingsValid ()
150
163
{
151
- ui.nameEdit -> setStyleSheet ( " " );
152
- ui.hostEdit -> setStyleSheet ( " " );
164
+ markFieldValid ( ui.nameEdit );
165
+ markFieldValid ( ui.hostEdit );
153
166
154
167
bool isValid = !ui.nameEdit ->text ().isEmpty ()
155
168
&& !ui.hostEdit ->text ().isEmpty ()
156
169
&& ui.portSpinBox ->value () > 0 ;
157
170
158
- if (isValid) {
159
- return true ;
160
- }
171
+ if (isValid)
172
+ return true ;
161
173
162
- if (ui.nameEdit ->text ().isEmpty ()) {
163
- ui.nameEdit ->setStyleSheet (" border: 1px solid red;" );
164
- }
174
+ if (ui.nameEdit ->text ().isEmpty ())
175
+ markFieldInvalid (ui.nameEdit );
165
176
166
- if (ui.hostEdit ->text ().isEmpty ()) {
167
- ui.hostEdit ->setStyleSheet (" border: 1px solid red;" );
168
- }
177
+ if (ui.hostEdit ->text ().isEmpty ())
178
+ markFieldInvalid (ui.hostEdit );
169
179
170
180
return false ;
171
181
}
172
182
173
183
bool ConnectionWindow::isAdvancedSettingsValid ()
174
184
{
175
- ui.namespaceSeparator -> setStyleSheet ( " " );
185
+ markFieldValid ( ui.namespaceSeparator );
176
186
177
- bool isValid = !ui.namespaceSeparator ->text ().isEmpty ();
187
+ bool isValid = !ui.namespaceSeparator ->text ().isEmpty ()
188
+ || !ui.keysPattern ->text ().isEmpty ();
178
189
179
- if (isValid) {
180
- return true ;
181
- }
190
+ if (isValid)
191
+ return true ;
182
192
183
- if (ui.namespaceSeparator ->text ().isEmpty ()) {
184
- ui.namespaceSeparator ->setStyleSheet (" border: 1px solid red;" );
185
- }
193
+ if (ui.namespaceSeparator ->text ().isEmpty ())
194
+ markFieldInvalid (ui.namespaceSeparator );
195
+
196
+ if (ui.keysPattern ->text ().isEmpty ())
197
+ markFieldInvalid (ui.keysPattern );
186
198
187
199
return false ;
188
200
}
189
201
190
202
bool ConnectionWindow::isSshSettingsValid ()
191
203
{
192
- ui.sshHost -> setStyleSheet ( " " );
193
- ui.sshUser -> setStyleSheet ( " " );
194
- ui.sshPass -> setStyleSheet ( " " );
195
- ui.privateKeyPath -> setStyleSheet ( " " );
204
+ markFieldValid ( ui.sshHost );
205
+ markFieldValid ( ui.sshUser );
206
+ markFieldValid ( ui.sshPass );
207
+ markFieldValid ( ui.privateKeyPath );
196
208
197
- if (!isSshTunnelUsed ()) {
198
- return true ;
199
- }
209
+ if (!isSshTunnelUsed ())
210
+ return true ;
200
211
201
212
bool isValid = !ui.sshHost ->text ().isEmpty ()
202
213
&& !ui.sshUser ->text ().isEmpty ()
203
214
&& !(ui.sshPass ->text ().isEmpty () && ui.privateKeyPath ->text ().isEmpty ())
204
215
&& (
205
216
(ui.sshPasswordGroup ->isChecked () && !ui.sshPass ->text ().isEmpty ())
206
217
||
207
- (ui.sshKeysGroup ->isChecked () && !ui.privateKeyPath ->text ().isEmpty () && QFile::exists (ui.privateKeyPath ->text ()))
218
+ (ui.sshKeysGroup ->isChecked () && !ui.privateKeyPath ->text ().isEmpty ()
219
+ && QFile::exists (ui.privateKeyPath ->text ()))
208
220
)
209
221
&& ui.sshPort ->value () > 0 ;
210
222
211
- if (isValid) {
212
- return true ;
213
- }
223
+ if (isValid)
224
+ return true ;
214
225
215
- if (ui.sshHost ->text ().isEmpty ()) {
216
- ui.sshHost ->setStyleSheet (" border: 1px solid red;" );
217
- }
226
+ if (ui.sshHost ->text ().isEmpty ())
227
+ markFieldInvalid (ui.sshHost );
218
228
219
- if (ui.sshUser ->text ().isEmpty ()) {
220
- ui.sshUser ->setStyleSheet (" border: 1px solid red;" );
221
- }
229
+ if (ui.sshUser ->text ().isEmpty ())
230
+ markFieldInvalid (ui.sshUser );
222
231
223
- if (ui.sshPasswordGroup ->isChecked () && ui.sshPass ->text ().isEmpty ()) {
224
- ui.sshPass ->setStyleSheet (" border: 1px solid red;" );
225
- }
232
+ if (ui.sshPasswordGroup ->isChecked () && ui.sshPass ->text ().isEmpty ())
233
+ markFieldInvalid (ui.sshPass );
226
234
227
- if (ui.sshKeysGroup ->isChecked () && ui.privateKeyPath ->text ().isEmpty ()) {
228
- ui.privateKeyPath ->setStyleSheet (" border: 1px solid red;" );
229
- }
235
+ if (ui.sshKeysGroup ->isChecked () && ui.privateKeyPath ->text ().isEmpty ())
236
+ markFieldInvalid (ui.privateKeyPath );
230
237
231
238
if (!ui.sshPasswordGroup ->isChecked () && !ui.sshKeysGroup ->isChecked ()) {
232
- ui.sshPass -> setStyleSheet ( " border: 1px solid red; " );
233
- ui.privateKeyPath -> setStyleSheet ( " border: 1px solid red; " );
239
+ markFieldInvalid ( ui.sshPass );
240
+ markFieldInvalid ( ui.privateKeyPath );
234
241
}
235
242
236
-
237
243
return false ;
238
244
}
239
245
@@ -244,26 +250,28 @@ bool ConnectionWindow::isSshTunnelUsed()
244
250
245
251
RedisClient::ConnectionConfig ConnectionWindow::getConectionConfigFromFormData ()
246
252
{
247
- RedisClient::ConnectionConfig conf (ui.hostEdit ->text ().trimmed (),ui.nameEdit ->text ().trimmed (), ui.portSpinBox ->value ());
253
+ RedisClient::ConnectionConfig conf (ui.hostEdit ->text ().trimmed (),
254
+ ui.nameEdit ->text ().trimmed (),
255
+ ui.portSpinBox ->value ());
248
256
249
257
conf.setParam (" namespace_separator" , ui.namespaceSeparator ->text ());
250
258
conf.setParam (" timeout_connect" , ui.connectionTimeout ->value () * 1000 );
251
259
conf.setParam (" timeout_execute" , ui.executionTimeout ->value () * 1000 );
252
260
253
- if (!ui.authEdit ->text ().isEmpty ()) {
254
- conf.setParam (" auth" , ui.authEdit ->text ());
255
- }
261
+ if (!ui.authEdit ->text ().isEmpty ())
262
+ conf.setParam (" auth" , ui.authEdit ->text ());
263
+
264
+ if (!ui.keysPattern ->text ().isEmpty ())
265
+ conf.setParam (" keys_pattern" , ui.keysPattern ->text ());
256
266
257
267
if (isSshTunnelUsed ()) {
258
268
conf.setSshTunnelSettings (
259
269
ui.sshHost ->text ().trimmed (),
260
270
ui.sshUser ->text ().trimmed (),
261
271
(ui.sshPasswordGroup ->isChecked ()? ui.sshPass ->text ().trimmed () : " " ),
262
272
ui.sshPort ->value (),
263
- (ui.sshKeysGroup ->isChecked () ? ui.privateKeyPath ->text ().trimmed () : " " )
264
- );
273
+ (ui.sshKeysGroup ->isChecked () ? ui.privateKeyPath ->text ().trimmed () : " " ));
265
274
}
266
275
267
276
return conf;
268
277
}
269
-
0 commit comments