rebase working but definitely needs clean up for all the whatifs
This commit is contained in:
@@ -67,6 +67,7 @@ SOURCES += main.cpp\
|
|||||||
dbc/dbcmaineditor.cpp \
|
dbc/dbcmaineditor.cpp \
|
||||||
dbc/dbcnodeeditor.cpp \
|
dbc/dbcnodeeditor.cpp \
|
||||||
dbc/dbcsignaleditor.cpp \
|
dbc/dbcsignaleditor.cpp \
|
||||||
|
dbc/dbcnoderebaseeditor.cpp \
|
||||||
re/discretestatewindow.cpp \
|
re/discretestatewindow.cpp \
|
||||||
re/filecomparatorwindow.cpp \
|
re/filecomparatorwindow.cpp \
|
||||||
re/flowviewwindow.cpp \
|
re/flowviewwindow.cpp \
|
||||||
@@ -100,6 +101,7 @@ HEADERS += mainwindow.h \
|
|||||||
canframemodel.h \
|
canframemodel.h \
|
||||||
connections/socketcand.h \
|
connections/socketcand.h \
|
||||||
connections/mqtt_bus.h \
|
connections/mqtt_bus.h \
|
||||||
|
dbc/dbcnoderebaseeditor.h \
|
||||||
mqtt/qmqtt.h \
|
mqtt/qmqtt.h \
|
||||||
mqtt/qmqtt_client.h \
|
mqtt/qmqtt_client.h \
|
||||||
mqtt/qmqtt_client_p.h \
|
mqtt/qmqtt_client_p.h \
|
||||||
@@ -188,6 +190,7 @@ FORMS += ui/candatagrid.ui \
|
|||||||
ui/connectionwindow.ui \
|
ui/connectionwindow.ui \
|
||||||
ui/dbcloadsavewindow.ui \
|
ui/dbcloadsavewindow.ui \
|
||||||
ui/dbcmaineditor.ui \
|
ui/dbcmaineditor.ui \
|
||||||
|
ui/dbcnoderebaseeditor.ui \
|
||||||
ui/dbcsignaleditor.ui \
|
ui/dbcsignaleditor.ui \
|
||||||
ui/dbcnodeeditor.ui \
|
ui/dbcnodeeditor.ui \
|
||||||
ui/discretestatewindow.ui \
|
ui/discretestatewindow.ui \
|
||||||
|
|||||||
@@ -380,6 +380,7 @@ void CANFrameModel::recalcOverwrite()
|
|||||||
//Then replace the old list of frames with just the unique list
|
//Then replace the old list of frames with just the unique list
|
||||||
frames.clear();
|
frames.clear();
|
||||||
frames.append(overWriteFrames.values().toVector());
|
frames.append(overWriteFrames.values().toVector());
|
||||||
|
frames.reserve(preallocSize);
|
||||||
|
|
||||||
filteredFrames.clear();
|
filteredFrames.clear();
|
||||||
filteredFrames.reserve(preallocSize);
|
filteredFrames.reserve(preallocSize);
|
||||||
|
|||||||
@@ -177,6 +177,24 @@ DBC_MESSAGE* DBCMessageHandler::findMsgByPartialName(QString name)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<DBC_MESSAGE*> DBCMessageHandler::findMsgsByNode(DBC_NODE* node)
|
||||||
|
{
|
||||||
|
QList<DBC_MESSAGE*> messagesForNode;
|
||||||
|
|
||||||
|
if (messages.count() == 0)
|
||||||
|
return messagesForNode;
|
||||||
|
|
||||||
|
for (int i = 0; i < messages.count(); i++)
|
||||||
|
{
|
||||||
|
if (messages[i].sender == node)
|
||||||
|
{
|
||||||
|
messagesForNode.append(&messages[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return messagesForNode;
|
||||||
|
}
|
||||||
|
|
||||||
bool DBCMessageHandler::addMessage(DBC_MESSAGE &msg)
|
bool DBCMessageHandler::addMessage(DBC_MESSAGE &msg)
|
||||||
{
|
{
|
||||||
messages.append(msg);
|
messages.append(msg);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
DBC_MESSAGE *findMsgByIdx(int idx);
|
DBC_MESSAGE *findMsgByIdx(int idx);
|
||||||
DBC_MESSAGE *findMsgByName(QString name);
|
DBC_MESSAGE *findMsgByName(QString name);
|
||||||
DBC_MESSAGE *findMsgByPartialName(QString name);
|
DBC_MESSAGE *findMsgByPartialName(QString name);
|
||||||
|
QList<DBC_MESSAGE*> findMsgsByNode(DBC_NODE *node);
|
||||||
bool addMessage(DBC_MESSAGE &msg);
|
bool addMessage(DBC_MESSAGE &msg);
|
||||||
bool removeMessage(DBC_MESSAGE *msg);
|
bool removeMessage(DBC_MESSAGE *msg);
|
||||||
bool removeMessageByIndex(int idx);
|
bool removeMessageByIndex(int idx);
|
||||||
|
|||||||
+17
-1
@@ -38,11 +38,13 @@ DBCMainEditor::DBCMainEditor( const QVector<CANFrame> *frames, QWidget *parent)
|
|||||||
sigEditor = new DBCSignalEditor(this);
|
sigEditor = new DBCSignalEditor(this);
|
||||||
msgEditor = new DBCMessageEditor(this);
|
msgEditor = new DBCMessageEditor(this);
|
||||||
nodeEditor = new DBCNodeEditor(this);
|
nodeEditor = new DBCNodeEditor(this);
|
||||||
|
nodeRebaseEditor = new DBCNodeRebaseEditor(this);
|
||||||
|
|
||||||
//all three might potentially change the data stored and force the tree to be updated
|
//all three might potentially change the data stored and force the tree to be updated
|
||||||
connect(sigEditor, &DBCSignalEditor::updatedTreeInfo, this, &DBCMainEditor::updatedSignal);
|
connect(sigEditor, &DBCSignalEditor::updatedTreeInfo, this, &DBCMainEditor::updatedSignal);
|
||||||
connect(msgEditor, &DBCMessageEditor::updatedTreeInfo, this, &DBCMainEditor::updatedMessage);
|
connect(msgEditor, &DBCMessageEditor::updatedTreeInfo, this, &DBCMainEditor::updatedMessage);
|
||||||
connect(nodeEditor, &DBCNodeEditor::updatedTreeInfo, this, &DBCMainEditor::updatedNode);
|
connect(nodeEditor, &DBCNodeEditor::updatedTreeInfo, this, &DBCMainEditor::updatedNode);
|
||||||
|
connect(nodeRebaseEditor, &DBCNodeRebaseEditor::updatedTreeInfo, this, &DBCMainEditor::updatedMessage);
|
||||||
|
|
||||||
nodeIcon = QIcon(":/icons/images/node.png");
|
nodeIcon = QIcon(":/icons/images/node.png");
|
||||||
messageIcon = QIcon(":/icons/images/message.png");
|
messageIcon = QIcon(":/icons/images/message.png");
|
||||||
@@ -339,7 +341,21 @@ void DBCMainEditor::onTreeContextMenu(const QPoint & pos)
|
|||||||
|
|
||||||
void DBCMainEditor::onRebaseMessages()
|
void DBCMainEditor::onRebaseMessages()
|
||||||
{
|
{
|
||||||
qDebug() << "rebase!!";
|
QTreeWidgetItem* firstCol = ui->treeDBC->currentItem();
|
||||||
|
bool ret = false;
|
||||||
|
DBC_MESSAGE *msg;
|
||||||
|
DBC_SIGNAL *sig;
|
||||||
|
DBC_NODE *node;
|
||||||
|
uint32_t msgID;
|
||||||
|
QString idString;
|
||||||
|
|
||||||
|
idString = firstCol->text(0).split(" ")[0];
|
||||||
|
node = dbcFile->findNodeByName(idString);
|
||||||
|
nodeRebaseEditor->setFileIdx(fileIdx);
|
||||||
|
nodeRebaseEditor->setNodeRef(node);
|
||||||
|
nodeRebaseEditor->refreshView();
|
||||||
|
nodeRebaseEditor->setModal(true);
|
||||||
|
nodeRebaseEditor->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBCMainEditor::onDuplicateNode()
|
void DBCMainEditor::onDuplicateNode()
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "dbcsignaleditor.h"
|
#include "dbcsignaleditor.h"
|
||||||
#include "dbcmessageeditor.h"
|
#include "dbcmessageeditor.h"
|
||||||
#include "dbcnodeeditor.h"
|
#include "dbcnodeeditor.h"
|
||||||
|
#include "dbcnoderebaseeditor.h"
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@@ -55,6 +56,7 @@ private:
|
|||||||
DBCSignalEditor *sigEditor;
|
DBCSignalEditor *sigEditor;
|
||||||
DBCMessageEditor *msgEditor;
|
DBCMessageEditor *msgEditor;
|
||||||
DBCNodeEditor *nodeEditor;
|
DBCNodeEditor *nodeEditor;
|
||||||
|
DBCNodeRebaseEditor *nodeRebaseEditor;
|
||||||
DBCFile *dbcFile;
|
DBCFile *dbcFile;
|
||||||
int fileIdx;
|
int fileIdx;
|
||||||
QIcon nodeIcon;
|
QIcon nodeIcon;
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
#include "dbcnoderebaseeditor.h"
|
||||||
|
#include "ui_dbcnoderebaseeditor.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include "helpwindow.h"
|
||||||
|
#include "utility.h"
|
||||||
|
|
||||||
|
DBCNodeRebaseEditor::DBCNodeRebaseEditor(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DBCNodeRebaseEditor)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
readSettings();
|
||||||
|
|
||||||
|
dbcHandler = DBCHandler::getReference();
|
||||||
|
dbcNode = nullptr;
|
||||||
|
|
||||||
|
connect(ui->btnDoRebase, &QPushButton::pressed,
|
||||||
|
[=]()
|
||||||
|
{
|
||||||
|
if (dbcNode == nullptr) return;
|
||||||
|
if (lowestMsgId > 0x1FFFFFFFul) return;
|
||||||
|
|
||||||
|
uint newBase = Utility::ParseStringToNum(ui->lineEdit->text());
|
||||||
|
|
||||||
|
if (newBase <= 0x1FFFFFFFul && newBase != lowestMsgId)
|
||||||
|
{
|
||||||
|
uint rebaseDiff = newBase - lowestMsgId;
|
||||||
|
|
||||||
|
QList<DBC_MESSAGE*> messagesForNode = dbcFile->messageHandler->findMsgsByNode(dbcNode);
|
||||||
|
if(messagesForNode.count() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<messagesForNode.count(); i++)
|
||||||
|
{
|
||||||
|
messagesForNode[i]->ID += rebaseDiff;
|
||||||
|
emit updatedTreeInfo(messagesForNode[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbcFile->setDirtyFlag();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// connect(ui->lineOriginalBaseId, &QLineEdit::editingFinished,
|
||||||
|
// [=]()
|
||||||
|
// {
|
||||||
|
// if (dbcNode == nullptr) return;
|
||||||
|
// if (dbcNode->comment != ui->lineComment->text()) dbcFile->setDirtyFlag();
|
||||||
|
// dbcNode->comment = ui->lineComment->text();
|
||||||
|
// emit updatedTreeInfo(dbcNode);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// connect(ui->lineMsgName, &QLineEdit::editingFinished,
|
||||||
|
// [=]()
|
||||||
|
// {
|
||||||
|
// if (dbcNode == nullptr) return;
|
||||||
|
// if (dbcNode->name != ui->lineMsgName->text()) dbcFile->setDirtyFlag();
|
||||||
|
// dbcNode->name = ui->lineMsgName->text();
|
||||||
|
// emit updatedTreeInfo(dbcNode);
|
||||||
|
// });
|
||||||
|
|
||||||
|
installEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
DBCNodeRebaseEditor::~DBCNodeRebaseEditor()
|
||||||
|
{
|
||||||
|
removeEventFilter(this);
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DBCNodeRebaseEditor::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyRelease) {
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
switch (keyEvent->key())
|
||||||
|
{
|
||||||
|
case Qt::Key_F1:
|
||||||
|
HelpWindow::getRef()->showHelp("nodeeditor.md");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// standard event processing
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::setFileIdx(int idx)
|
||||||
|
{
|
||||||
|
if (idx < 0 || idx > dbcHandler->getFileCount() - 1) return;
|
||||||
|
dbcFile = dbcHandler->getFileByIdx(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::readSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
resize(settings.value("DBCNodeRebaseEditor/WindowSize", QSize(312, 128)).toSize());
|
||||||
|
move(Utility::constrainedWindowPos(settings.value("DBCNodeRebaseEditor/WindowPos", QPoint(100, 100)).toPoint()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::writeSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
settings.setValue("DBCNodeRebaseEditor/WindowSize", size());
|
||||||
|
settings.setValue("DBCNodeRebaseEditor/WindowPos", pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::setNodeRef(DBC_NODE *node)
|
||||||
|
{
|
||||||
|
dbcNode = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::showEvent(QShowEvent* event)
|
||||||
|
{
|
||||||
|
QDialog::showEvent(event);
|
||||||
|
|
||||||
|
refreshView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBCNodeRebaseEditor::refreshView()
|
||||||
|
{
|
||||||
|
if(dbcNode)
|
||||||
|
{
|
||||||
|
QList<DBC_MESSAGE*> messagesForNode = dbcFile->messageHandler->findMsgsByNode(dbcNode);
|
||||||
|
if(messagesForNode.count() == 0)
|
||||||
|
{
|
||||||
|
//??
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
lowestMsgId = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
for (int i=0; i<messagesForNode.count(); i++)
|
||||||
|
{
|
||||||
|
if(messagesForNode[i]->ID < lowestMsgId)
|
||||||
|
lowestMsgId = messagesForNode[i]->ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineOriginalBaseId->setText(Utility::formatCANID(lowestMsgId & 0x1FFFFFFFul));
|
||||||
|
ui->lineMsgName->setText(dbcNode->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//generateSampleText();
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef DBCNODEREBASEEDITOR_H
|
||||||
|
#define DBCNODEREBASEEDITOR_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "dbc_classes.h"
|
||||||
|
#include "dbchandler.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DBCNodeRebaseEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DBCNodeRebaseEditor : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DBCNodeRebaseEditor(QWidget *parent = nullptr);
|
||||||
|
~DBCNodeRebaseEditor();
|
||||||
|
void showEvent(QShowEvent*);
|
||||||
|
void setNodeRef(DBC_NODE *node);
|
||||||
|
void setFileIdx(int idx);
|
||||||
|
void refreshView();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void updatedTreeInfo(DBC_MESSAGE *msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DBCNodeRebaseEditor *ui;
|
||||||
|
|
||||||
|
DBCHandler *dbcHandler;
|
||||||
|
DBC_NODE *dbcNode;
|
||||||
|
DBCFile *dbcFile;
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
|
||||||
|
uint lowestMsgId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DBCNODEREBASEEDITOR_H
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DBCNodeRebaseEditor</class>
|
||||||
|
<widget class="QDialog" name="DBCNodeRebaseEditor">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>303</width>
|
||||||
|
<height>159</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>283</width>
|
||||||
|
<height>116</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Node Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineMsgName"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Current Base ID:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineOriginalBaseId"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>New Base ID:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="btnDoRebase">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rebase All Messages in Node</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="btnCancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user