Added more functionality for new DBC editing system. Tweaked graphics of CANDataGrid a bit.
This commit is contained in:
@@ -44,6 +44,7 @@ SOURCES += main.cpp\
|
||||
dbc/dbchandler.cpp \
|
||||
dbc/dbcloadsavewindow.cpp \
|
||||
dbc/dbcmaineditor.cpp \
|
||||
dbc/dbcnodeeditor.cpp \
|
||||
dbc/dbcsignaleditor.cpp \
|
||||
re/discretestatewindow.cpp \
|
||||
re/filecomparatorwindow.cpp \
|
||||
@@ -105,6 +106,7 @@ HEADERS += mainwindow.h \
|
||||
dbc/dbcmaineditor.h \
|
||||
dbc/dbcsignaleditor.h \
|
||||
dbc/dbcmessageeditor.h \
|
||||
dbc/dbcnodeeditor.h \
|
||||
re/discretestatewindow.h \
|
||||
re/filecomparatorwindow.h \
|
||||
re/flowviewwindow.h \
|
||||
@@ -139,6 +141,7 @@ FORMS += ui/candatagrid.ui \
|
||||
ui/dbcloadsavewindow.ui \
|
||||
ui/dbcmaineditor.ui \
|
||||
ui/dbcsignaleditor.ui \
|
||||
ui/dbcnodeeditor.ui \
|
||||
ui/discretestatewindow.ui \
|
||||
ui/filecomparatorwindow.ui \
|
||||
ui/firmwareuploaderwindow.ui \
|
||||
|
||||
+22
-2
@@ -14,6 +14,7 @@ CANDataGrid::CANDataGrid(QWidget *parent) :
|
||||
memset(data, 0, 8);
|
||||
memset(refData, 0, 8);
|
||||
memset(usedData, 0, 8);
|
||||
memset(usedSignalNum, 0, 64);
|
||||
for (int x = 0; x < 8; x++)
|
||||
for (int y = 0; y < 8; y++)
|
||||
textStates[x][y] = GridTextState::NORMAL;
|
||||
@@ -53,7 +54,7 @@ void CANDataGrid::setCellTextState(int x, int y, GridTextState state)
|
||||
this->update();
|
||||
}
|
||||
|
||||
GridTextState CANDataGrid::geCellTextState(int x, int y)
|
||||
GridTextState CANDataGrid::getCellTextState(int x, int y)
|
||||
{
|
||||
if (x < 0) return GridTextState::NORMAL;
|
||||
if (x > 7) return GridTextState::NORMAL;
|
||||
@@ -62,6 +63,21 @@ GridTextState CANDataGrid::geCellTextState(int x, int y)
|
||||
return textStates[x][y];
|
||||
}
|
||||
|
||||
void CANDataGrid::setUsedSignalNum(int bit, unsigned char signal)
|
||||
{
|
||||
if (bit < 0) return;
|
||||
if (bit > 63) return;
|
||||
usedSignalNum[bit] = signal;
|
||||
}
|
||||
|
||||
unsigned char CANDataGrid::getUsedSignalNum(int bit)
|
||||
{
|
||||
if (bit < 0) return 0;
|
||||
if (bit > 63) return 0;
|
||||
return usedSignalNum[bit];
|
||||
}
|
||||
|
||||
|
||||
void CANDataGrid::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
@@ -161,7 +177,11 @@ void CANDataGrid::paintEvent(QPaintEvent *event)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((usedData[y] & (1 << (7-x))) == (1 << (7-x))) painter.setBrush(grayBrush);
|
||||
if ((usedData[y] & (1 << (7-x))) == (1 << (7-x)))
|
||||
{
|
||||
grayBrush = QBrush(QColor(0xB6, 0xB6, 0xB6), Qt::BDiagPattern);
|
||||
painter.setBrush(grayBrush);
|
||||
}
|
||||
else painter.setBrush(whiteBrush);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -19,6 +19,9 @@ class CANDataGrid;
|
||||
* Then, support was added for modifying the text color of each cell. This can be used for whatever the calling code wants. An example is
|
||||
* FlowView that uses all of the above functionality plus this functionality in order to show which bits are set as triggers for stopping
|
||||
* the flowview playback.
|
||||
*
|
||||
* Now the control also tracks which signal is using which bit. Currently this is not used for graphical output. I tried but couldn't make it look
|
||||
* like I wanted. So, it's un-used as of yet.
|
||||
*/
|
||||
|
||||
enum GridTextState
|
||||
@@ -41,7 +44,9 @@ public:
|
||||
void setUsed(unsigned char *, bool);
|
||||
void saveImage(QString filename, int width, int height);
|
||||
void setCellTextState(int x, int y, GridTextState state);
|
||||
GridTextState geCellTextState(int x, int y);
|
||||
GridTextState getCellTextState(int x, int y);
|
||||
void setUsedSignalNum(int bit, unsigned char signal);
|
||||
unsigned char getUsedSignalNum(int bit);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||
@@ -54,6 +59,7 @@ private:
|
||||
unsigned char refData[8];
|
||||
unsigned char data[8];
|
||||
unsigned char usedData[8];
|
||||
unsigned char usedSignalNum[64]; //allows a full char per 64 bits we track so we can specify which signal claims this bit
|
||||
GridTextState textStates[8][8];
|
||||
QPoint upperLeft, gridSize;
|
||||
};
|
||||
|
||||
+60
-144
@@ -22,10 +22,18 @@ DBCMainEditor::DBCMainEditor( const QVector<CANFrame> *frames, QWidget *parent)
|
||||
|
||||
connect(ui->btnSearch, &QAbstractButton::clicked, this, &DBCMainEditor::handleSearch);
|
||||
connect(ui->lineSearch, &QLineEdit::returnPressed, this, &DBCMainEditor::handleSearch);
|
||||
connect(ui->btnSearchNext, &QAbstractButton::clicked, this, &DBCMainEditor::handleSearchForward);
|
||||
connect(ui->btnSearchPrev, &QAbstractButton::clicked, this, &DBCMainEditor::handleSearchBackward);
|
||||
connect(ui->treeDBC, &QTreeWidget::doubleClicked, this, &DBCMainEditor::onTreeDoubleClicked);
|
||||
|
||||
sigEditor = new DBCSignalEditor(this);
|
||||
msgEditor = new DBCMessageEditor(this);
|
||||
nodeEditor = new DBCNodeEditor(this);
|
||||
|
||||
//all three might potentially change the data stored and force the tree to be updated
|
||||
connect(sigEditor, &DBCSignalEditor::updatedTreeInfo, this, &DBCMainEditor::updatedTreeInfo);
|
||||
connect(msgEditor, &DBCMessageEditor::updatedTreeInfo, this, &DBCMainEditor::updatedTreeInfo);
|
||||
connect(nodeEditor, &DBCNodeEditor::updatedTreeInfo, this, &DBCMainEditor::updatedTreeInfo);
|
||||
|
||||
nodeIcon = QIcon(":/icons/images/node.png");
|
||||
messageIcon = QIcon(":/icons/images/message.png");
|
||||
@@ -60,6 +68,8 @@ DBCMainEditor::~DBCMainEditor()
|
||||
removeEventFilter(this);
|
||||
delete ui;
|
||||
delete sigEditor;
|
||||
delete msgEditor;
|
||||
delete nodeEditor;
|
||||
}
|
||||
|
||||
bool DBCMainEditor::eventFilter(QObject *obj, QEvent *event)
|
||||
@@ -71,6 +81,12 @@ bool DBCMainEditor::eventFilter(QObject *obj, QEvent *event)
|
||||
case Qt::Key_F1:
|
||||
HelpWindow::getRef()->showHelp("dbc_editor.html");
|
||||
break;
|
||||
case Qt::Key_F3:
|
||||
handleSearchForward();
|
||||
break;
|
||||
case Qt::Key_F4:
|
||||
handleSearchBackward();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@@ -160,78 +176,36 @@ void DBCMainEditor::deleteCurrentTreeItem()
|
||||
|
||||
void DBCMainEditor::handleSearch()
|
||||
{
|
||||
/*
|
||||
uint32_t msgId = Utility::ParseStringToNum(ui->lineSearch->text());
|
||||
if (ui->radioID->isChecked())
|
||||
searchItems = ui->treeDBC->findItems(ui->lineSearch->text(),Qt::MatchContains | Qt::MatchRecursive);
|
||||
qDebug() << "Search returned " << searchItems.count() << "items.";
|
||||
if (searchItems.count() > 0)
|
||||
{
|
||||
DBC_MESSAGE *msg = dbcFile->messageHandler->findMsgByID(msgId);
|
||||
if (msg)
|
||||
{
|
||||
DBC_NODE *node = msg->sender;
|
||||
if (node)
|
||||
{
|
||||
QString nodeName = node->name;
|
||||
for (int i = 0; i < ui->NodesTable->rowCount(); i++)
|
||||
{
|
||||
QTableWidgetItem *item = ui->NodesTable->item(i, 0);
|
||||
if (item->text() == nodeName)
|
||||
{
|
||||
item->setSelected(true);
|
||||
ui->NodesTable->scrollToItem(item);
|
||||
onCellClickedNode(i, 0);
|
||||
for (int j = 0; j < ui->MessagesTable->rowCount(); j++)
|
||||
{
|
||||
QTableWidgetItem *msgItem = ui->MessagesTable->item(j, 0);
|
||||
if (!msgItem) break;
|
||||
if (Utility::ParseStringToNum(msgItem->text()) == msgId)
|
||||
{
|
||||
msgItem->setSelected(true);
|
||||
ui->MessagesTable->scrollToItem(msgItem);
|
||||
onCellClickedMessage(j, 0);
|
||||
break;
|
||||
ui->treeDBC->setCurrentItem(searchItems[0]);
|
||||
searchItemPos = 0;
|
||||
ui->lblSearchPos->setText("Search Results: " + QString::number(searchItemPos + 1) + " of " + QString::number(searchItems.count()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ui->radioName->isChecked())
|
||||
else
|
||||
{
|
||||
DBC_MESSAGE *msg = dbcFile->messageHandler->findMsgByPartialName(ui->lineSearch->text());
|
||||
if (msg)
|
||||
{
|
||||
DBC_NODE *node = msg->sender;
|
||||
if (node)
|
||||
{
|
||||
QString nodeName = node->name;
|
||||
for (int i = 0; i < ui->NodesTable->rowCount(); i++)
|
||||
{
|
||||
QTableWidgetItem *item = ui->NodesTable->item(i, 0);
|
||||
if (item->text() == nodeName)
|
||||
{
|
||||
item->setSelected(true);
|
||||
ui->NodesTable->scrollToItem(item);
|
||||
onCellClickedNode(i, 0);
|
||||
for (int j = 0; j < ui->MessagesTable->rowCount(); j++)
|
||||
{
|
||||
QTableWidgetItem *msgItem = ui->MessagesTable->item(j, 1);
|
||||
if (!msgItem) break;
|
||||
if (msgItem->text().contains(ui->lineSearch->text(), Qt::CaseInsensitive))
|
||||
{
|
||||
msgItem->setSelected(true);
|
||||
ui->MessagesTable->scrollToItem(msgItem);
|
||||
onCellClickedMessage(j, 0);
|
||||
break;
|
||||
ui->lblSearchPos->setText("Search Results: 0 of 0");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
void DBCMainEditor::handleSearchForward()
|
||||
{
|
||||
if (searchItems.count() == 0) return;
|
||||
if (searchItemPos < searchItems.count() - 1) searchItemPos++;
|
||||
else searchItemPos = 0;
|
||||
ui->treeDBC->setCurrentItem(searchItems[searchItemPos]);
|
||||
ui->lblSearchPos->setText("Search Results: " + QString::number(searchItemPos + 1) + " of " + QString::number(searchItems.count()));
|
||||
}
|
||||
|
||||
void DBCMainEditor::handleSearchBackward()
|
||||
{
|
||||
if (searchItems.count() == 0) return;
|
||||
if (searchItemPos > 0) searchItemPos--;
|
||||
else searchItemPos = searchItems.count() - 1;
|
||||
ui->treeDBC->setCurrentItem(searchItems[searchItemPos]);
|
||||
ui->lblSearchPos->setText("Search Results: " + QString::number(searchItemPos + 1) + " of " + QString::number(searchItems.count()));
|
||||
}
|
||||
|
||||
//Double clicking is interpreted as a desire to edit the given item.
|
||||
@@ -243,6 +217,7 @@ void DBCMainEditor::onTreeDoubleClicked(const QModelIndex &index)
|
||||
bool ret = false;
|
||||
DBC_MESSAGE *msg;
|
||||
DBC_SIGNAL *sig;
|
||||
DBC_NODE *node;
|
||||
uint32_t msgID;
|
||||
QString idString;
|
||||
|
||||
@@ -251,6 +226,12 @@ void DBCMainEditor::onTreeDoubleClicked(const QModelIndex &index)
|
||||
switch (firstCol->data(0, Qt::UserRole).toInt())
|
||||
{
|
||||
case 1: //a node
|
||||
idString = firstCol->text(0).split(" ")[0];
|
||||
node = dbcFile->findNodeByName(idString);
|
||||
nodeEditor->setFileIdx(fileIdx);
|
||||
nodeEditor->setNodeRef(node);
|
||||
nodeEditor->refreshView();
|
||||
nodeEditor->show();
|
||||
break;
|
||||
case 2: //a message
|
||||
idString = firstCol->text(0).split(" ")[0];
|
||||
@@ -258,8 +239,9 @@ void DBCMainEditor::onTreeDoubleClicked(const QModelIndex &index)
|
||||
msg = dbcFile->messageHandler->findMsgByID(msgID);
|
||||
msgEditor->setMessageRef(msg);
|
||||
msgEditor->setFileIdx(fileIdx);
|
||||
msgEditor->setWindowModality(Qt::WindowModal);
|
||||
msgEditor->exec(); //blocks this window from being active until we're done
|
||||
//msgEditor->setWindowModality(Qt::WindowModal);
|
||||
msgEditor->refreshView();
|
||||
msgEditor->show(); //show allows the rest of the forms to keep going
|
||||
break;
|
||||
case 3: //a signal
|
||||
idString = firstCol->parent()->text(0).split(" ")[0];
|
||||
@@ -269,82 +251,11 @@ void DBCMainEditor::onTreeDoubleClicked(const QModelIndex &index)
|
||||
sigEditor->setSignalRef(sig);
|
||||
sigEditor->setMessageRef(msg);
|
||||
sigEditor->setFileIdx(fileIdx);
|
||||
sigEditor->setWindowModality(Qt::WindowModal);
|
||||
sigEditor->exec(); //blocks this window from being active until we're done
|
||||
//sigEditor->setWindowModality(Qt::WindowModal);
|
||||
sigEditor->refreshView();
|
||||
sigEditor->show();
|
||||
break;
|
||||
}
|
||||
|
||||
/* if (col == 3) //3 is the signals field. If clicked we go to the signals dialog
|
||||
{
|
||||
QTableWidgetItem* msg = ui->MessagesTable->item(row, 0);
|
||||
if(msg) {
|
||||
QString idString = msg->text();
|
||||
DBC_MESSAGE *message = dbcFile->messageHandler->findMsgByID(static_cast<uint32_t>(Utility::ParseStringToNum(idString)));
|
||||
sigEditor->setMessageRef(message);
|
||||
sigEditor->setFileIdx(fileIdx);
|
||||
sigEditor->setWindowModality(Qt::WindowModal);
|
||||
sigEditor->exec(); //blocks this window from being active until we're done
|
||||
//now update the displayed # of signals
|
||||
inhibitCellChanged = true;
|
||||
QTableWidgetItem *replacement = new QTableWidgetItem(QString::number(message->sigHandler->getCount()));
|
||||
ui->MessagesTable->setItem(row, col, replacement);
|
||||
inhibitCellChanged = false;
|
||||
}
|
||||
}
|
||||
if (col == 4)
|
||||
{
|
||||
QColor newColor = QColorDialog::getColor(thisItem->background().color());
|
||||
thisItem->setBackground(newColor);
|
||||
|
||||
if(!firstCol) return;
|
||||
|
||||
msgID = Utility::ParseStringToNum2(firstCol->text(), &ret);
|
||||
msg = dbcFile->messageHandler->findMsgByID(msgID);
|
||||
|
||||
if (msg)
|
||||
{
|
||||
msg->fgColor = newColor;
|
||||
DBC_ATTRIBUTE_VALUE *val = msg->findAttrValByName("GenMsgForegroundColor");
|
||||
if (val)
|
||||
{
|
||||
val->value = newColor.name();
|
||||
}
|
||||
else
|
||||
{
|
||||
DBC_ATTRIBUTE_VALUE newVal;
|
||||
newVal.attrName = "GenMsgForegroundColor";
|
||||
newVal.value = newColor.name();
|
||||
msg->attributes.append(newVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (col == 5)
|
||||
{
|
||||
QColor newColor = QColorDialog::getColor(thisItem->background().color());
|
||||
thisItem->setBackground(newColor);
|
||||
|
||||
if(!firstCol) return;
|
||||
|
||||
msgID = Utility::ParseStringToNum2(firstCol->text(), &ret);
|
||||
msg = dbcFile->messageHandler->findMsgByID(msgID);
|
||||
|
||||
if (msg)
|
||||
{
|
||||
msg->bgColor = newColor;
|
||||
DBC_ATTRIBUTE_VALUE *val = msg->findAttrValByName("GenMsgBackgroundColor");
|
||||
if (val)
|
||||
{
|
||||
val->value = newColor.name();
|
||||
}
|
||||
else
|
||||
{
|
||||
DBC_ATTRIBUTE_VALUE newVal;
|
||||
newVal.attrName = "GenMsgBackgroundColor";
|
||||
newVal.value = newColor.name();
|
||||
msg->attributes.append(newVal);
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
@@ -401,3 +312,8 @@ void DBCMainEditor::refreshTree()
|
||||
}
|
||||
ui->treeDBC->sortItems(0, Qt::SortOrder::AscendingOrder); //sort the display list for ease in viewing by mere mortals, helps me a lot.
|
||||
}
|
||||
|
||||
void DBCMainEditor::updatedTreeInfo(QString oldData, QString newData, int type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
+11
-2
@@ -4,9 +4,11 @@
|
||||
#include <QDialog>
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
#include <QTreeWidget>
|
||||
#include "dbchandler.h"
|
||||
#include "dbcsignaleditor.h"
|
||||
#include "dbcmessageeditor.h"
|
||||
#include "dbcnodeeditor.h"
|
||||
#include "utility.h"
|
||||
|
||||
namespace Ui {
|
||||
@@ -22,11 +24,16 @@ public:
|
||||
~DBCMainEditor();
|
||||
void setFileIdx(int idx);
|
||||
|
||||
public slots:
|
||||
void updatedTreeInfo(QString oldData, QString newData, int type);
|
||||
|
||||
private slots:
|
||||
void onTreeDoubleClicked(const QModelIndex &index);
|
||||
void onCustomMenuTree(QPoint);
|
||||
void deleteCurrentTreeItem();
|
||||
void handleSearch();
|
||||
void handleSearchForward();
|
||||
void handleSearchBackward();
|
||||
|
||||
private:
|
||||
Ui::DBCMainEditor *ui;
|
||||
@@ -34,6 +41,7 @@ private:
|
||||
const QVector<CANFrame> *referenceFrames;
|
||||
DBCSignalEditor *sigEditor;
|
||||
DBCMessageEditor *msgEditor;
|
||||
DBCNodeEditor *nodeEditor;
|
||||
DBCFile *dbcFile;
|
||||
int fileIdx;
|
||||
QIcon nodeIcon;
|
||||
@@ -41,14 +49,15 @@ private:
|
||||
QIcon signalIcon;
|
||||
QIcon multiplexorSignalIcon;
|
||||
QIcon multiplexedSignalIcon;
|
||||
QList<QTreeWidgetItem *> searchItems;
|
||||
int searchItemPos;
|
||||
|
||||
void refreshTree();
|
||||
void showEvent(QShowEvent* event);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
void refreshTree();
|
||||
};
|
||||
|
||||
#endif // DBCMAINEDITOR_H
|
||||
|
||||
@@ -19,6 +19,10 @@ public:
|
||||
void showEvent(QShowEvent*);
|
||||
void setMessageRef(DBC_MESSAGE *msg);
|
||||
void setFileIdx(int idx);
|
||||
void refreshView();
|
||||
|
||||
signals:
|
||||
void updatedTreeInfo(QString oldData, QString newData, int type);
|
||||
|
||||
private:
|
||||
Ui::DBCMessageEditor *ui;
|
||||
@@ -31,7 +35,6 @@ private:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
void refreshView();
|
||||
void generateSampleText();
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
#include "dbcnodeeditor.h"
|
||||
#include "ui_dbcnodeeditor.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QKeyEvent>
|
||||
#include <QColorDialog>
|
||||
#include "helpwindow.h"
|
||||
#include "utility.h"
|
||||
|
||||
DBCNodeEditor::DBCNodeEditor(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DBCNodeEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
readSettings();
|
||||
|
||||
dbcHandler = DBCHandler::getReference();
|
||||
dbcNode = nullptr;
|
||||
|
||||
installEventFilter(this);
|
||||
}
|
||||
|
||||
DBCNodeEditor::~DBCNodeEditor()
|
||||
{
|
||||
removeEventFilter(this);
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DBCNodeEditor::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
bool DBCNodeEditor::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.html");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// standard event processing
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DBCNodeEditor::setFileIdx(int idx)
|
||||
{
|
||||
if (idx < 0 || idx > dbcHandler->getFileCount() - 1) return;
|
||||
dbcFile = dbcHandler->getFileByIdx(idx);
|
||||
}
|
||||
|
||||
void DBCNodeEditor::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||
{
|
||||
resize(settings.value("DBCNodeEditor/WindowSize", QSize(312, 128)).toSize());
|
||||
move(settings.value("DBCNodeEditor/WindowPos", QPoint(100, 100)).toPoint());
|
||||
}
|
||||
}
|
||||
|
||||
void DBCNodeEditor::writeSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||
{
|
||||
settings.setValue("DBCNodeEditor/WindowSize", size());
|
||||
settings.setValue("DBCNodeEditor/WindowPos", pos());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DBCNodeEditor::setNodeRef(DBC_NODE *node)
|
||||
{
|
||||
dbcNode = node;
|
||||
}
|
||||
|
||||
void DBCNodeEditor::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
|
||||
refreshView();
|
||||
}
|
||||
|
||||
void DBCNodeEditor::refreshView()
|
||||
{
|
||||
ui->lineComment->setText(dbcNode->comment);
|
||||
ui->lineMsgName->setText(dbcNode->name);
|
||||
|
||||
//generateSampleText();
|
||||
}
|
||||
|
||||
void DBCNodeEditor::generateSampleText()
|
||||
{
|
||||
/*
|
||||
QBrush fg, bg;
|
||||
|
||||
if (dbcMessage->fgColor.isValid()) fg = QBrush(dbcMessage->fgColor);
|
||||
else fg = QBrush(QColor(dbcFile->findAttributeByName("GenMsgForegroundColor")->defaultValue.toString()));
|
||||
if (dbcMessage->bgColor.isValid()) bg = QBrush(dbcMessage->bgColor);
|
||||
else bg = QBrush(QColor(dbcFile->findAttributeByName("GenMsgBackgroundColor")->defaultValue.toString()));
|
||||
|
||||
ui->listSample->clear();
|
||||
QListWidgetItem *item = new QListWidgetItem("Test String");
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
ui->listSample->addItem(item);
|
||||
item = new QListWidgetItem("0x20F TestMsg");
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
ui->listSample->addItem(item);
|
||||
item = new QListWidgetItem("20 FF 10 A1 BB CC 4D");
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
ui->listSample->addItem(item);
|
||||
item = new QListWidgetItem("1024.3434");
|
||||
item->setForeground(fg);
|
||||
item->setBackground(bg);
|
||||
ui->listSample->addItem(item);
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef DBCNODEEDITOR_H
|
||||
#define DBCNODEEDITOR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "dbc_classes.h"
|
||||
#include "dbchandler.h"
|
||||
|
||||
namespace Ui {
|
||||
class DBCNodeEditor;
|
||||
}
|
||||
|
||||
class DBCNodeEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DBCNodeEditor(QWidget *parent = nullptr);
|
||||
~DBCNodeEditor();
|
||||
void showEvent(QShowEvent*);
|
||||
void setNodeRef(DBC_NODE *node);
|
||||
void setFileIdx(int idx);
|
||||
void refreshView();
|
||||
|
||||
signals:
|
||||
void updatedTreeInfo(QString oldData, QString newData, int type);
|
||||
|
||||
private:
|
||||
Ui::DBCNodeEditor *ui;
|
||||
|
||||
DBCHandler *dbcHandler;
|
||||
DBC_NODE *dbcNode;
|
||||
DBCFile *dbcFile;
|
||||
|
||||
void closeEvent(QCloseEvent *event);
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
void generateSampleText();
|
||||
};
|
||||
|
||||
#endif // DBCNODEEDITOR_H
|
||||
+11
-2
@@ -125,6 +125,7 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
{
|
||||
if (currentSignal == nullptr) return;
|
||||
currentSignal->comment = ui->txtComment->text().simplified().replace(' ', '_');
|
||||
//updatedTreeInfo();
|
||||
});
|
||||
|
||||
connect(ui->txtUnitName, &QLineEdit::editingFinished,
|
||||
@@ -151,8 +152,8 @@ DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
|
||||
if (currentSignal == nullptr) return;
|
||||
QString tempNameStr = ui->txtName->text().simplified().replace(' ', '_');
|
||||
if (tempNameStr.length() > 0) currentSignal->name = tempNameStr;
|
||||
//need to update the list too.
|
||||
//ui->signalsList->currentItem()->setText(currentSignal->name);
|
||||
//need to update the tree too.
|
||||
//updatedTreeInfo();
|
||||
});
|
||||
|
||||
connect(ui->txtMultiplexValue, &QLineEdit::editingFinished,
|
||||
@@ -286,6 +287,12 @@ void DBCSignalEditor::showEvent(QShowEvent* event)
|
||||
fillValueTable(currentSignal);
|
||||
}
|
||||
|
||||
void DBCSignalEditor::refreshView()
|
||||
{
|
||||
fillSignalForm(currentSignal);
|
||||
fillValueTable(currentSignal);
|
||||
}
|
||||
|
||||
void DBCSignalEditor::onValuesCellChanged(int row,int col)
|
||||
{
|
||||
if (inhibitCellChanged) return;
|
||||
@@ -519,6 +526,7 @@ void DBCSignalEditor::generateUsedBits()
|
||||
{
|
||||
int byt = y / 8;
|
||||
usedBits[byt] |= 1 << (y % 8);
|
||||
ui->bitfield->setUsedSignalNum(y, x);
|
||||
}
|
||||
}
|
||||
else //big endian / motorola format
|
||||
@@ -529,6 +537,7 @@ void DBCSignalEditor::generateUsedBits()
|
||||
{
|
||||
int byt = startBit / 8;
|
||||
usedBits[byt] |= 1 << (startBit % 8);
|
||||
ui->bitfield->setUsedSignalNum(startBit, x);
|
||||
size--;
|
||||
if ((startBit % 8) == 0) startBit += 15;
|
||||
else startBit--;
|
||||
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
void setSignalRef(DBC_SIGNAL *sig);
|
||||
void showEvent(QShowEvent*);
|
||||
~DBCSignalEditor();
|
||||
void refreshView();
|
||||
|
||||
signals:
|
||||
void updatedTreeInfo(QString oldData, QString newData, int type);
|
||||
|
||||
private slots:
|
||||
void bitfieldClicked(int x, int y);
|
||||
|
||||
+56
-18
@@ -32,6 +32,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewMessage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Message</string>
|
||||
</property>
|
||||
@@ -46,6 +49,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnNewSignal">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Signal</string>
|
||||
</property>
|
||||
@@ -60,6 +66,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDelete">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
@@ -91,6 +100,27 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeDBC">
|
||||
<property name="dragEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::NoDragDrop</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::IgnoreAction</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="indentation">
|
||||
<number>28</number>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
@@ -107,30 +137,13 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Find DBC Message:</string>
|
||||
<string>Find:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineSearch"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioID">
|
||||
<property name="text">
|
||||
<string>Msg ID</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioName">
|
||||
<property name="text">
|
||||
<string>Msg Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSearch">
|
||||
<property name="text">
|
||||
@@ -140,6 +153,31 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblSearchPos">
|
||||
<property name="text">
|
||||
<string>Search Results: 0 of 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSearchNext">
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSearchPrev">
|
||||
<property name="text">
|
||||
<string>Previous</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DBCMessageEditor</class>
|
||||
<widget class="QDialog" name="DBCMessageEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>311</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Message Editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Frame ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineFrameID"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineMsgName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Message Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineFrameLen"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Frame Length:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Text Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Background Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Comments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lineComment"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Sending Node:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="comboSender"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="btnTextColor">
|
||||
<property name="text">
|
||||
<string>Set</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="btnBackgroundColor">
|
||||
<property name="text">
|
||||
<string>Set</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Sample Colored Output:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listSample"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DBCNodeEditor</class>
|
||||
<widget class="QDialog" name="DBCNodeEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>311</width>
|
||||
<height>128</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Node Editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<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>Comments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineComment"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClose">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user