From 5aa866acc26a7fd37fd6524ec10e609878182ac1 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Sat, 8 Jan 2022 12:01:09 +1100 Subject: [PATCH] [companion] Remove no longer relevant EEPROM size column heading (#1381) --- companion/src/mdichild.cpp | 4 ---- companion/src/modelslist.cpp | 41 +++++------------------------------- companion/src/modelslist.h | 7 +----- 3 files changed, 6 insertions(+), 46 deletions(-) diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 4e4d36ebd..a0d98bb50 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -697,10 +697,6 @@ QVector MdiChild::getSelectedModels() const void MdiChild::updateTitle() { QString title = "[*]" + userFriendlyCurrentFile(); // + " (" + firmware->getName() + QString(")"); - int availableEEpromSize = modelsListModel->getAvailableEEpromSize(); - if (availableEEpromSize >= 0) { - title += QString(" - %1 ").arg(availableEEpromSize) + tr("free bytes"); - } QFileInfo fi(curFile); if (!isUntitled && !fi.isWritable()) { title += QString(" (%1)").arg(tr("read only")); diff --git a/companion/src/modelslist.cpp b/companion/src/modelslist.cpp index b11b15723..7581d201e 100644 --- a/companion/src/modelslist.cpp +++ b/companion/src/modelslist.cpp @@ -136,18 +136,13 @@ bool TreeItem::isModel() const TreeModel::TreeModel(RadioData * radioData, QObject * parent): QAbstractItemModel(parent), - radioData(radioData), - availableEEpromSize(-1) + radioData(radioData) { - Board::Type board = getCurrentBoard(); hasCategories = getCurrentFirmware()->getCapability(Capability::HasModelCategories); QVector labels; if (!hasCategories) labels << tr("Index"); labels << tr("Name"); - if (!(IS_FAMILY_HORUS_OR_T16(board) || IS_SKY9X(board))) { - labels << tr("Size"); - } labels << tr("RX #"); rootItem = new TreeItem(labels); // uniqueId and version for drag/drop operations (see encodeHeaderData()) @@ -558,7 +553,7 @@ TreeItem * TreeModel::getItem(const QModelIndex & index) const // recursive QModelIndex TreeModel::getIndexForModel(const int modelIndex, QModelIndex parent) { - for (int i=0; i < rowCount(parent); ++i) { + for (int i = 0; i < rowCount(parent); ++i) { QModelIndex idx = index(i, 0, parent); if (hasChildren(idx) && (idx = getIndexForModel(modelIndex, idx)).isValid()) return idx; @@ -570,18 +565,13 @@ QModelIndex TreeModel::getIndexForModel(const int modelIndex, QModelIndex parent QModelIndex TreeModel::getIndexForCategory(const int categoryIndex) { - for (int i=0; i < rowCount(); ++i) { + for (int i = 0; i < rowCount(); ++i) { if (getItem(index(i, 0))->getCategoryIndex() == categoryIndex) return index(i, 0); } return QModelIndex(); } -int TreeModel::getAvailableEEpromSize() -{ - return availableEEpromSize; -} - int TreeModel::getModelIndex(const QModelIndex & index) const { return getItem(index)->getModelIndex(); @@ -648,15 +638,7 @@ void TreeModel::onRowsRemoved(const QModelIndex & parent, int first, int last) void TreeModel::refresh() { - EEPROMInterface * eepromInterface = getCurrentEEpromInterface(); - Board::Type board = eepromInterface->getBoard(); TreeItem * defaultCategoryItem = NULL; - bool hasEepromSizeData = false; // not necessary with move to YAML storage for all boards TODO: remove unused code - - if (hasEepromSizeData) { - availableEEpromSize = Boards::getEEpromSize(board) - 64; // let's consider fat - availableEEpromSize -= 16 * ((eepromInterface->getSize(radioData->generalSettings) + 14) / 15); - } this->blockSignals(true); // make sure onRowsRemoved is not triggered removeRows(0, rowCount()); @@ -669,7 +651,7 @@ void TreeModel::refresh() } } - for (unsigned i=0; imodels.size(); i++) { + for (unsigned i = 0; i < radioData->models.size(); i++) { ModelData & model = radioData->models[i]; int currentColumn = 0; TreeItem * current = NULL; @@ -710,16 +692,7 @@ void TreeModel::refresh() modelName = tr("Model %1").arg(uint(i+1), 2, 10, QChar('0')); } current->setData(currentColumn++, modelName); - if (hasEepromSizeData) { - int size = eepromInterface->getSize(model); - current->setData(currentColumn++, QString().sprintf("%5d", size)); - size = 16 * ((size + 14) / 15); - availableEEpromSize -= size; - if (i == radioData->generalSettings.currModelIndex) { - // Because we need this space for a TEMP model each time we have to write it again - availableEEpromSize -= size; - } - } + int protocol; QString rxs; unsigned moduleIdx = 0; @@ -742,10 +715,6 @@ void TreeModel::refresh() current->setData(currentColumn++, rxs); } } - - if (hasEepromSizeData) { - availableEEpromSize = (availableEEpromSize / 16) * 15; - } } bool TreeModel::isModelIdUnique(unsigned modelIdx, unsigned module, unsigned protocol) diff --git a/companion/src/modelslist.h b/companion/src/modelslist.h index 135e8b28d..8fce2ef2c 100644 --- a/companion/src/modelslist.h +++ b/companion/src/modelslist.h @@ -18,8 +18,7 @@ * GNU General Public License for more details. */ -#ifndef _MODELSLIST_H_ -#define _MODELSLIST_H_ +#pragma once #include "eeprominterface.h" #include @@ -126,7 +125,6 @@ class TreeModel : public QAbstractItemModel QModelIndex getIndexForModel(const int modelIndex, QModelIndex parent = QModelIndex()); QModelIndex getIndexForCategory(const int categoryIndex); - int getAvailableEEpromSize(); int getModelIndex(const QModelIndex & index) const; int getCategoryIndex(const QModelIndex & index) const; int rowNumber(const QModelIndex & index = QModelIndex()) const; @@ -153,9 +151,6 @@ class TreeModel : public QAbstractItemModel TreeItem * rootItem; RadioData * radioData; - int availableEEpromSize; MimeHeaderData mimeHeaderData; bool hasCategories; }; - -#endif // _MODELSLIST_H_