Updated the entire program to work in either hex or decimal. Changing the mode in settings will change which is used in many places.
You can always still enter values in decimal, hex, or binary regardless of the mode you are in.
This commit is contained in:
+5
-7
@@ -1,6 +1,7 @@
|
||||
#include "canframemodel.h"
|
||||
|
||||
#include <QFile>
|
||||
#include "utility.h"
|
||||
|
||||
int CANFrameModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
@@ -37,6 +38,7 @@ void CANFrameModel::setHexMode(bool mode)
|
||||
{
|
||||
this->beginResetModel();
|
||||
useHexMode = mode;
|
||||
Utility::decimalMode = !useHexMode;
|
||||
this->endResetModel();
|
||||
}
|
||||
}
|
||||
@@ -165,11 +167,8 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
if (!timeSeconds) return QString::number(thisFrame.timestamp);
|
||||
else return QString::number(thisFrame.timestamp / 1000000.0f);
|
||||
break;
|
||||
case 1: //id
|
||||
if (useHexMode)
|
||||
return QString::number(thisFrame.ID, 16).toUpper().rightJustified(2,'0');
|
||||
else
|
||||
return QString::number(thisFrame.ID).rightJustified(3,'0');
|
||||
case 1: //id
|
||||
return Utility::formatNumber(thisFrame.ID);
|
||||
break;
|
||||
case 2: //ext
|
||||
return QString::number(thisFrame.extended);
|
||||
@@ -183,8 +182,7 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const
|
||||
case 5: //data
|
||||
for (int i = 0; i < thisFrame.len; i++)
|
||||
{
|
||||
if (useHexMode) tempString.append(QString::number(thisFrame.data[i], 16).toUpper().rightJustified(2,'0'));
|
||||
else tempString.append(QString::number(thisFrame.data[i]).rightJustified(3,'0'));
|
||||
tempString.append(Utility::formatNumber(thisFrame.data[i]));
|
||||
tempString.append(" ");
|
||||
}
|
||||
//now, if we're supposed to interpret the data and the DBC handler is loaded then use it
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 130
|
||||
#define VERSION 131
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
+4
-4
@@ -221,7 +221,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
|
||||
//dbcHandler->findNodeByIdx(0);
|
||||
}
|
||||
|
||||
msgID = ui->MessagesTable->item(row, 0)->text().toInt(NULL, 16);
|
||||
msgID = Utility::ParseStringToNum(ui->MessagesTable->item(row, 0)->text());
|
||||
qDebug() << "Msg ID of edited: " << msgID;
|
||||
msg = dbcHandler->findMsgByID(msgID);
|
||||
|
||||
@@ -257,7 +257,7 @@ void DBCMainEditor::onCellChangedMessage(int row,int col)
|
||||
if (msg != NULL) msg->ID = msgID;
|
||||
}
|
||||
inhibitCellChanged = true;
|
||||
replacement = new QTableWidgetItem(QString::number(msgID, 16));
|
||||
replacement = new QTableWidgetItem(Utility::formatNumber(msgID));
|
||||
ui->MessagesTable->setItem(row, col, replacement);
|
||||
replacement = new QTableWidgetItem(QString::number(newMsg.len));
|
||||
ui->MessagesTable->setItem(row, 2, replacement);
|
||||
@@ -375,7 +375,7 @@ void DBCMainEditor::onCellClickedMessage(int row, int col)
|
||||
if (col == 3) //3 is the signals field. If clicked we go to the signals dialog
|
||||
{
|
||||
QString idString = ui->MessagesTable->item(row, 0)->text();
|
||||
DBC_MESSAGE *message = dbcHandler->findMsgByID(idString.toInt(NULL, 16));
|
||||
DBC_MESSAGE *message = dbcHandler->findMsgByID(Utility::ParseStringToNum(idString));
|
||||
sigEditor->setMessageRef(message);
|
||||
sigEditor->exec(); //blocks this window from being active until we're done
|
||||
//now update the displayed # of signals
|
||||
@@ -433,7 +433,7 @@ void DBCMainEditor::refreshMessagesTable(const DBC_NODE *node)
|
||||
if (msg.sender == node)
|
||||
{
|
||||
//many of these are simplistic first versions just to test functionality.
|
||||
QTableWidgetItem *msgID = new QTableWidgetItem(QString::number(msg.ID, 16));
|
||||
QTableWidgetItem *msgID = new QTableWidgetItem(Utility::formatNumber(msg.ID));
|
||||
QTableWidgetItem *msgName = new QTableWidgetItem(msg.name);
|
||||
QTableWidgetItem *msgLen = new QTableWidgetItem(QString::number(msg.len));
|
||||
QTableWidgetItem *msgSignals = new QTableWidgetItem(QString::number(msg.msgSignals.count()));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDebug>
|
||||
#include "dbchandler.h"
|
||||
#include "dbcsignaleditor.h"
|
||||
#include "utility.h"
|
||||
|
||||
namespace Ui {
|
||||
class DBCMainEditor;
|
||||
|
||||
+14
-5
@@ -50,6 +50,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->cbIntelFormat, &QCheckBox::toggled,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
currentSignal->intelByteOrder = ui->cbIntelFormat->isChecked();
|
||||
fillSignalForm(currentSignal);
|
||||
});
|
||||
@@ -57,11 +58,13 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->comboReceiver, &QComboBox::currentTextChanged,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
currentSignal->receiver = dbcHandler->findNodeByName(ui->comboReceiver->currentText());
|
||||
});
|
||||
connect(ui->comboType, &QComboBox::currentTextChanged,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
switch (ui->comboType->currentIndex())
|
||||
{
|
||||
case 0:
|
||||
@@ -84,6 +87,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtBias, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
double temp;
|
||||
bool result;
|
||||
temp = ui->txtBias->text().toDouble(&result);
|
||||
@@ -93,6 +97,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtMaxVal, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
double temp;
|
||||
bool result;
|
||||
temp = ui->txtMaxVal->text().toDouble(&result);
|
||||
@@ -102,6 +107,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtMinVal, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
double temp;
|
||||
bool result;
|
||||
temp = ui->txtMinVal->text().toDouble(&result);
|
||||
@@ -110,6 +116,7 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtScale, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
double temp;
|
||||
bool result;
|
||||
temp = ui->txtScale->text().toDouble(&result);
|
||||
@@ -118,19 +125,22 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtComment, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
currentSignal->comment = ui->txtComment->text();
|
||||
});
|
||||
|
||||
connect(ui->txtUnitName, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
currentSignal->unitName = ui->txtUnitName->text();
|
||||
});
|
||||
connect(ui->txtBitLength, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
int temp;
|
||||
temp = ui->txtBitLength->text().toInt();
|
||||
temp = Utility::ParseStringToNum(ui->txtBitLength->text());
|
||||
if (temp < 0) return;
|
||||
if (temp > 63) return;
|
||||
currentSignal->signalSize = temp;
|
||||
@@ -139,12 +149,11 @@ DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
|
||||
connect(ui->txtName, &QLineEdit::editingFinished,
|
||||
[=]()
|
||||
{
|
||||
if (currentSignal == NULL) return;
|
||||
currentSignal->name = ui->txtName->text();
|
||||
//need to update the list too.
|
||||
ui->signalsList->currentItem()->setText(currentSignal->name);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
DBCSignalEditor::~DBCSignalEditor()
|
||||
@@ -220,7 +229,7 @@ void DBCSignalEditor::onValuesCellChanged(int row,int col)
|
||||
|
||||
if (col == 0)
|
||||
{
|
||||
currentSignal->valList[row].value = ui->valuesTable->item(row, col)->text().toInt();
|
||||
currentSignal->valList[row].value = Utility::ParseStringToNum(ui->valuesTable->item(row, col)->text());
|
||||
}
|
||||
else if (col == 1)
|
||||
{
|
||||
@@ -409,7 +418,7 @@ void DBCSignalEditor::fillValueTable(DBC_SIGNAL *sig)
|
||||
|
||||
for (int i = 0; i < sig->valList.count(); i++)
|
||||
{
|
||||
QTableWidgetItem *val = new QTableWidgetItem(QString::number(sig->valList[i].value));
|
||||
QTableWidgetItem *val = new QTableWidgetItem(Utility::formatNumber(sig->valList[i].value));
|
||||
QTableWidgetItem *desc = new QTableWidgetItem(sig->valList[i].descript);
|
||||
rowIdx = ui->valuesTable->rowCount();
|
||||
ui->valuesTable->insertRow(rowIdx);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "dbchandler.h"
|
||||
#include "utility.h"
|
||||
|
||||
namespace Ui {
|
||||
class DBCSignalEditor;
|
||||
|
||||
@@ -220,7 +220,7 @@ void FileComparatorWindow::calculateDetails()
|
||||
bitmapBaseReference->setText(0, "Bits set only in reference frames");
|
||||
}
|
||||
sharedItem->addChild(bitmapBaseInterested);
|
||||
sharedItem->addChild(bitmapBaseReference);
|
||||
if (!uniqueInterested) sharedItem->addChild(bitmapBaseReference);
|
||||
|
||||
uint64_t interestedBits = interested.bitmap;
|
||||
uint64_t referenceBits = reference.bitmap;
|
||||
|
||||
+19
-18
@@ -303,7 +303,7 @@ void FlowViewWindow::refreshIDList()
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
QListWidgetItem* item = new QListWidgetItem(QString::number(id, 16).toUpper().rightJustified(4,'0'), ui->listFrameID);
|
||||
QListWidgetItem* item = new QListWidgetItem(Utility::formatNumber(id), ui->listFrameID);
|
||||
}
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
@@ -318,7 +318,7 @@ void FlowViewWindow::updateFrameLabel()
|
||||
void FlowViewWindow::changeID(QString newID)
|
||||
{
|
||||
//parse the ID and then load up the frame cache with just messages with that ID.
|
||||
int id = newID.toInt(NULL, 16);
|
||||
int id = Utility::ParseStringToNum(newID);
|
||||
frameCache.clear();
|
||||
|
||||
if (modelFrames->count() == 0) return;
|
||||
@@ -440,23 +440,24 @@ void FlowViewWindow::timerTriggered()
|
||||
|
||||
void FlowViewWindow::updateDataView()
|
||||
{
|
||||
ui->txtCurr1->setText(QString::number(currBytes[0], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr2->setText(QString::number(currBytes[1], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr3->setText(QString::number(currBytes[2], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr4->setText(QString::number(currBytes[3], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr5->setText(QString::number(currBytes[4], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr6->setText(QString::number(currBytes[5], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr7->setText(QString::number(currBytes[6], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr8->setText(QString::number(currBytes[7], 16).toUpper().rightJustified(2, '0'));
|
||||
|
||||
ui->txtRef1->setText(QString::number(refBytes[0], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef2->setText(QString::number(refBytes[1], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef3->setText(QString::number(refBytes[2], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef4->setText(QString::number(refBytes[3], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef5->setText(QString::number(refBytes[4], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef6->setText(QString::number(refBytes[5], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef7->setText(QString::number(refBytes[6], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtRef8->setText(QString::number(refBytes[7], 16).toUpper().rightJustified(2, '0'));
|
||||
ui->txtCurr1->setText(Utility::formatNumber(currBytes[0]));
|
||||
ui->txtCurr2->setText(Utility::formatNumber(currBytes[1]));
|
||||
ui->txtCurr3->setText(Utility::formatNumber(currBytes[2]));
|
||||
ui->txtCurr4->setText(Utility::formatNumber(currBytes[3]));
|
||||
ui->txtCurr5->setText(Utility::formatNumber(currBytes[4]));
|
||||
ui->txtCurr6->setText(Utility::formatNumber(currBytes[5]));
|
||||
ui->txtCurr7->setText(Utility::formatNumber(currBytes[6]));
|
||||
ui->txtCurr8->setText(Utility::formatNumber(currBytes[7]));
|
||||
|
||||
ui->txtRef1->setText(Utility::formatNumber(refBytes[0]));
|
||||
ui->txtRef2->setText(Utility::formatNumber(refBytes[1]));
|
||||
ui->txtRef3->setText(Utility::formatNumber(refBytes[2]));
|
||||
ui->txtRef4->setText(Utility::formatNumber(refBytes[3]));
|
||||
ui->txtRef5->setText(Utility::formatNumber(refBytes[4]));
|
||||
ui->txtRef6->setText(Utility::formatNumber(refBytes[5]));
|
||||
ui->txtRef7->setText(Utility::formatNumber(refBytes[6]));
|
||||
ui->txtRef8->setText(Utility::formatNumber(refBytes[7]));
|
||||
|
||||
ui->flowView->setReference(refBytes, false);
|
||||
ui->flowView->updateData(currBytes, true);
|
||||
|
||||
+9
-9
@@ -114,7 +114,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
int bitfieldHistogram[64];
|
||||
QTreeWidgetItem *baseNode, *dataBase, *histBase, *numBase, *tempItem;
|
||||
|
||||
targettedID = newID.toInt(NULL, 16);
|
||||
targettedID = Utility::ParseStringToNum(newID);
|
||||
|
||||
if (modelFrames->count() == 0) return;
|
||||
|
||||
@@ -137,7 +137,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
if (frameCache.count() == 0) return;
|
||||
|
||||
baseNode = new QTreeWidgetItem();
|
||||
baseNode->setText(0, QString("ID: 0x") + newID );
|
||||
baseNode->setText(0, QString("ID: ") + newID );
|
||||
|
||||
if (frameCache[0].extended) //if these frames seem to be extended then try for J1939 decoding
|
||||
{
|
||||
@@ -160,23 +160,23 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
{
|
||||
jid.dest = jid.ps;
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("Destination ID: 0x") + QString::number(jid.dest,16));
|
||||
tempItem->setText(0, tr("Destination ID: ") + Utility::formatNumber(jid.dest));
|
||||
baseNode->addChild(tempItem);
|
||||
}
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("SRC: 0x") + QString::number(jid.src,16));
|
||||
tempItem->setText(0, tr("SRC: ") + Utility::formatNumber(jid.src));
|
||||
baseNode->addChild(tempItem);
|
||||
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("PGN: ") + QString::number(jid.pgn,10));
|
||||
tempItem->setText(0, tr("PGN: ") + Utility::formatNumber(jid.pgn));
|
||||
baseNode->addChild(tempItem);
|
||||
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("PF: 0x") + QString::number(jid.pf,16));
|
||||
tempItem->setText(0, tr("PF: ") + Utility::formatNumber(jid.pf));
|
||||
baseNode->addChild(tempItem);
|
||||
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("PS: 0x") + QString::number(jid.ps,16));
|
||||
tempItem->setText(0, tr("PS: ") + Utility::formatNumber(jid.ps));
|
||||
baseNode->addChild(tempItem);
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ void FrameInfoWindow::updateDetailsWindow(QString newID)
|
||||
dataBase->setText(0, tr("Data Byte ") + QString::number(c));
|
||||
baseNode->addChild(dataBase);
|
||||
tempItem = new QTreeWidgetItem();
|
||||
tempItem->setText(0, tr("Range: ") + QString::number(minData[c]) + tr(" to ") + QString::number(maxData[c]));
|
||||
tempItem->setText(0, tr("Range: ") + Utility::formatNumber(minData[c]) + tr(" to ") + Utility::formatNumber(maxData[c]));
|
||||
dataBase->addChild(tempItem);
|
||||
histBase->setText(0, tr("Histogram"));
|
||||
dataBase->addChild(histBase);
|
||||
@@ -292,7 +292,7 @@ void FrameInfoWindow::refreshIDList()
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
ui->listFrameID->addItem(QString::number(id, 16).toUpper().rightJustified(4,'0'));
|
||||
ui->listFrameID->addItem(Utility::formatNumber(id));
|
||||
}
|
||||
}
|
||||
//default is to sort in ascending order
|
||||
|
||||
@@ -247,7 +247,7 @@ void FramePlaybackWindow::refreshIDList()
|
||||
QHash<int, bool>::Iterator filterIter;
|
||||
for (filterIter = currentSeqItem->idFilters.begin(); filterIter != currentSeqItem->idFilters.end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatHexNum(filterIter.key()), ui->listID);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(Utility::formatNumber(filterIter.key()), ui->listID);
|
||||
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable); // set checkable flag
|
||||
if (filterIter.value()) listItem->setCheckState(Qt::Checked);
|
||||
else listItem->setCheckState(Qt::Unchecked);
|
||||
@@ -292,7 +292,7 @@ void FramePlaybackWindow::seqTableCellChanged(int row,int col)
|
||||
{
|
||||
if (col == 1) //don't save any changes to the first column (0)
|
||||
{
|
||||
seqItems[row].maxLoops = ui->tblSequence->item(row, col)->text().toInt();
|
||||
seqItems[row].maxLoops = Utility::ParseStringToNum(ui->tblSequence->item(row, col)->text());
|
||||
if (seqItems[row].maxLoops < 1) seqItems[row].maxLoops = 1;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ void FramePlaybackWindow::changeSendingBus(int newIdx)
|
||||
void FramePlaybackWindow::changeIDFiltering(QListWidgetItem *item)
|
||||
{
|
||||
qDebug() << "Changed ID filter";
|
||||
int ID = item->text().toInt(NULL, 16);
|
||||
int ID = Utility::ParseStringToNum(item->text());
|
||||
currentSeqItem->idFilters[ID] = item->checkState();
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ void FramePlaybackWindow::btnSelectAllClick()
|
||||
{
|
||||
QListWidgetItem *item = ui->listID->item(i);
|
||||
item->setCheckState(Qt::Checked);
|
||||
currentSeqItem->idFilters[item->text().toInt(NULL, 16)] = true;
|
||||
currentSeqItem->idFilters[Utility::ParseStringToNum(item->text())] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,7 +516,7 @@ void FramePlaybackWindow::btnSelectNoneClick()
|
||||
{
|
||||
QListWidgetItem *item = ui->listID->item(i);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
currentSeqItem->idFilters[item->text().toInt(NULL, 16)] = false;
|
||||
currentSeqItem->idFilters[Utility::ParseStringToNum(item->text())] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -270,6 +270,7 @@ void MainWindow::readUpdateableSettings()
|
||||
QSettings settings;
|
||||
useHex = settings.value("Main/UseHex", true).toBool();
|
||||
model->setHexMode(useHex);
|
||||
Utility::decimalMode = !useHex;
|
||||
model->setSecondsMode(settings.value("Main/TimeSeconds", false).toBool());
|
||||
useFiltered = settings.value("Main/UseFiltered", false).toBool();
|
||||
}
|
||||
@@ -322,8 +323,7 @@ void MainWindow::updateFilterList()
|
||||
for (filterIter = filters->begin(); filterIter != filters->end(); ++filterIter)
|
||||
{
|
||||
QListWidgetItem *thisItem = new QListWidgetItem();
|
||||
if (useHex) thisItem->setText(QString::number(filterIter.key(), 16).toUpper().rightJustified(4,'0'));
|
||||
else thisItem->setText(QString::number(filterIter.key()));
|
||||
thisItem->setText(Utility::formatNumber(filterIter.key()));
|
||||
thisItem->setFlags(thisItem->flags() | Qt::ItemIsUserCheckable);
|
||||
if (filterIter.value()) thisItem->setCheckState(Qt::Checked);
|
||||
else thisItem->setCheckState(Qt::Unchecked);
|
||||
@@ -337,8 +337,7 @@ void MainWindow::filterListItemChanged(QListWidgetItem *item)
|
||||
//qDebug() << item->text();
|
||||
int ID;
|
||||
bool isSet = false;
|
||||
if (useHex) ID = item->text().toInt(NULL, 16);
|
||||
else ID = item->text().toInt();
|
||||
ID = Utility::ParseStringToNum(item->text());
|
||||
if (item->checkState() == Qt::Checked) isSet = true;
|
||||
|
||||
model->setFilterState(ID, isSet);
|
||||
@@ -717,7 +716,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
||||
CANFrame thisFrame = frames->at(c);
|
||||
QString builderString;
|
||||
builderString += tr("Time: ") + QString::number((thisFrame.timestamp / 1000000.0), 'f', 6);
|
||||
builderString += tr(" ID: 0x") + QString::number(thisFrame.ID, 16).toUpper().rightJustified(8, '0');
|
||||
builderString += tr(" ID: ") + Utility::formatNumber(thisFrame.ID);
|
||||
if (thisFrame.extended) builderString += tr(" Ext ");
|
||||
else builderString += tr(" Std ");
|
||||
builderString += tr("Bus: ") + QString::number(thisFrame.bus);
|
||||
@@ -727,7 +726,7 @@ Data Bytes: 88 10 00 13 BB 00 06 00
|
||||
builderString = tr("Data Bytes: ");
|
||||
for (int temp = 0; temp < thisFrame.len; temp++)
|
||||
{
|
||||
builderString += QString::number(thisFrame.data[temp], 16).toUpper().rightJustified(2, '0') + " ";
|
||||
builderString += Utility::formatNumber(thisFrame.data[temp]) + " ";
|
||||
}
|
||||
builderString += "\n";
|
||||
outFile->write(builderString.toUtf8());
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ void NewGraphDialog::colorSwatchClick()
|
||||
|
||||
void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||
{
|
||||
ui->txtID->setText("0x" + QString::number(params.ID, 16).toUpper());
|
||||
ui->txtID->setText(Utility::formatNumber(params.ID));
|
||||
ui->txtBias->setText(QString::number(params.bias));
|
||||
ui->txtMask->setText("0x" + QString::number(params.mask, 16).toUpper().left(10));
|
||||
ui->txtMask->setText(Utility::formatNumber(params.mask));
|
||||
ui->txtScale->setText(QString::number(params.scale));
|
||||
ui->txtStride->setText(QString::number(params.stride));
|
||||
ui->cbSigned->setChecked(params.isSigned);
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
#include "utility.h"
|
||||
|
||||
bool Utility::decimalMode = false;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef UTILITY_H
|
||||
#define UTILITY_H
|
||||
|
||||
#include <Qt>
|
||||
#include <stdint.h>
|
||||
#include <QByteArray>
|
||||
#include <QDateTime>
|
||||
|
||||
@@ -9,12 +11,15 @@
|
||||
class Utility
|
||||
{
|
||||
public:
|
||||
|
||||
static bool decimalMode;
|
||||
|
||||
static int ParseStringToNum(QByteArray input)
|
||||
{
|
||||
int temp = 0;
|
||||
|
||||
input = input.toUpper();
|
||||
if (input.startsWith("0X")) //hex number
|
||||
if (input.startsWith("0X") || input.startsWith("X")) //hex number
|
||||
{
|
||||
temp = input.right(input.size() - 2).toInt(NULL, 16);
|
||||
}
|
||||
@@ -47,14 +52,25 @@ public:
|
||||
|
||||
//prints hex numbers in uppercase with 0's filling out the number depending
|
||||
//on the size needed. Promotes hex numbers to either 2, 4, or 8 digits
|
||||
static QString formatHexNum(int input)
|
||||
static QString formatHexNum(uint64_t input)
|
||||
{
|
||||
if (input < 256)
|
||||
return QString::number(input, 16).toUpper().rightJustified(2,'0');
|
||||
return "0x" + QString::number(input, 16).toUpper().rightJustified(2,'0');
|
||||
if (input < 65536)
|
||||
return QString::number(input, 16).toUpper().rightJustified(4,'0');
|
||||
return "0x" + QString::number(input, 16).toUpper().rightJustified(4,'0');
|
||||
if (input < 4294967296)
|
||||
return "0x" + QString::number(input, 16).toUpper().rightJustified(8,'0');
|
||||
return "0x" + QString::number(input, 16).toUpper().rightJustified(16,'0');
|
||||
}
|
||||
|
||||
return QString::number(input, 16).toUpper().rightJustified(8,'0');
|
||||
//uses decimalMode to see if it should show value as decimal or hex
|
||||
static QString formatNumber(uint64_t value)
|
||||
{
|
||||
if (decimalMode)
|
||||
{
|
||||
return QString::number(value, 10);
|
||||
}
|
||||
else return formatHexNum(value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user