mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-26 17:55:12 +03:00
[Companion] Rename category function added
This commit is contained in:
parent
c707715f3d
commit
1460620483
4 changed files with 26 additions and 7 deletions
|
@ -340,9 +340,9 @@ class Firmware {
|
||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEEpromInterface(EEPROMInterface * interface)
|
void setEEpromInterface(EEPROMInterface * eeprom)
|
||||||
{
|
{
|
||||||
eepromInterface = interface;
|
eepromInterface = eeprom;
|
||||||
}
|
}
|
||||||
|
|
||||||
EEPROMInterface * getEEpromInterface()
|
EEPROMInterface * getEEpromInterface()
|
||||||
|
|
|
@ -51,7 +51,7 @@ MdiChild::MdiChild(MainWindow * parent):
|
||||||
setWindowIcon(CompanionIcon("open.png"));
|
setWindowIcon(CompanionIcon("open.png"));
|
||||||
ui->simulateButton->setIcon(CompanionIcon("simulate.png"));
|
ui->simulateButton->setIcon(CompanionIcon("simulate.png"));
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
onFirmwareChanged();
|
initModelsList();
|
||||||
connect(parent, SIGNAL(FirmwareChanged()), this, SLOT(onFirmwareChanged()));
|
connect(parent, SIGNAL(FirmwareChanged()), this, SLOT(onFirmwareChanged()));
|
||||||
connect(ui->modelsList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openModelEditWindow()));
|
connect(ui->modelsList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openModelEditWindow()));
|
||||||
connect(ui->modelsList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showModelsListContextMenu(const QPoint &)));
|
connect(ui->modelsList, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showModelsListContextMenu(const QPoint &)));
|
||||||
|
@ -154,11 +154,18 @@ void MdiChild::onFirmwareChanged()
|
||||||
{
|
{
|
||||||
Firmware * previous = firmware;
|
Firmware * previous = firmware;
|
||||||
firmware = getCurrentFirmware();
|
firmware = getCurrentFirmware();
|
||||||
BoardEnum board = firmware->getBoard();
|
|
||||||
qDebug() << "onFirmwareChanged" << previous->getName() << "=>" << firmware->getName();
|
qDebug() << "onFirmwareChanged" << previous->getName() << "=>" << firmware->getName();
|
||||||
radioData.convert(previous, firmware);
|
radioData.convert(previous, firmware);
|
||||||
|
initModelsList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MdiChild::initModelsList()
|
||||||
|
{
|
||||||
|
BoardEnum board = firmware->getBoard();
|
||||||
|
|
||||||
delete modelsListModel;
|
delete modelsListModel;
|
||||||
modelsListModel = new TreeModel(&radioData, this);
|
modelsListModel = new TreeModel(&radioData, this);
|
||||||
|
connect(modelsListModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(onDataChanged(const QModelIndex &)));
|
||||||
ui->modelsList->setModel(modelsListModel);
|
ui->modelsList->setModel(modelsListModel);
|
||||||
ui->modelsList->header()->setVisible(!IS_HORUS(board));
|
ui->modelsList->header()->setVisible(!IS_HORUS(board));
|
||||||
if (IS_HORUS(board)) {
|
if (IS_HORUS(board)) {
|
||||||
|
@ -371,6 +378,16 @@ void MdiChild::categoryDelete()
|
||||||
setModified();
|
setModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MdiChild::onDataChanged(const QModelIndex & index)
|
||||||
|
{
|
||||||
|
int categoryIndex = modelsListModel->getCategoryIndex(index);
|
||||||
|
if (categoryIndex < 0 || categoryIndex >= (int)radioData.categories.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strcpy(radioData.categories[categoryIndex].name, modelsListModel->data(index, 0).toString().left(sizeof(CategoryData::name)-1).toStdString().c_str());
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
void MdiChild::modelAdd()
|
void MdiChild::modelAdd()
|
||||||
{
|
{
|
||||||
int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex());
|
int categoryIndex = modelsListModel->getCategoryIndex(ui->modelsList->currentIndex());
|
||||||
|
|
|
@ -81,6 +81,7 @@ class MdiChild : public QWidget
|
||||||
bool loadBackup();
|
bool loadBackup();
|
||||||
void confirmDelete();
|
void confirmDelete();
|
||||||
void deleteSelectedModels();
|
void deleteSelectedModels();
|
||||||
|
void onDataChanged(const QModelIndex & index);
|
||||||
|
|
||||||
void cut();
|
void cut();
|
||||||
void copy();
|
void copy();
|
||||||
|
@ -97,7 +98,7 @@ class MdiChild : public QWidget
|
||||||
void setCurrentFile(const QString & fileName);
|
void setCurrentFile(const QString & fileName);
|
||||||
void doCopy(QByteArray * gmData);
|
void doCopy(QByteArray * gmData);
|
||||||
void doPaste(QByteArray * gmData, int index);
|
void doPaste(QByteArray * gmData, int index);
|
||||||
|
void initModelsList();
|
||||||
|
|
||||||
Ui::MdiChild * ui;
|
Ui::MdiChild * ui;
|
||||||
TreeModel * modelsListModel;
|
TreeModel * modelsListModel;
|
||||||
|
|
|
@ -223,7 +223,7 @@ int TreeModel::rowCount(const QModelIndex &parent) const
|
||||||
return parentItem->childCount();
|
return parentItem->childCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeModel::setData(const QModelIndex &index, const QVariant & value, int role)
|
bool TreeModel::setData(const QModelIndex & index, const QVariant & value, int role)
|
||||||
{
|
{
|
||||||
if (role != Qt::EditRole)
|
if (role != Qt::EditRole)
|
||||||
return false;
|
return false;
|
||||||
|
@ -231,8 +231,9 @@ bool TreeModel::setData(const QModelIndex &index, const QVariant & value, int ro
|
||||||
TreeItem * item = getItem(index);
|
TreeItem * item = getItem(index);
|
||||||
bool result = item->setData(index.column(), value);
|
bool result = item->setData(index.column(), value);
|
||||||
|
|
||||||
if (result)
|
if (result) {
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue