1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
/***************************************************************************
* C++ Implementation: *
* Copyright (C) 2012-2017 by Eduard Kalinowski *
* Germany, Lower Saxony, Hanover *
* eduard_kalinowski@yahoo.de *
* *
* HTTraQt is free software; may be distributed and/or modified under the *
* terms of the GNU General Public License version 3 as published by the *
* Free Software Foundation and appearing in the file LICENSE_GPLv3 *
* included in the packaging of this file. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with HTTraQt. If not, see http://www.gnu.org/licenses *
***************************************************************************/
#include "includes/optionsflow.h"
#include "includes/OptionsDialog.h"
#include "../main/includes/httraqt.h"
optionsFlow::optionsFlow(QWidget* parent, Qt::WindowFlags fl)
: QWidget(parent, fl), Ui::flowForm()
{
setupUi(this);
this->parent = static_cast<OptionsDialog*>(parent);
QStringList connections;
connections << "";
for (int i = 1; i < 15; i++) {
connections << QString::number(i);
}
flowForm::labelConn->insertItems(0, connections);
QStringList timeout;
timeout << "" << "30" << "60" << "120" << "180" << "300" << "600" << "1200";
flowForm::labelTimeout->insertItems(0, timeout);
flowForm::labelTimeout->setDuplicatesEnabled(true);
connect (flowForm::labelTimeout->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished()));
QStringList retries;
retries << "" << "0" << "1" << "2" << "3" << "6";
flowForm::labelRetries->insertItems(0, retries);
flowForm::labelRetries->setDuplicatesEnabled(true);
connect (flowForm::labelRetries->lineEdit(), SIGNAL(editingFinished()), this, SLOT(editingFinished()));
opts = &(static_cast<OptionsDialog*>(this->parent))->_tabTextInfos;
initTextPoints();
}
optionsFlow::~optionsFlow()
{
}
// check the entered value depended from combobox
void optionsFlow::editingFinished()
{
QLineEdit* from;
bool valGood;
QString t;
from = (QLineEdit*)sender();
QComboBox *par = (QComboBox*)from->parent();
t = from->text();
// qDebug() << from << t;
if (t == "" || t == "\n") {
par->setCurrentIndex(0); // first element, = -1
return;
}
disconnect (from, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
if (from == flowForm::labelTimeout->lineEdit()) { // int, range: space, 0..255
int tmp = t.toInt(&valGood);
if (valGood == true) {
if (!(tmp >= 0 && tmp <= 1200)) {
qDebug() << "wrong" << from << tmp;
valGood = false;
}
}
}
if (from == flowForm::labelRetries->lineEdit()) { // int, range: space, 0..9999
int tmp = t.toInt(&valGood);
if (valGood == true) {
if (!(tmp >= 0 && tmp <= 99)) {
qDebug() << "wrong" << from << tmp;
valGood = false;
}
}
}
if (valGood == true) {
// qDebug() << "right" << t;
int currInd = par->findText(t);
if ( currInd < 0) {
par->addItem(t);
par->model()->sort(0);
int tInd = par->findText(t);
par->setCurrentIndex(tInd);
} else {
par->setCurrentIndex(currInd);
}
}
connect (from, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
}
void optionsFlow::initTextPoints()
{
*opts << (trWidgets) {
flowForm::label1201_2, _NR_CONN, "", LABEL, 0
};
*opts << (trWidgets) {
flowForm::label1290, _TIMEOUTS, "", LABEL, 0
};
*opts << (trWidgets) {
flowForm::label1203, _RETRIES, "", LABEL, 0
};
*opts << (trWidgets) {
flowForm::label1202_2, _MIN_RATE, "", LABEL, 0
};
*opts << (trWidgets) {
flowForm::label1055, -1, "RateOut", EDITLINE, 0
};
*opts << (trWidgets) {
flowForm::labelConn, -1, "Sockets", COMBOBOX, 0
};
*opts << (trWidgets) {
flowForm::labelTimeout, -1, "TimeOut", COMBOBOX, 0
};
*opts << (trWidgets) {
flowForm::labelRetries, -1, "Retry", COMBOBOX, 0
};
*opts << (trWidgets) {
flowForm::label1033, _KEEP_ALIVE, "KeepAlive", CHECKBOX, 0
};
*opts << (trWidgets) {
flowForm::label1031_2, _CANCEL_TIMEOUT, "RemoveTimeout", CHECKBOX, 0
};
*opts << (trWidgets) {
flowForm::label1032, _CANCEL_SLOW, "RemoveRateout", CHECKBOX, 0
};
}
/*$SPECIALIZATION$*/
|