Skip to content

Commit

Permalink
Fixed #459 - QSODetail: added possibility to define an empty country
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Sep 11, 2024
1 parent 32b5647 commit 455e2a6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ui/QSODetailDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ QSODetailDialog::QSODetailDialog(const QSqlRecord &qso,
/* Country */
SqlListModel* countryModel = new SqlListModel("SELECT id, translate_to_locale(name), name "
"FROM dxcc_entities "
"ORDER BY 2 COLLATE LOCALEAWARE ASC;", "", this);
"ORDER BY 2 COLLATE LOCALEAWARE ASC;", " ", this);
while ( countryModel->canFetchMore() )
countryModel->fetchMore();

Expand Down Expand Up @@ -1685,11 +1685,7 @@ void QSOEditMapperDelegate::setEditorData(QWidget *editor,
QModelIndexList countryIndex = combo->model()->match(combo->model()->index(0,0),
Qt::DisplayRole, index.data(),
1, Qt::MatchExactly);
if ( countryIndex.size() >= 1 )
{
combo->setCurrentIndex(countryIndex.at(0).row());
}

combo->setCurrentIndex(( countryIndex.size() >= 1 ) ? countryIndex.at(0).row() : -1);
}
return;
}
Expand Down Expand Up @@ -1824,10 +1820,14 @@ void QSOEditMapperDelegate::setModelData(QWidget *editor,
if ( combo )
{
int row = combo->currentIndex();
const QModelIndex &idxDXCC = combo->model()->index(row,0);
const QModelIndex &idxCountryEN = combo->model()->index(row,2);
QVariant dataDXCC = combo->model()->data(idxDXCC);
QVariant dataCountryEN = combo->model()->data(idxCountryEN);
QVariant dataDXCC;
QVariant dataCountryEN;

if ( row > 0 ) // the first line is an empty line
{
dataDXCC = combo->model()->data(combo->model()->index(row,0));
dataCountryEN = combo->model()->data(combo->model()->index(row,2));
}

model->setData(index, dataDXCC);
model->setData(model->index(index.row(),
Expand Down

0 comments on commit 455e2a6

Please sign in to comment.