Skip to content

Commit

Permalink
truncate resends to a one decimal place. thats all that is supported …
Browse files Browse the repository at this point in the history
…for now.
  • Loading branch information
dannagle committed Aug 22, 2015
1 parent 6523084 commit d0f0272
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
13 changes: 4 additions & 9 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void MainWindow::on_savePacketButton_clicked()
testPacket.tcpOrUdp = ui->udptcpComboBox->currentText();
testPacket.sendResponse = 0;
testPacket.port = ui->packetPortEdit->text().toUInt();
testPacket.repeat = ui->resendEdit->text().toFloat();
testPacket.repeat = Packet::oneDecimal(ui->resendEdit->text().toFloat());

testPacket.saveToDB();
packetsSaved = Packet::fetchAllfromDB("");
Expand Down Expand Up @@ -708,7 +708,7 @@ void MainWindow::on_testPacketButton_clicked()
testPacket.tcpOrUdp = ui->udptcpComboBox->currentText();
testPacket.sendResponse = 0;
testPacket.port = ui->packetPortEdit->text().toUInt();
testPacket.repeat = ui->resendEdit->text().toFloat();
testPacket.repeat = Packet::oneDecimal(ui->resendEdit->text().toFloat());


if(testPacket.toIP.isEmpty()) {
Expand Down Expand Up @@ -920,7 +920,7 @@ void MainWindow::on_packetsTable_itemChanged(QTableWidgetItem *item)
}
if(datatype == "repeat")
{
int repeat = newText.toUInt();
float repeat = Packet::oneDecimal(newText.toFloat());
updatePacket.repeat = repeat;
}
if(datatype == "tcpOrUdp")
Expand Down Expand Up @@ -1594,11 +1594,6 @@ void MainWindow::on_actionSubnet_Calculator_triggered()

void MainWindow::on_resendEdit_editingFinished()
{
//truncate to 1 deciminal place.
float resendVal = ui->resendEdit->text().toFloat();
resendVal = resendVal * 10;
int resendint = (int) resendVal;
resendVal = (float) resendint;
resendVal = resendVal / 10;
float resendVal = Packet::oneDecimal(ui->resendEdit->text().toFloat());
ui->resendEdit->setText(QString::number(resendVal));
}
7 changes: 7 additions & 0 deletions src/packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ bool Packet::isTCP()
return (tcpOrUdp.trimmed().toLower() == "tcp");
}

float Packet::oneDecimal(float value) {
float valueFloat = value * 10;
int valueInt = (int) valueFloat;
valueFloat = ((float) valueInt) / 10;
return valueFloat;
}

Packet::~Packet()
{
init();
Expand Down
1 change: 1 addition & 0 deletions src/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Packet
QIcon getIcon();
static void sortByName(QList<Packet> &packetList);
static void sortByTime(QList<Packet> &packetList);
static float oneDecimal(float value);
private:
static int hexToInt(QChar hex);

Expand Down
4 changes: 1 addition & 3 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ void Settings::on_buttonBox_accepted()

settings.setValue("cancelResendNum", ui->cancelResendNumEdit->text().toUInt());

float multiSend = ui->multiSendDelayEdit->text().toFloat() * 10;
int multiSendInt = (int) multiSend;
multiSend = ((float) multiSendInt) / 10;
float multiSend = Packet::oneDecimal(ui->multiSendDelayEdit->text().toFloat());
settings.setValue("multiSendDelay", multiSend);


Expand Down

0 comments on commit d0f0272

Please sign in to comment.