diff --git a/canframemodel.cpp b/canframemodel.cpp index 71c9b74..e3bb856 100644 --- a/canframemodel.cpp +++ b/canframemodel.cpp @@ -20,6 +20,16 @@ CANFrameModel::CANFrameModel(QObject *parent) timeOffset = 0; } +void CANFrameModel::setHexMode(bool mode) +{ + if (useHexMode != mode) + { + this->beginResetModel(); + useHexMode = mode; + this->endResetModel(); + } +} + void CANFrameModel::setDBCHandler(DBCHandler *handler) { dbcHandler = handler; @@ -104,7 +114,10 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const return QString::number(thisFrame.timestamp); break; case 1: //id - return QString::number(thisFrame.ID, 16).toUpper().rightJustified(2,'0'); + if (useHexMode) + return QString::number(thisFrame.ID, 16).toUpper().rightJustified(2,'0'); + else + return QString::number(thisFrame.ID).rightJustified(3,'0'); break; case 2: //ext return QString::number(thisFrame.extended); @@ -118,7 +131,8 @@ QVariant CANFrameModel::data(const QModelIndex &index, int role) const case 5: //data for (int i = 0; i < thisFrame.len; i++) { - tempString.append(QString::number(thisFrame.data[i], 16).toUpper().rightJustified(2,'0')); + 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(" "); } //now, if we're supposed to interpret the data and the DBC handler is loaded then use it diff --git a/canframemodel.h b/canframemodel.h index d75b266..12a1e2a 100644 --- a/canframemodel.h +++ b/canframemodel.h @@ -30,6 +30,7 @@ public: void setDBCHandler(DBCHandler *); void setInterpetMode(bool); void setOverwriteMode(bool); + void setHexMode(bool); void normalizeTiming(); void recalcOverwrite(); void insertFrames(const QVector &newFrames); @@ -42,6 +43,7 @@ private: QMutex mutex; bool interpretFrames; //should we use the dbcHandler? bool overwriteDups; //should we display all frames or only the newest for each ID? + bool useHexMode; uint64_t timeOffset; }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 7a7a5f6..9b96455 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -43,8 +43,6 @@ MainWindow::MainWindow(QWidget *parent) : QCoreApplication::setOrganizationDomain("evtv.me"); QCoreApplication::setApplicationName("SavvyCAN"); - readSettings(); - selfRef = this; this->setWindowTitle("Savvy CAN V" + QString::number(VERSION)); @@ -52,6 +50,8 @@ MainWindow::MainWindow(QWidget *parent) : model = new CANFrameModel(); ui->canFramesView->setModel(model); + readSettings(); + QStringList headers; headers << "Timestamp" << "ID" << "Ext" << "Bus" << "Len" << "Data"; //model->setHorizontalHeaderLabels(headers); @@ -242,6 +242,7 @@ void MainWindow::readSettings() { ui->cbAutoScroll->setChecked(true); } + model->setHexMode(settings.value("Main/UseHex", true).toBool()); } void MainWindow::writeSettings()