optionslimits editable comboboxes
Eduard Kalinowski
10 years ago
928 | 928 | Previous |
929 | 929 | Назад |
930 | 930 | Next |
931 | Вперед | |
931 | Далее | |
932 | 932 | URLs |
933 | 933 | URLs |
934 | 934 | Warning |
222 | 222 | } |
223 | 223 | |
224 | 224 | if (msgBox == NULL) { |
225 | // qDebug() << "not found dialog" << ticon; | |
225 | // qDebug() << "not found dialog" << ticon; | |
226 | 226 | return 0; |
227 | 227 | } |
228 | 228 | |
1168 | 1168 | profile_code(v); |
1169 | 1169 | // qDebug() << "save" << v; |
1170 | 1170 | s->setValue((*iopt).name, v); |
1171 | } else { | |
1171 | } | |
1172 | ||
1173 | if ((*iopt).type == FLOAT) { | |
1174 | if ((*iopt).value.toFloat() != -1) { | |
1175 | float fTmp = (*iopt).value.toFloat(); | |
1176 | QString fTxt; | |
1177 | fTxt = QString().sprintf("%4.2f", fTmp); | |
1178 | s->setValue((*iopt).name, (LLint)( fTxt.toFloat() * 1024 * 1024)); | |
1179 | } else { | |
1180 | s->setValue((*iopt).name, ""); | |
1181 | } | |
1182 | } | |
1183 | ||
1184 | if ((*iopt).type == INTEGER) { | |
1172 | 1185 | if ((*iopt).value.toInt() != -1) { |
1173 | 1186 | s->setValue((*iopt).name, (*iopt).value.toInt()); |
1174 | 1187 | } else { |
1200 | 1213 | profile_decode(tStr); |
1201 | 1214 | // qDebug() << "load" << tStr; |
1202 | 1215 | (*iopt).value = tStr; |
1216 | ||
1217 | continue; | |
1218 | } | |
1219 | ||
1220 | if ((*iopt).type == FLOAT) { | |
1221 | bool iOk; | |
1222 | tFloat = s->value((*iopt).name, (*iopt).value).toFloat(&iOk); | |
1223 | ||
1224 | if (iOk == true) { | |
1225 | (*iopt).value = (tFloat / (1024.0 * 1024.0)); // overwrite the default value if right | |
1226 | } | |
1203 | 1227 | |
1204 | 1228 | continue; |
1205 | 1229 | } |
1429 | 1453 | "CurrentAction", INTEGER, 0 |
1430 | 1454 | }; |
1431 | 1455 | prOptions << (options) { |
1432 | "MaxHtml", INTEGER, 0 | |
1433 | }; | |
1434 | prOptions << (options) { | |
1435 | "MaxOther", INTEGER, 0 | |
1436 | }; | |
1437 | prOptions << (options) { | |
1438 | "MaxAll", INTEGER, 0 | |
1456 | "MaxHtml", FLOAT, -1 | |
1457 | }; | |
1458 | prOptions << (options) { | |
1459 | "MaxOther", FLOAT, -1 | |
1460 | }; | |
1461 | prOptions << (options) { | |
1462 | "MaxAll", FLOAT, -1 | |
1439 | 1463 | }; |
1440 | 1464 | prOptions << (options) { |
1441 | 1465 | "MaxWait", INTEGER, 0 |
1444 | 1468 | "MaxTime", INTEGER, -1 |
1445 | 1469 | }; |
1446 | 1470 | prOptions << (options) { |
1447 | "MaxRate", INTEGER, -1 | |
1471 | "MaxRate", FLOAT, -1 | |
1448 | 1472 | }; |
1449 | 1473 | prOptions << (options) { |
1450 | 1474 | "MaxConn", INTEGER, -1 |
2977 | 3001 | } |
2978 | 3002 | |
2979 | 3003 | |
3004 | void HTTraQt::SetProfile(QString variName, float val) | |
3005 | { | |
3006 | QVector<options>::iterator iopt; | |
3007 | ||
3008 | if (variName.length() < 1) { | |
3009 | return; | |
3010 | } | |
3011 | ||
3012 | for (iopt = prOptions.begin(); iopt != prOptions.end(); ++iopt) { | |
3013 | if ((*iopt).name == variName) { | |
3014 | if ((*iopt).type != FLOAT) { | |
3015 | qDebug() << "Wrong type!" << (*iopt).name; | |
3016 | break; | |
3017 | } | |
3018 | ||
3019 | (*iopt).value = val; | |
3020 | break; | |
3021 | } | |
3022 | } | |
3023 | } | |
3024 | ||
3025 | ||
2980 | 3026 | void HTTraQt::SetProfile(QString variName, int val) |
2981 | 3027 | { |
2982 | 3028 | QVector<options>::iterator iopt; |
3015 | 3061 | } |
3016 | 3062 | |
3017 | 3063 | (*iopt).value = val; |
3064 | break; | |
3065 | } | |
3066 | } | |
3067 | } | |
3068 | ||
3069 | ||
3070 | void HTTraQt::GetProfile(QString variName, float &val) | |
3071 | { | |
3072 | QVector<options>::iterator iopt; | |
3073 | ||
3074 | if (variName.length() < 1) { | |
3075 | return; | |
3076 | } | |
3077 | ||
3078 | for (iopt = prOptions.begin(); iopt != prOptions.end(); ++iopt) { | |
3079 | if ((*iopt).name == variName) { | |
3080 | if ((*iopt).type != FLOAT) { | |
3081 | qDebug() << "Wrong type!" << (*iopt).name; | |
3082 | break; | |
3083 | } | |
3084 | ||
3085 | val = (*iopt).value.toFloat(); | |
3018 | 3086 | break; |
3019 | 3087 | } |
3020 | 3088 | } |
3214 | 3282 | } |
3215 | 3283 | |
3216 | 3284 | // maxfile_nonhtml |
3217 | GetProfile("MaxOther", n); | |
3218 | ||
3219 | if (n != 0) { | |
3220 | opt->maxfile_nonhtml = (LLint)n * 1024 * 1024; | |
3285 | GetProfile("MaxOther", nf); | |
3286 | ||
3287 | if (nf != 0) { | |
3288 | opt->maxfile_nonhtml = (LLint)(nf * 1024 * 1024); | |
3221 | 3289 | } else { |
3222 | 3290 | opt->maxfile_nonhtml = -1; |
3223 | 3291 | } |
3224 | 3292 | |
3225 | 3293 | // maxfile_html |
3226 | GetProfile("MaxHtml", n); | |
3227 | ||
3228 | if (n != 0) { | |
3229 | opt->maxfile_html = (LLint)n * 1024 * 1024; | |
3294 | GetProfile("MaxHtml", nf); | |
3295 | ||
3296 | if (nf != 0) { | |
3297 | opt->maxfile_html = (LLint)nf * 1024 * 1024; | |
3230 | 3298 | } else { |
3231 | 3299 | opt->maxfile_html = -1; |
3232 | 3300 | } |
3233 | 3301 | |
3234 | 3302 | // maxsite |
3235 | GetProfile("MaxAll", n); | |
3236 | ||
3237 | if (n != 0) { | |
3238 | opt->maxsite = (LLint)n * 1024 * 1024; | |
3303 | GetProfile("MaxAll", nf); | |
3304 | ||
3305 | if (nf != 0) { | |
3306 | opt->maxsite = (LLint)(nf * 1024 * 1024); | |
3239 | 3307 | } else { |
3240 | 3308 | opt->maxsite = -1; |
3241 | 3309 | } |
3277 | 3345 | } |
3278 | 3346 | |
3279 | 3347 | // maxrate |
3280 | GetProfile("MaxRate", n); | |
3281 | ||
3282 | if (n >= 0) { | |
3283 | opt->maxrate = n * 1024 * 1024; | |
3348 | GetProfile("MaxRate", nf); | |
3349 | ||
3350 | if (nf >= 0) { | |
3351 | opt->maxrate = (int)(nf * 1024 * 1024); | |
3284 | 3352 | } else { |
3285 | 3353 | opt->maxrate = -1; |
3286 | 3354 | } |
3347 | 3415 | { |
3348 | 3416 | QString st; |
3349 | 3417 | int n; |
3418 | float nf; | |
3350 | 3419 | int n1; |
3351 | 3420 | char choixdeb; |
3352 | 3421 | int action; |
3662 | 3731 | cmdOpt += filter; |
3663 | 3732 | |
3664 | 3733 | //sizemax |
3665 | GetProfile("MaxAll", n); | |
3734 | GetProfile("MaxAll", nf); | |
3666 | 3735 | |
3667 | 3736 | if (n > 0) { |
3668 | cmdOpt += ("-M" + QString::number(n * 1024 * 1024) + " "); | |
3737 | cmdOpt += ("-M" + QString::number((LLint)(nf * 1024 * 1024)) + " "); | |
3669 | 3738 | } |
3670 | 3739 | |
3671 | 3740 | //pausebytes |
3675 | 3744 | cmdOpt += ("-G" + QString::number(n) + " "); |
3676 | 3745 | } |
3677 | 3746 | |
3678 | GetProfile("MaxHtml", n); | |
3679 | GetProfile("MaxOther", n1); | |
3680 | ||
3681 | if (n >= 0 || n1 >= 0) { | |
3747 | float nf1; | |
3748 | GetProfile("MaxHtml", nf); | |
3749 | GetProfile("MaxOther", nf1); | |
3750 | ||
3751 | if (nf >= 0 || nf1 >= 0) { | |
3682 | 3752 | cmdOpt += "-m"; |
3683 | 3753 | |
3684 | if (n1 > 0) { | |
3685 | cmdOpt += QString::number(n * 1024 * 1024); | |
3754 | if (nf1 > 0) { | |
3755 | cmdOpt += QString::number((LLint)(nf1 * 1024 * 1024)); | |
3686 | 3756 | } else { |
3687 | 3757 | cmdOpt += "0"; |
3688 | 3758 | } |
3689 | 3759 | |
3690 | if (n > 0) { | |
3691 | cmdOpt += ("," + QString::number(n * 1024 * 1024)); | |
3760 | if (nf > 0) { | |
3761 | cmdOpt += ("," + QString::number((LLint)(nf * 1024 * 1024))); | |
3692 | 3762 | } else { |
3693 | 3763 | cmdOpt += ",0"; |
3694 | 3764 | } |
3770 | 3840 | cmdOpt += ("-E" + QString::number(n) + " "); // max timeout |
3771 | 3841 | } |
3772 | 3842 | |
3773 | GetProfile("MaxRate", n); | |
3774 | ||
3775 | if (n >= 0) { | |
3776 | cmdOpt += ("-A" + QString::number(n * 1024 * 1024) + " "); // max rate | |
3843 | GetProfile("MaxRate", nf); | |
3844 | ||
3845 | if (nf >= 0) { | |
3846 | cmdOpt += ("-A" + QString::number((int)(nf * 1024 * 1024)) + " "); // max rate | |
3777 | 3847 | } |
3778 | 3848 | |
3779 | 3849 | // maxConnections = 0; |
156 | 156 | void writeSettings(bool global); |
157 | 157 | void writeGUISettings(void); |
158 | 158 | |
159 | void SetProfile(QString variName, float val); | |
159 | 160 | void SetProfile(QString variName, int val); |
160 | 161 | void SetProfile(QString variName, const QString &val); |
161 | 162 | |
162 | 163 | void GetProfile(QString variName, int &val); |
164 | void GetProfile(QString variName, float &val); | |
163 | 165 | void GetProfile(QString variName, QString &val); |
164 | 166 | void clearStatsBuffer(void); |
165 | 167 | void setFontForWidgets(void); |
423 | 423 | "Use this capture tool for links that can only be accessed through forms or javascript code", // 412 |
424 | 424 | "Choose language according to preference", // 413 |
425 | 425 | "Catch URL!", // 414 |
426 | "Please set temporary browser proxy settings to the following values (Copy/Paste Proxy Address and Port).\n" | |
426 | "Please set temporary browser proxy settings to the following values (Copy/Paste Proxy Address and Port).\n" | |
427 | 427 | "Then click on the Form SUBMIT button in your browser page, or click on the specific link you want to capture.", // 415 |
428 | 428 | "This will send the desired link from your browser to HTTraQt.", // 416 |
429 | 429 | "Abort", // 417 |
23 | 23 | #include "../main/includes/httraqt.h" |
24 | 24 | #include "includes/OptionsDialog.h" |
25 | 25 | |
26 | ||
26 | ||
27 | 27 | OptionsDialog::OptionsDialog(QWidget* parent, Qt::WFlags fl) |
28 | 28 | : QDialog(parent, fl) |
29 | 29 | { |
30 | 30 | setupUi(this); |
31 | 31 | |
32 | 32 | this->parent = (HTTraQt*)parent; |
33 | // qDebug() << "init OptionsDialog"; | |
33 | // qDebug() << "init OptionsDialog"; | |
34 | 34 | _tabTextInfos.clear(); |
35 | 35 | |
36 | 36 | QToolButton* b[] = {buttonLinks, buttonBuild, buttonRulez, buttonLimits, buttonProxy, |
37 | buttonExperts, buttonMime, buttonFlow, buttonSpider, buttonBrowser, buttonLog}; | |
38 | memcpy(buttons, b, OPTION_SITES*sizeof(QToolButton*)); | |
39 | ||
40 | int h[] = {_LINKS, _BUILD, _SCANRULEZ, _LIMITS, _PROXY, _EXPERTS, _MIMETYPES, _FLOWCONTROL, | |
41 | _SPIDER, _BROWSERID, _LOGINDEX}; | |
42 | memcpy(headers, h, OPTION_SITES*sizeof(int)); | |
43 | ||
37 | buttonExperts, buttonMime, buttonFlow, buttonSpider, buttonBrowser, buttonLog | |
38 | }; | |
39 | memcpy(buttons, b, OPTION_SITES * sizeof(QToolButton*)); | |
40 | ||
41 | int h[] = {_LINKS, _BUILD, _SCANRULEZ, _LIMITS, _PROXY, _EXPERTS, _MIMETYPES, _FLOWCONTROL, | |
42 | _SPIDER, _BROWSERID, _LOGINDEX | |
43 | }; | |
44 | memcpy(headers, h, OPTION_SITES * sizeof(int)); | |
45 | ||
44 | 46 | for (int i = 0; i < OPTION_SITES; i++) { |
45 | 47 | // headers[i] = buttons[i]->text(); |
46 | 48 | buttons[i]->setText(translateString(headers[i])); |
95 | 97 | } |
96 | 98 | |
97 | 99 | QWidget* p[] = {pLinks, pBuild, pRulez, pLimits, pProxy, pExperts, pMime, pFlow, pSpider, pBrowser, pLog}; |
98 | memcpy(pages, p, OPTION_SITES*sizeof(QWidget*)); | |
100 | memcpy(pages, p, OPTION_SITES * sizeof(QWidget*)); | |
99 | 101 | |
100 | 102 | buttons[0]->setChecked(true); |
101 | 103 | } |
187 | 189 | |
188 | 190 | case EDITLINE: { |
189 | 191 | if ((*ivec).opttype == INTEGER) { |
190 | (*ivec).value = ((QLineEdit*)(*ivec).wg)->text().toInt(); | |
192 | if (((QLineEdit*)(*ivec).wg)->text() != "-1") { | |
193 | (*ivec).value = ((QLineEdit*)(*ivec).wg)->text().toInt(); | |
194 | } | |
195 | } else { | |
196 | (*ivec).value = -1; | |
197 | } | |
198 | ||
199 | if ((*ivec).opttype == FLOAT) { | |
200 | if (((QLineEdit*)(*ivec).wg)->text() != "-1") { | |
201 | (*ivec).value = ((QLineEdit*)(*ivec).wg)->text().toFloat(); | |
202 | } else { | |
203 | (*ivec).value = -1; | |
204 | } | |
191 | 205 | } |
192 | 206 | |
193 | 207 | if ((*ivec).opttype == TEXT) { |
226 | 240 | (*ivec).value = ((QComboBox*)(*ivec).wg)->currentText(); |
227 | 241 | } |
228 | 242 | |
229 | if ((*ivec).opttype == INTEGER) { | |
243 | if ((*ivec).opttype == INTEGER || (*ivec).opttype == FLOAT) { | |
230 | 244 | bool ok; |
231 | 245 | QString ct = ((QComboBox*)(*ivec).wg)->currentText(); |
232 | 246 | |
233 | 247 | if (ct == "" || ct == "-") { |
234 | 248 | (*ivec).value = -1; |
235 | 249 | } else { |
236 | int num = ct.toInt(&ok); | |
237 | ||
238 | if (ok == true) { | |
239 | (*ivec).value = num; | |
250 | if ((*ivec).opttype == INTEGER ) { | |
251 | int num = ct.toInt(&ok); | |
252 | ||
253 | if (ok == true) { | |
254 | (*ivec).value = num; | |
255 | } else { | |
256 | (*ivec).value = ((QComboBox*)(*ivec).wg)->currentIndex(); | |
257 | } | |
240 | 258 | } else { |
241 | (*ivec).value = ((QComboBox*)(*ivec).wg)->currentIndex(); | |
259 | float num = ct.toFloat(&ok); | |
260 | ||
261 | if (ok == true) { | |
262 | (*ivec).value = num; | |
263 | } else { | |
264 | (*ivec).value = ((QComboBox*)(*ivec).wg)->currentIndex(); | |
265 | } | |
242 | 266 | } |
243 | 267 | } |
244 | 268 | } |
349 | 373 | } |
350 | 374 | } |
351 | 375 | } |
376 | ||
377 | if ((*ivec).opttype == FLOAT) { | |
378 | int pos ; | |
379 | ||
380 | if ((*ivec).value == -1) { | |
381 | pos = ((QComboBox*)(*ivec).wg)->findText(""); | |
382 | ((QComboBox*)(*ivec).wg)->setCurrentIndex(pos); | |
383 | } else { | |
384 | pos = ((QComboBox*)(*ivec).wg)->findText(QString::number((*ivec).value.toFloat())); | |
385 | ||
386 | if (pos >= 0) { | |
387 | ((QComboBox*)(*ivec).wg)->setCurrentIndex(pos); | |
388 | } else { | |
389 | ((QComboBox*)(*ivec).wg)->setCurrentIndex((*ivec).value.toFloat()); | |
390 | } | |
391 | } | |
392 | } | |
352 | 393 | } |
353 | 394 | |
354 | 395 | break; |
360 | 401 | } |
361 | 402 | |
362 | 403 | case EDITLINE: {// no translate for edit widget |
363 | ||
364 | 404 | if ((*ivec).opttype == INTEGER) { |
365 | ((QLineEdit*)(*ivec).wg)->setText(QString::number((*ivec).value.toInt())); | |
405 | if ((*ivec).value.toInt() == -1) { | |
406 | ((QLineEdit*)(*ivec).wg)->setText(""); | |
407 | } else { | |
408 | ((QLineEdit*)(*ivec).wg)->setText(QString::number((*ivec).value.toInt())); | |
409 | } | |
410 | } | |
411 | ||
412 | if ((*ivec).opttype == FLOAT) { | |
413 | if ((*ivec).value.toInt() == -1) { | |
414 | ((QLineEdit*)(*ivec).wg)->setText(""); | |
415 | } else { | |
416 | ((QLineEdit*)(*ivec).wg)->setText(QString::number((*ivec).value.toFloat())); | |
417 | } | |
366 | 418 | } |
367 | 419 | |
368 | 420 | if ((*ivec).opttype == TEXT) { |
100 | 100 | <widget class="QComboBox" name="comboMaxExtDep"> |
101 | 101 | <property name="minimumSize"> |
102 | 102 | <size> |
103 | <width>75</width> | |
104 | <height>0</height> | |
105 | </size> | |
106 | </property> | |
107 | <property name="maximumSize"> | |
108 | <size> | |
109 | <width>100</width> | |
103 | <width>100</width> | |
104 | <height>0</height> | |
105 | </size> | |
106 | </property> | |
107 | <property name="maximumSize"> | |
108 | <size> | |
109 | <width>125</width> | |
110 | 110 | <height>25</height> |
111 | 111 | </size> |
112 | </property> | |
113 | <property name="editable"> | |
114 | <bool>true</bool> | |
112 | 115 | </property> |
113 | 116 | </widget> |
114 | 117 | </item> |
141 | 144 | <widget class="QComboBox" name="comboMaxTime"> |
142 | 145 | <property name="minimumSize"> |
143 | 146 | <size> |
144 | <width>75</width> | |
145 | <height>0</height> | |
146 | </size> | |
147 | </property> | |
148 | <property name="maximumSize"> | |
149 | <size> | |
150 | <width>100</width> | |
147 | <width>100</width> | |
148 | <height>0</height> | |
149 | </size> | |
150 | </property> | |
151 | <property name="maximumSize"> | |
152 | <size> | |
153 | <width>125</width> | |
151 | 154 | <height>25</height> |
152 | 155 | </size> |
156 | </property> | |
157 | <property name="editable"> | |
158 | <bool>true</bool> | |
153 | 159 | </property> |
154 | 160 | </widget> |
155 | 161 | </item> |
157 | 163 | <widget class="QComboBox" name="comboMaxTransf"> |
158 | 164 | <property name="minimumSize"> |
159 | 165 | <size> |
160 | <width>75</width> | |
161 | <height>0</height> | |
162 | </size> | |
163 | </property> | |
164 | <property name="maximumSize"> | |
165 | <size> | |
166 | <width>100</width> | |
166 | <width>100</width> | |
167 | <height>0</height> | |
168 | </size> | |
169 | </property> | |
170 | <property name="maximumSize"> | |
171 | <size> | |
172 | <width>125</width> | |
167 | 173 | <height>25</height> |
168 | 174 | </size> |
175 | </property> | |
176 | <property name="editable"> | |
177 | <bool>true</bool> | |
169 | 178 | </property> |
170 | 179 | </widget> |
171 | 180 | </item> |
173 | 182 | <widget class="QLineEdit" name="editMaxNHtml"> |
174 | 183 | <property name="minimumSize"> |
175 | 184 | <size> |
176 | <width>75</width> | |
177 | <height>0</height> | |
178 | </size> | |
179 | </property> | |
180 | <property name="maximumSize"> | |
181 | <size> | |
182 | <width>100</width> | |
185 | <width>100</width> | |
186 | <height>0</height> | |
187 | </size> | |
188 | </property> | |
189 | <property name="maximumSize"> | |
190 | <size> | |
191 | <width>125</width> | |
183 | 192 | <height>16777215</height> |
184 | 193 | </size> |
185 | 194 | </property> |
189 | 198 | <widget class="QLineEdit" name="editPause"> |
190 | 199 | <property name="minimumSize"> |
191 | 200 | <size> |
192 | <width>75</width> | |
193 | <height>0</height> | |
194 | </size> | |
195 | </property> | |
196 | <property name="maximumSize"> | |
197 | <size> | |
198 | <width>100</width> | |
201 | <width>100</width> | |
202 | <height>0</height> | |
203 | </size> | |
204 | </property> | |
205 | <property name="maximumSize"> | |
206 | <size> | |
207 | <width>125</width> | |
199 | 208 | <height>16777215</height> |
200 | 209 | </size> |
201 | 210 | </property> |
268 | 277 | <widget class="QComboBox" name="comboMaxLinks"> |
269 | 278 | <property name="minimumSize"> |
270 | 279 | <size> |
271 | <width>75</width> | |
272 | <height>0</height> | |
273 | </size> | |
274 | </property> | |
275 | <property name="maximumSize"> | |
276 | <size> | |
277 | <width>100</width> | |
280 | <width>100</width> | |
281 | <height>0</height> | |
282 | </size> | |
283 | </property> | |
284 | <property name="maximumSize"> | |
285 | <size> | |
286 | <width>125</width> | |
278 | 287 | <height>25</height> |
279 | 288 | </size> |
289 | </property> | |
290 | <property name="editable"> | |
291 | <bool>true</bool> | |
280 | 292 | </property> |
281 | 293 | </widget> |
282 | 294 | </item> |
398 | 410 | <widget class="QLineEdit" name="editMaxHtml"> |
399 | 411 | <property name="minimumSize"> |
400 | 412 | <size> |
401 | <width>75</width> | |
402 | <height>0</height> | |
403 | </size> | |
404 | </property> | |
405 | <property name="maximumSize"> | |
406 | <size> | |
407 | <width>100</width> | |
413 | <width>100</width> | |
414 | <height>0</height> | |
415 | </size> | |
416 | </property> | |
417 | <property name="maximumSize"> | |
418 | <size> | |
419 | <width>125</width> | |
408 | 420 | <height>16777215</height> |
409 | 421 | </size> |
410 | 422 | </property> |
464 | 476 | <widget class="QComboBox" name="comboMaxConn"> |
465 | 477 | <property name="minimumSize"> |
466 | 478 | <size> |
467 | <width>75</width> | |
468 | <height>0</height> | |
469 | </size> | |
470 | </property> | |
471 | <property name="maximumSize"> | |
472 | <size> | |
473 | <width>100</width> | |
479 | <width>100</width> | |
480 | <height>0</height> | |
481 | </size> | |
482 | </property> | |
483 | <property name="maximumSize"> | |
484 | <size> | |
485 | <width>125</width> | |
474 | 486 | <height>25</height> |
475 | 487 | </size> |
488 | </property> | |
489 | <property name="editable"> | |
490 | <bool>true</bool> | |
476 | 491 | </property> |
477 | 492 | </widget> |
478 | 493 | </item> |
530 | 545 | <widget class="QLineEdit" name="editMaxSize"> |
531 | 546 | <property name="minimumSize"> |
532 | 547 | <size> |
533 | <width>75</width> | |
534 | <height>0</height> | |
535 | </size> | |
536 | </property> | |
537 | <property name="maximumSize"> | |
538 | <size> | |
539 | <width>100</width> | |
548 | <width>100</width> | |
549 | <height>0</height> | |
550 | </size> | |
551 | </property> | |
552 | <property name="maximumSize"> | |
553 | <size> | |
554 | <width>125</width> | |
540 | 555 | <height>16777215</height> |
541 | 556 | </size> |
542 | 557 | </property> |
571 | 586 | <widget class="QComboBox" name="comboMaxDep"> |
572 | 587 | <property name="minimumSize"> |
573 | 588 | <size> |
574 | <width>75</width> | |
575 | <height>0</height> | |
576 | </size> | |
577 | </property> | |
578 | <property name="maximumSize"> | |
579 | <size> | |
580 | <width>100</width> | |
589 | <width>100</width> | |
590 | <height>0</height> | |
591 | </size> | |
592 | </property> | |
593 | <property name="maximumSize"> | |
594 | <size> | |
595 | <width>125</width> | |
581 | 596 | <height>25</height> |
582 | 597 | </size> |
598 | </property> | |
599 | <property name="editable"> | |
600 | <bool>true</bool> | |
583 | 601 | </property> |
584 | 602 | </widget> |
585 | 603 | </item> |
94 | 94 | public: |
95 | 95 | OptionsDialog(QWidget * parent = 0, Qt::WFlags f = 0); |
96 | 96 | ~OptionsDialog(); |
97 | ||
97 | ||
98 | 98 | void onSetDefOptions(); |
99 | 99 | void setToGUI(); |
100 | 100 | void getFromGUI(); |
50 | 50 | |
51 | 51 | protected slots: |
52 | 52 | /*$PROTECTED_SLOTS$*/ |
53 | void editingFinished(void); | |
53 | 54 | // void unitChanged(bool on); |
54 | 55 | private: |
55 | 56 | QVector<trWidgets>* opts; |
33 | 33 | maxTime << "" << "120" << "900" << "1800" << "3600" << "7200"; |
34 | 34 | limitsForm::comboMaxTime->insertItems(0, maxTime); // max time overall |
35 | 35 | |
36 | connect (limitsForm::comboMaxTime->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
37 | // connect (limitsForm::comboMaxTime->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
38 | ||
36 | 39 | QStringList connSec; |
37 | 40 | connSec << "" << "1" << "2" << "4" << "8" << "16" << "32" << "64" << "128"; |
38 | 41 | limitsForm::comboMaxConn->insertItems(0, connSec); // max connections/sec |
39 | 42 | |
43 | connect (limitsForm::comboMaxConn->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
44 | // connect (limitsForm::comboMaxConn->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
45 | ||
40 | 46 | limitsForm::comboMaxDep->insertItems(0, connSec); // max depth |
47 | ||
48 | connect (limitsForm::comboMaxDep->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
49 | // connect (limitsForm::comboMaxDep->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
41 | 50 | |
42 | 51 | QStringList extD; |
43 | 52 | extD << "" << "0" << "1" << "2" << "4" << "8" << "16" << "32" << "64" << "128"; |
44 | 53 | limitsForm::comboMaxExtDep->insertItems(0, extD); // max links |
54 | connect (limitsForm::comboMaxExtDep->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
55 | // connect (limitsForm::comboMaxExtDep->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
45 | 56 | |
46 | 57 | QStringList maxLinks; |
47 | 58 | maxLinks << "" << "100000" << "200000" << "1000000" << "5000000"; |
48 | 59 | limitsForm::comboMaxLinks->insertItems(0, maxLinks); // max links |
49 | 60 | |
61 | connect (limitsForm::comboMaxLinks->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
62 | // connect (limitsForm::comboMaxLinks->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
63 | ||
50 | 64 | QStringList maxTransferRate; |
51 | maxTransferRate << "" << "1" << "5" << "20" << "50" << "75" << "100" << "250"; | |
65 | maxTransferRate << "" << "0.01" << "0.1" << "0.5" << "1" << "5" << "20" << "50" << "75" << "100" << "250"; | |
52 | 66 | limitsForm::comboMaxTransf->insertItems(0, maxTransferRate); // max transfer rate |
67 | ||
68 | connect (limitsForm::comboMaxTransf->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished())); | |
69 | // connect (limitsForm::comboMaxTransf->lineEdit(), SIGNAL(returnPressed()), this, SLOT(editingFinished())); | |
53 | 70 | |
54 | 71 | opts = &((OptionsDialog*)(parentDialog))->_tabTextInfos; |
55 | 72 | |
110 | 127 | } |
111 | 128 | #endif |
112 | 129 | |
130 | // check the entered value depended from combobox | |
131 | void optionsLimits::editingFinished() | |
132 | { | |
133 | QLineEdit* from; | |
134 | bool valGood; | |
135 | QString t; | |
136 | from = (QLineEdit*)sender(); | |
137 | t = from->text(); | |
138 | // qDebug() << from << t; | |
139 | if (t == "" || t == "\n") { | |
140 | limitsForm::comboMaxConn->setCurrentIndex(0); // first element, = -1 | |
141 | return; | |
142 | } | |
143 | ||
144 | if (from == limitsForm::comboMaxConn->lineEdit()){ // int, range: space, 0..255 | |
145 | int tmp = t.toInt(&valGood); | |
146 | if (valGood == true){ | |
147 | if (!(tmp >= 0 && tmp <=255)){ | |
148 | ||
149 | } | |
150 | else{ | |
151 | int currInd = limitsForm::comboMaxConn->findText(t); | |
152 | if ( currInd < 0){ | |
153 | limitsForm::comboMaxConn->addItem(t); | |
154 | limitsForm::comboMaxConn->model()->sort(0); | |
155 | } | |
156 | else{ | |
157 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
158 | } | |
159 | } | |
160 | } | |
161 | } | |
162 | if (from == limitsForm::comboMaxDep->lineEdit()){ // int, range: space, 0..9999 | |
163 | int tmp = t.toInt(&valGood); | |
164 | if (valGood == true){ | |
165 | if (!(tmp >= 0 && tmp <=9999)){ | |
166 | ||
167 | } | |
168 | else{ | |
169 | int currInd = limitsForm::comboMaxConn->findText(t); | |
170 | if ( currInd < 0){ | |
171 | limitsForm::comboMaxConn->addItem(t); | |
172 | limitsForm::comboMaxConn->model()->sort(0); | |
173 | } | |
174 | else{ | |
175 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
176 | } | |
177 | } | |
178 | } | |
179 | } | |
180 | if (from == limitsForm::comboMaxExtDep->lineEdit()){ // int, range: space, 0..9999 | |
181 | int tmp = t.toInt(&valGood); | |
182 | if (valGood == true){ | |
183 | if (!(tmp >= 0 && tmp <=9999)){ | |
184 | ||
185 | } | |
186 | else{ | |
187 | int currInd = limitsForm::comboMaxConn->findText(t); | |
188 | if ( currInd < 0){ | |
189 | limitsForm::comboMaxConn->addItem(t); | |
190 | limitsForm::comboMaxConn->model()->sort(0); | |
191 | } | |
192 | else{ | |
193 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
194 | } | |
195 | } | |
196 | } | |
197 | } | |
198 | if (from == limitsForm::comboMaxTime->lineEdit()){ // int, range: space, 0..99999 sec | |
199 | int tmp = t.toInt(&valGood); | |
200 | if (valGood == true){ | |
201 | if (!(tmp >= 0 && tmp <=99999)){ | |
202 | ||
203 | } | |
204 | else{ | |
205 | int currInd = limitsForm::comboMaxConn->findText(t); | |
206 | if ( currInd < 0){ | |
207 | limitsForm::comboMaxConn->addItem(t); | |
208 | limitsForm::comboMaxConn->model()->sort(0); | |
209 | } | |
210 | else{ | |
211 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
212 | } | |
213 | } | |
214 | } | |
215 | } | |
216 | if (from == limitsForm::comboMaxTransf->lineEdit()){ // float, range: space, 0..1000 MB/s | |
217 | float tmp = t.toFloat(&valGood); | |
218 | if (valGood == true){ | |
219 | if (!(tmp >= 0 && tmp <=1000)){ | |
220 | ||
221 | } | |
222 | else{ | |
223 | int currInd = limitsForm::comboMaxConn->findText(t); | |
224 | if ( currInd < 0){ | |
225 | limitsForm::comboMaxConn->addItem(t); | |
226 | limitsForm::comboMaxConn->model()->sort(0); | |
227 | } | |
228 | else{ | |
229 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
230 | } | |
231 | } | |
232 | } | |
233 | } | |
234 | if (from == limitsForm::comboMaxLinks->lineEdit()){ // int, range: space, 0..5000000 | |
235 | int tmp = t.toInt(&valGood); | |
236 | if (valGood == true){ | |
237 | if (!(tmp >= 0 && tmp <=5000000)){ | |
238 | ||
239 | } | |
240 | else{ | |
241 | int currInd = limitsForm::comboMaxConn->findText(t); | |
242 | if ( currInd < 0){ | |
243 | limitsForm::comboMaxConn->addItem(t); | |
244 | limitsForm::comboMaxConn->model()->sort(0); | |
245 | } | |
246 | else{ | |
247 | limitsForm::comboMaxConn->setCurrentIndex(currInd); | |
248 | } | |
249 | } | |
250 | } | |
251 | } | |
252 | } | |
253 | ||
113 | 254 | void optionsLimits::initTextPoints() |
114 | 255 | { |
115 | 256 | *opts << (trWidgets) { |
155 | 296 | limitsForm::comboMaxTime, -1, "MaxTime", COMBOBOX, INTEGER, 0 |
156 | 297 | }; |
157 | 298 | *opts << (trWidgets) { |
158 | limitsForm::comboMaxTransf, -1, "MaxRate", COMBOBOX, INTEGER, 0 | |
299 | limitsForm::comboMaxTransf, -1, "MaxRate", COMBOBOX, FLOAT, 0 | |
159 | 300 | }; |
160 | 301 | *opts << (trWidgets) { |
161 | 302 | limitsForm::comboMaxConn, -1, "MaxConn", COMBOBOX, INTEGER, 0 |
164 | 305 | limitsForm::comboMaxLinks, -1, "MaxLinks", COMBOBOX, INTEGER, 0 |
165 | 306 | }; |
166 | 307 | *opts << (trWidgets) { |
167 | limitsForm::editMaxHtml, -1, "MaxHtml", EDITLINE, INTEGER, 0 | |
168 | }; | |
169 | *opts << (trWidgets) { | |
170 | limitsForm::editMaxNHtml, -1, "MaxOther", EDITLINE, INTEGER, 0 | |
171 | }; | |
172 | *opts << (trWidgets) { | |
173 | limitsForm::editMaxSize, -1, "MaxAll", EDITLINE, INTEGER, 0 | |
308 | limitsForm::editMaxHtml, -1, "MaxHtml", EDITLINE, FLOAT, 0 | |
309 | }; | |
310 | *opts << (trWidgets) { | |
311 | limitsForm::editMaxNHtml, -1, "MaxOther", EDITLINE, FLOAT, 0 | |
312 | }; | |
313 | *opts << (trWidgets) { | |
314 | limitsForm::editMaxSize, -1, "MaxAll", EDITLINE, FLOAT, 0 | |
174 | 315 | }; |
175 | 316 | *opts << (trWidgets) { |
176 | 317 | limitsForm::editPause, -1, "MaxWait", EDITLINE, INTEGER, 0 |