[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)) {
MdiChild * child = createMdiChild();
child->newFile();
child->newFile(false);
child->loadFile(tempFile, false);
child->show();
qunlink(tempFile);
+4 -5
View File
@@ -565,7 +565,6 @@ void MdiChild::onItemActivated(const QModelIndex index)
openModelEditWindow(mIdx);
}
else if (modelsListModel->isCategoryType(index)) {
ui->modelsList->setCurrentIndex(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());
ui->modelsList->setCurrentIndex(QModelIndex()); // must do this otherwise leaves QTreeView in limbo after TreeModel::refresh() (Qt undoc/bug?)
setModified();
setWindowModified(true);
emit modified();
}
/*
@@ -1299,14 +1298,14 @@ void MdiChild::modelSimulate()
startSimulation(this, radioData, getCurrentModel());
}
void MdiChild::newFile()
void MdiChild::newFile(bool createDefaults)
{
static int sequenceNumber = 1;
isUntitled = true;
curFile = QString("document%1.otx").arg(sequenceNumber++);
updateTitle();
if (firmware->getCapability(Capability::HasModelCategories)) {
if (createDefaults && firmware->getCapability(Capability::HasModelCategories)) {
categoryAdd();
}
}
+1 -1
View File
@@ -81,7 +81,7 @@ class MdiChild : public QWidget
QAction * getAction(const Actions type);
public slots:
void newFile();
void newFile(bool createDefaults = true);
bool loadFile(const QString & fileName, bool resetCurrentFile=true);
bool save();
bool saveAs(bool isNew=false);