Skip to content

Commit

Permalink
Небольшая правка ошибок в логике удаления разделов
Browse files Browse the repository at this point in the history
  • Loading branch information
forth32 committed Jun 7, 2018
1 parent 952ea37 commit e851a0f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 41 deletions.
1 change: 1 addition & 0 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ cpio=0;
if (!startfile.isEmpty()) {
OpenFwFile(startfile);
}
partlist->setFocus();
}

//*****************************************
Expand Down
1 change: 1 addition & 0 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ QToolButton *RefreshPorts;
void open_recent(int n);
void settitle() {setWindowTitle("Huawei firmware editor/flasher");}
void ask_save();
void removeEditor();

// Слоты обработчиков главного меню
public slots:
Expand Down
92 changes: 51 additions & 41 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,47 +251,11 @@ head_copy();
SelectPart();
}

//*****************************************
//* Выбор раздела из списка
//*****************************************
void MainWindow::SelectPart() {

QString txt;
QStringList(plst);

int idx=partlist->currentRow();
if (idx == -1) return; // пустой список
// Проверяем и, если надо, сохраняем измененные данные
if ((hrow != -1)&&(hrow != idx)) {
HeaderChanged(); // сохраняем заголовок
DataChanged(); // сохранияем блок данных
}

if ((hrow == idx) && (structure_mode_save == structure_mode->isChecked())) return; // ложный сигнал, выбран все тот же элемент списка

modebuttons->hide();

structure_mode_save=structure_mode->isChecked();
hrow=idx; // сохранияем для будущей записи заголовка


// Вывод значений заголовка
txt.sprintf("%-8.8s",ptable->platform(idx));
Platform_input->setText(txt);

txt.sprintf("%-16.16s",ptable->date(idx));
Date_input->setText(txt);

txt.sprintf("%-16.16s",ptable->time(idx));
Time_input->setText(txt);

txt.sprintf("%-32.32s",ptable->version(idx));
Version_input->setText(txt);

txt.sprintf("%04x",ptable->code(idx)>>16);
pcode->setText(txt);

// Удаляем все элементы просмотра разделов
//*********************************************
//* Удаляем все элементы просмотра разделов
//*********************************************
void MainWindow::removeEditor() {

if (hexedit != 0) {
EditorLayout->removeWidget(hexedit);
Expand Down Expand Up @@ -340,6 +304,50 @@ if (spacer != 0) {
delete spacer;
spacer=0;
}
}

//*****************************************
//* Выбор раздела из списка
//*****************************************
void MainWindow::SelectPart() {

QString txt;
QStringList(plst);

int idx=partlist->currentRow();
if (idx == -1) return; // пустой список
// Проверяем и, если надо, сохраняем измененные данные
if ((hrow != -1)&&(hrow != idx)) {
HeaderChanged(); // сохраняем заголовок
DataChanged(); // сохранияем блок данных
}

if ((hrow == idx) && (structure_mode_save == structure_mode->isChecked())) return; // ложный сигнал, выбран все тот же элемент списка

modebuttons->hide();

structure_mode_save=structure_mode->isChecked();
hrow=idx; // сохранияем для будущей записи заголовка


// Вывод значений заголовка
txt.sprintf("%-8.8s",ptable->platform(idx));
Platform_input->setText(txt);

txt.sprintf("%-16.16s",ptable->date(idx));
Date_input->setText(txt);

txt.sprintf("%-16.16s",ptable->time(idx));
Time_input->setText(txt);

txt.sprintf("%-32.32s",ptable->version(idx));
Version_input->setText(txt);

txt.sprintf("%04x",ptable->code(idx)>>16);
pcode->setText(txt);

// удаляем преддущий редактор
removeEditor();

modebuttons->show();

Expand Down Expand Up @@ -544,6 +552,7 @@ void MainWindow::Menu_Part_Delete() {
int32_t ci=partlist->currentRow();

if (ptable->index() == 1) return; // последний раздел удалять нельзя
removeEditor(); // удаляем текущий редактор
ptable->delpart(ci);
regenerate_partlist();
if (ci< (ptable->index()-1)) partlist->setCurrentRow(ci);
Expand Down Expand Up @@ -751,7 +760,8 @@ usbload();
//* Установка признака модификации
//********************************************
void MainWindow::setModified() {


if (modified) return;
modified=true;
// добавляем звездочку в заголовок
QString str=windowTitle();
Expand Down

0 comments on commit e851a0f

Please sign in to comment.