Added ability to create new DBC files from the DBC file manager,
hooked up ability to change associated bus for DBC files.
This commit is contained in:
@@ -731,6 +731,13 @@ void DBCHandler::saveDBCFile(int idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DBCHandler::createBlankFile()
|
||||||
|
{
|
||||||
|
DBCFile newFile;
|
||||||
|
loadedFiles.append(newFile);
|
||||||
|
return loadedFiles.count();
|
||||||
|
}
|
||||||
|
|
||||||
//the only reason to even bother sending the index is to see if
|
//the only reason to even bother sending the index is to see if
|
||||||
//the user wants to replace an already loaded DBC.
|
//the user wants to replace an already loaded DBC.
|
||||||
//Otherwise add a new one. Well, always add a new one.
|
//Otherwise add a new one. Well, always add a new one.
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public:
|
|||||||
int getFileCount();
|
int getFileCount();
|
||||||
DBCFile* getFileByIdx(int idx);
|
DBCFile* getFileByIdx(int idx);
|
||||||
DBCFile* getFileByName(QString name);
|
DBCFile* getFileByName(QString name);
|
||||||
|
int createBlankFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<DBCFile> loadedFiles;
|
QList<DBCFile> loadedFiles;
|
||||||
|
|||||||
+23
-2
@@ -24,6 +24,7 @@ DBCLoadSaveWindow::DBCLoadSaveWindow(DBCHandler *handler, const QVector<CANFrame
|
|||||||
connect(ui->btnMoveUp, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::moveUp);
|
connect(ui->btnMoveUp, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::moveUp);
|
||||||
connect(ui->btnRemove, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::removeFile);
|
connect(ui->btnRemove, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::removeFile);
|
||||||
connect(ui->btnSave, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::saveFile);
|
connect(ui->btnSave, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::saveFile);
|
||||||
|
connect(ui->btnNewDBC, &QAbstractButton::clicked, this, &DBCLoadSaveWindow::newFile);
|
||||||
connect(ui->tableFiles, &QTableWidget::cellChanged, this, &DBCLoadSaveWindow::cellChanged);
|
connect(ui->tableFiles, &QTableWidget::cellChanged, this, &DBCLoadSaveWindow::cellChanged);
|
||||||
connect(ui->tableFiles, &QTableWidget::cellDoubleClicked, this, &DBCLoadSaveWindow::cellDoubleClicked);
|
connect(ui->tableFiles, &QTableWidget::cellDoubleClicked, this, &DBCLoadSaveWindow::cellDoubleClicked);
|
||||||
|
|
||||||
@@ -35,6 +36,15 @@ DBCLoadSaveWindow::~DBCLoadSaveWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DBCLoadSaveWindow::newFile()
|
||||||
|
{
|
||||||
|
int idx = dbcHandler->createBlankFile();
|
||||||
|
idx = ui->tableFiles->rowCount();
|
||||||
|
ui->tableFiles->insertRow(ui->tableFiles->rowCount());
|
||||||
|
ui->tableFiles->setItem(idx, 0, new QTableWidgetItem("UNNAMEDFILE"));
|
||||||
|
ui->tableFiles->setItem(idx, 1, new QTableWidgetItem("-1"));
|
||||||
|
}
|
||||||
|
|
||||||
void DBCLoadSaveWindow::loadFile()
|
void DBCLoadSaveWindow::loadFile()
|
||||||
{
|
{
|
||||||
DBCFile *file = dbcHandler->loadDBCFile(-1);
|
DBCFile *file = dbcHandler->loadDBCFile(-1);
|
||||||
@@ -49,6 +59,8 @@ void DBCLoadSaveWindow::saveFile()
|
|||||||
int idx = ui->tableFiles->currentRow();
|
int idx = ui->tableFiles->currentRow();
|
||||||
if (idx < 0) return;
|
if (idx < 0) return;
|
||||||
dbcHandler->saveDBCFile(idx);
|
dbcHandler->saveDBCFile(idx);
|
||||||
|
//then update the list to show the new file name (if it changed)
|
||||||
|
ui->tableFiles->setItem(idx, 0, new QTableWidgetItem(dbcHandler->getFileByIdx(idx)->getFullFilename()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBCLoadSaveWindow::removeFile()
|
void DBCLoadSaveWindow::removeFile()
|
||||||
@@ -87,12 +99,21 @@ void DBCLoadSaveWindow::editFile()
|
|||||||
|
|
||||||
void DBCLoadSaveWindow::cellChanged(int row, int col)
|
void DBCLoadSaveWindow::cellChanged(int row, int col)
|
||||||
{
|
{
|
||||||
|
if (col == 1) //the bus column
|
||||||
|
{
|
||||||
|
DBCFile *file = dbcHandler->getFileByIdx(row);
|
||||||
|
int bus = ui->tableFiles->item(row, col)->text().toInt();
|
||||||
|
if (bus > -2 && bus < 2)
|
||||||
|
{
|
||||||
|
file->setAssocBus(bus);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBCLoadSaveWindow::cellDoubleClicked(int row, int col)
|
void DBCLoadSaveWindow::cellDoubleClicked(int row, int col)
|
||||||
{
|
{
|
||||||
|
editorWindow->setFileIdx(row);
|
||||||
|
editorWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBCLoadSaveWindow::swapTableRows(bool up)
|
void DBCLoadSaveWindow::swapTableRows(bool up)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ private slots:
|
|||||||
void editFile();
|
void editFile();
|
||||||
void cellChanged(int row, int col);
|
void cellChanged(int row, int col);
|
||||||
void cellDoubleClicked(int row, int col);
|
void cellDoubleClicked(int row, int col);
|
||||||
|
void newFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DBCLoadSaveWindow *ui;
|
Ui::DBCLoadSaveWindow *ui;
|
||||||
|
|||||||
@@ -17,6 +17,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTableWidget" name="tableFiles"/>
|
<widget class="QTableWidget" name="tableFiles"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnNewDBC">
|
||||||
|
<property name="text">
|
||||||
|
<string>Create new DBC</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
Reference in New Issue
Block a user