mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 17:55:19 +03:00
[Companion] Code refactoring
This commit is contained in:
parent
03bb622456
commit
a3bff8cf61
1 changed files with 41 additions and 58 deletions
|
@ -280,69 +280,52 @@ void ModelsListWidget::focusOutEvent ( QFocusEvent * event )
|
||||||
|
|
||||||
void ModelsListWidget::refreshList()
|
void ModelsListWidget::refreshList()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
int msize;
|
addItem(tr("General Settings"));
|
||||||
div_t divresult;
|
|
||||||
addItem(tr("General Settings"));
|
|
||||||
|
|
||||||
EEPROMInterface *eepromInterface = GetEepromInterface();
|
EEPROMInterface * eepromInterface = GetEepromInterface();
|
||||||
int availableEEpromSize = eepromInterface->getEEpromSize()-64; //let's consider fat
|
BoardEnum board = eepromInterface->getBoard();
|
||||||
divresult=div(eepromInterface->getSize(radioData->generalSettings),15);
|
|
||||||
divresult.quot+=(divresult.rem!=0 ? 1:0);
|
// TODO here we calculate the size used by the RLE format, this is clearly not the right place to do that...
|
||||||
availableEEpromSize -= divresult.quot*16;
|
int availableEEpromSize = eepromInterface->getEEpromSize() - 64; // let's consider fat
|
||||||
|
div_t divresult = div(eepromInterface->getSize(radioData->generalSettings), 15);
|
||||||
for(uint8_t i=0; i<GetEepromInterface()->getMaxModels(); i++)
|
divresult.quot += (divresult.rem != 0 ? 1 : 0);
|
||||||
{
|
availableEEpromSize -= divresult.quot*16;
|
||||||
QString item = QString().sprintf("%02d: ", i+1);
|
|
||||||
|
for (uint8_t i=0; i<GetEepromInterface()->getMaxModels(); i++) {
|
||||||
if (!radioData->models[i].isEmpty()) {
|
QString item = QString().sprintf("%02d: ", i+1);
|
||||||
if (eepromInterface && IS_SKY9X(eepromInterface->getBoard())) {
|
if (!radioData->models[i].isEmpty()) {
|
||||||
if (radioData->models[i].name[0]==0) {
|
QString modelName;
|
||||||
QString modelname="Model";
|
if (strlen(radioData->models[i].name) > 0)
|
||||||
modelname.append(QString().sprintf("%02d", i+1));
|
modelName = radioData->models[i].name;
|
||||||
item += modelname;
|
else
|
||||||
} else {
|
modelName = QString().sprintf("Model%02d", i+1);
|
||||||
item += radioData->models[i].name;
|
item += modelName;
|
||||||
}
|
if (!IS_SKY9X(board) && !IS_HORUS(board)) {
|
||||||
}
|
item += QString(GetCurrentFirmware()->getCapability(ModelName)-modelName.size(), ' ');
|
||||||
else {
|
int size = eepromInterface->getSize(radioData->models[i]);
|
||||||
char modelname[256];
|
item += QString().sprintf("%5d", size);
|
||||||
if (radioData->models[i].name[0]==0) {
|
divresult = div(size, 15);
|
||||||
sprintf(modelname, "Model%02d", i+1);
|
divresult.quot += (divresult.rem != 0 ? 1 : 0);
|
||||||
} else {
|
availableEEpromSize -= divresult.quot*16;
|
||||||
if (IS_TARANIS(eepromInterface->getBoard())) {
|
if (i == radioData->generalSettings.currModel) {
|
||||||
sprintf(modelname,"%12s",radioData->models[i].name);
|
// TODO why?
|
||||||
} else {
|
|
||||||
sprintf(modelname,"%10s",radioData->models[i].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (IS_TARANIS(eepromInterface->getBoard())) {
|
|
||||||
item += QString().sprintf("%12s", modelname);
|
|
||||||
} else {
|
|
||||||
item += QString().sprintf("%10s", modelname);
|
|
||||||
}
|
|
||||||
msize = eepromInterface->getSize(radioData->models[i]);
|
|
||||||
item += QString().sprintf("%5d", msize);
|
|
||||||
divresult=div(msize,15);
|
|
||||||
divresult.quot+=(divresult.rem!=0 ? 1:0);
|
|
||||||
availableEEpromSize -= divresult.quot*16;
|
availableEEpromSize -= divresult.quot*16;
|
||||||
|
|
||||||
if (i==radioData->generalSettings.currModel) {
|
|
||||||
availableEEpromSize -= divresult.quot*16;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addItem(item);
|
|
||||||
}
|
|
||||||
if (radioData->generalSettings.currModel < (unsigned int)GetEepromInterface()->getMaxModels()) {
|
|
||||||
QFont f = QFont("Courier New", 12);
|
|
||||||
f.setBold(true);
|
|
||||||
this->item(radioData->generalSettings.currModel+1)->setFont(f);
|
|
||||||
}
|
}
|
||||||
|
addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (radioData->generalSettings.currModel < (unsigned int)eepromInterface->getMaxModels()) {
|
||||||
|
QFont f = QFont("Courier New", 12);
|
||||||
|
f.setBold(true);
|
||||||
|
this->item(radioData->generalSettings.currModel+1)->setFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
if (eepromInterface && !IS_SKY9X(eepromInterface->getBoard())) {
|
if (!IS_SKY9X(board) && !IS_HORUS(board)) {
|
||||||
((MdiChild*)parent())->setEEpromAvail((availableEEpromSize/16)*15);
|
((MdiChild*)parent())->setEEpromAvail((availableEEpromSize/16)*15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelsListWidget::cut()
|
void ModelsListWidget::cut()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue