[Companion] Do not create a category in new file when loading data from radio; Fix crashes when editing category name.

This commit is contained in:
Max Paperno
2017-04-12 07:18:01 -04:00
parent a062efeb21
commit 111bcad9a7
3 changed files with 6 additions and 7 deletions
+1 -1
View File
@@ -805,7 +805,7 @@ void MainWindow::readEeprom()
if (readEepromFromRadio(tempFile)) { if (readEepromFromRadio(tempFile)) {
MdiChild * child = createMdiChild(); MdiChild * child = createMdiChild();
child->newFile(); child->newFile(false);
child->loadFile(tempFile, false); child->loadFile(tempFile, false);
child->show(); child->show();
qunlink(tempFile); qunlink(tempFile);
+4 -5
View File
@@ -565,7 +565,6 @@ void MdiChild::onItemActivated(const QModelIndex index)
openModelEditWindow(mIdx); openModelEditWindow(mIdx);
} }
else if (modelsListModel->isCategoryType(index)) { else if (modelsListModel->isCategoryType(index)) {
ui->modelsList->setCurrentIndex(index);
ui->modelsList->edit(index); ui->modelsList->edit(index);
} }
} }
@@ -591,8 +590,8 @@ void MdiChild::onDataChanged(const QModelIndex & index)
} }
strcpy(radioData.categories[categoryIndex].name, modelsListModel->data(index, 0).toString().left(sizeof(CategoryData::name)-1).toStdString().c_str()); strcpy(radioData.categories[categoryIndex].name, modelsListModel->data(index, 0).toString().left(sizeof(CategoryData::name)-1).toStdString().c_str());
ui->modelsList->setCurrentIndex(QModelIndex()); // must do this otherwise leaves QTreeView in limbo after TreeModel::refresh() (Qt undoc/bug?) setWindowModified(true);
setModified(); emit modified();
} }
/* /*
@@ -1299,14 +1298,14 @@ void MdiChild::modelSimulate()
startSimulation(this, radioData, getCurrentModel()); startSimulation(this, radioData, getCurrentModel());
} }
void MdiChild::newFile() void MdiChild::newFile(bool createDefaults)
{ {
static int sequenceNumber = 1; static int sequenceNumber = 1;
isUntitled = true; isUntitled = true;
curFile = QString("document%1.otx").arg(sequenceNumber++); curFile = QString("document%1.otx").arg(sequenceNumber++);
updateTitle(); updateTitle();
if (firmware->getCapability(Capability::HasModelCategories)) { if (createDefaults && firmware->getCapability(Capability::HasModelCategories)) {
categoryAdd(); categoryAdd();
} }
} }
+1 -1
View File
@@ -81,7 +81,7 @@ class MdiChild : public QWidget
QAction * getAction(const Actions type); QAction * getAction(const Actions type);
public slots: public slots:
void newFile(); void newFile(bool createDefaults = true);
bool loadFile(const QString & fileName, bool resetCurrentFile=true); bool loadFile(const QString & fileName, bool resetCurrentFile=true);
bool save(); bool save();
bool saveAs(bool isNew=false); bool saveAs(bool isNew=false);