[Companion] Crash fix

This commit is contained in:
Bertrand Songis
2017-01-20 07:22:26 +01:00
parent 324544835a
commit 28ccf7d8ee
4 changed files with 11 additions and 72 deletions
+2 -2
View File
@@ -774,7 +774,7 @@ void MainWindow::readEeprom()
}
}
bool MainWindow::readFirmwareFromRadio(const QString &filename)
bool MainWindow::readFirmwareFromRadio(const QString & filename)
{
ProgressDialog progressDialog(this, tr("Read Firmware from Radio"), CompanionIcon("read_flash.png"));
bool result = readFirmware(filename, progressDialog.progress());
@@ -784,7 +784,7 @@ bool MainWindow::readFirmwareFromRadio(const QString &filename)
return result;
}
bool MainWindow::readEepromFromRadio(const QString &filename)
bool MainWindow::readEepromFromRadio(const QString & filename)
{
ProgressDialog progressDialog(this, tr("Read Models and Settings from Radio"), CompanionIcon("read_eeprom.png"));
bool result = ::readEeprom(filename, progressDialog.progress());
+6 -1
View File
@@ -382,12 +382,17 @@ void MdiChild::categoryDelete()
void MdiChild::onDataChanged(const QModelIndex & index)
{
int modelIndex = modelsListModel->getModelIndex(index);
if (modelIndex >= 0) {
return;
}
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();
fileChanged = true;
documentWasModified();
}
void MdiChild::modelAdd()
+3 -11
View File
@@ -182,7 +182,6 @@ QModelIndex TreeModel::index(int row, int column, const QModelIndex & parent) co
return QModelIndex();
TreeItem * parentItem = getItem(parent);
TreeItem * childItem = parentItem->child(row);
if (childItem)
return createIndex(row, column, childItem);
@@ -221,7 +220,6 @@ bool TreeModel::removeRows(int position, int rows, const QModelIndex & parent)
int TreeModel::rowCount(const QModelIndex &parent) const
{
TreeItem * parentItem = getItem(parent);
return parentItem->childCount();
}
@@ -230,6 +228,9 @@ bool TreeModel::setData(const QModelIndex & index, const QVariant & value, int r
if (role != Qt::EditRole)
return false;
if (!index.isValid())
return false;
TreeItem * item = getItem(index);
bool result = item->setData(index.column(), value);
@@ -305,16 +306,7 @@ void TreeModel::refresh()
availableEEpromSize -= size;
}
}
/* TODO if (i == radioData->generalSettings.currModelIndex) {
QFont font = item->font(0);
font.setBold(true);
for (int j=0; j<columnCount(); j++) {
item->setFont(j, font);
}
} */
}
// addTopLevelItem(item);
}
if (!IS_SKY9X(board) && !IS_HORUS(board)) {
-58
View File
@@ -105,62 +105,4 @@ class TreeModel : public QAbstractItemModel
int availableEEpromSize;
};
#if 0
class ModelsListWidget : public QTreeView
{
Q_OBJECT
public:
ModelsListWidget(QWidget * parent = 0);
void setRadioData(RadioData * radioData);
bool hasSelection();
void keyPressEvent(QKeyEvent * event);
bool hasPasteData();
int currentRow() const;
protected:
void dropEvent(QDropEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
#ifndef WIN32
void focusInEvent ( QFocusEvent * event );
void focusOutEvent ( QFocusEvent * event );
#endif
public slots:
void refreshList();
void cut();
void copy();
void paste();
void print();
void EditModel();
void LoadBackup();
void OpenWizard();
void duplicate();
void deleteSelected(bool ask);
void confirmDelete();
void onCurrentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
private:
void doCut(QByteArray *gmData);
void doPaste(QByteArray *gmData, int index);
void doCopy(QByteArray *gmData);
void saveSelection();
void restoreSelection();
RadioData * radioData;
QPoint dragStartPosition;
CurrentSelection currentSelection;
QColor active_highlight_color;
};
#endif
#endif // _MODELSLIST_H_