Skip to content

Commit

Permalink
Reviewed usage of QVariant isNull
Browse files Browse the repository at this point in the history
Reviewed isNull based on commit 5128ce7
  • Loading branch information
foldynl committed Sep 29, 2024
1 parent 08e548f commit aab7269
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 43 deletions.
28 changes: 14 additions & 14 deletions core/MembershipQE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,25 +554,25 @@ void ClubStatusQuery::getClubStatus(const QString &in_callsign,
while ( ++records && query.next() )
{
QString clubid = query.value(0).toString();
QVariant band = query.value(1);
QVariant mode = query.value(2);
QString band = query.value(1).toString();
QString mode = query.value(2).toString();
QVariant confirmed = query.value(3);
QVariant current_mode = query.value(4);
QString current_mode = query.value(4).toString();

qCDebug(runtime) << "Processing" << currentProcessedClub
<< clubid
<< band.isNull() << band
<< mode.isNull() << mode
<< confirmed.isNull() << confirmed
<< current_mode.isNull();
<< band.isEmpty() << band
<< mode.isEmpty() << mode
<< confirmed.toString().isEmpty() << confirmed
<< current_mode.isEmpty();

// the select generates starting line for a new club
// Changing the club
if ( currentProcessedClub != clubid
&& band.isNull()
&& mode.isNull()
&& confirmed.isNull()
&& current_mode.isNull() )
&& band.isEmpty()
&& mode.isEmpty()
&& confirmed.toString().isEmpty()
&& current_mode.isEmpty() )
{
if ( !currentProcessedClub.isEmpty() )
{
Expand All @@ -591,10 +591,10 @@ void ClubStatusQuery::getClubStatus(const QString &in_callsign,

if ( currentProcessedClub == clubid )
{
if ( band.toString() == in_band )
if ( band == in_band )
{
bandMatched = true;
if ( mode.toString() == current_mode.toString() )
if ( mode == current_mode )
{
bandModeMatched = true;

Expand All @@ -605,7 +605,7 @@ void ClubStatusQuery::getClubStatus(const QString &in_callsign,
}
}

if ( mode.toString() == current_mode.toString() )
if ( mode == current_mode )
{
modeMatched = true;
}
Expand Down
2 changes: 1 addition & 1 deletion core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ int main(int argc, char* argv[])
QString lang = parser.value(forceLanguage);

app.setOrganizationName("hamradio");
app.setApplicationName("QLog" + ((environment.isNull()) ? "" : environment.prepend("-")));
app.setApplicationName("QLog" + ((environment.isEmpty()) ? "" : environment.prepend("-")));

/* If the Style parameter is not present then use a default - Fusion style */
if ( !stylePresent )
Expand Down
12 changes: 6 additions & 6 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,24 @@ DxccStatus Data::dxccStatus(int dxcc, const QString &band, const QString &mode)

if ( query.next() )
{
if ( query.value(0).isNull() )
if ( query.value(0).toString().isEmpty() )
return DxccStatus::NewEntity;

if ( query.value(1).isNull() )
if ( query.value(1).toString().isEmpty() )
{
if ( query.value(2).isNull() )
if ( query.value(2).toString().isEmpty() )
return DxccStatus::NewBandMode;
else
return DxccStatus::NewBand;
}

if ( query.value(2).isNull() )
if ( query.value(2).toString().isEmpty() )
return DxccStatus::NewMode;

if ( query.value(3).isNull() )
if ( query.value(3).toString().isEmpty() )
return DxccStatus::NewSlot;

if ( query.value(4).isNull() )
if ( query.value(4).toString().isEmpty() )
return DxccStatus::Worked;
else
return DxccStatus::Confirmed;
Expand Down
6 changes: 3 additions & 3 deletions ui/AlertWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ void AlertWidget::restoreTableHeaderState()
{
FCT_IDENTIFICATION;

const QVariant &state = settings.value("alert/state");
const QByteArray &state = settings.value("alert/state").toByteArray();

if (!state.isNull())
if (!state.isEmpty())
{
ui->alertTableView->horizontalHeader()->restoreState(state.toByteArray());
ui->alertTableView->horizontalHeader()->restoreState(state);
}
}

Expand Down
25 changes: 13 additions & 12 deletions ui/DxWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,31 +793,32 @@ void DxWidget::restoreWidgetSetting()
FCT_IDENTIFICATION;

QSettings settings;
QVariant state = settings.value("dxc/dxtablestate");
QByteArray state = settings.value("dxc/dxtablestate").toByteArray();

if (!state.isNull())
if (!state.isEmpty())
{
ui->dxTable->horizontalHeader()->restoreState(state.toByteArray());
ui->dxTable->horizontalHeader()->restoreState(state);
}

state = settings.value("dxc/wcytablestate");
state = settings.value("dxc/wcytablestate").toByteArray();

if (!state.isNull())
if (!state.isEmpty())
{
ui->wcyTable->horizontalHeader()->restoreState(state.toByteArray());
ui->wcyTable->horizontalHeader()->restoreState(state);
}

state = settings.value("dxc/wwvtablestate");
state = settings.value("dxc/wwvtablestate").toByteArray();

if (!state.isNull())
if (!state.isEmpty())
{
ui->wwvTable->horizontalHeader()->restoreState(state.toByteArray());
ui->wwvTable->horizontalHeader()->restoreState(state);
}
state = settings.value("dxc/toalltablestate");

if (!state.isNull())
state = settings.value("dxc/toalltablestate").toByteArray();

if (!state.isEmpty())
{
ui->toAllTable->horizontalHeader()->restoreState(state.toByteArray());
ui->toAllTable->horizontalHeader()->restoreState(state);
}

int fontsize = settings.value("dxc/consolefontsize", -1).toInt();
Expand Down
6 changes: 3 additions & 3 deletions ui/LogbookWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ LogbookWidget::LogbookWidget(QWidget *parent) :
ui->contactTable->setItemDelegateForColumn(LogbookModel::COLUMN_UKSMG, new UnitFormatDelegate("", 0, 1, ui->contactTable));

QSettings settings;
QVariant logbookState = settings.value("logbook/state");
if (!logbookState.isNull()) {
ui->contactTable->horizontalHeader()->restoreState(logbookState.toByteArray());
const QByteArray &logbookState = settings.value("logbook/state").toByteArray();
if (!logbookState.isEmpty()) {
ui->contactTable->horizontalHeader()->restoreState(logbookState);
}
else {
/* Hide all */
Expand Down
2 changes: 1 addition & 1 deletion ui/RigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void RigWidget::bandComboChanged(const QString &newBand)

double newFreq = record.value("start_freq").toDouble();

if ( ! record.value("last_seen_freq").isNull() )
if ( ! record.value("last_seen_freq").toString().isEmpty() )
{
newFreq = record.value("last_seen_freq").toDouble();
}
Expand Down
6 changes: 3 additions & 3 deletions ui/WsjtxWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ void WsjtxWidget::restoreTableHeaderState()
FCT_IDENTIFICATION;

QSettings settings;
QVariant state = settings.value("wsjtx/state");
const QByteArray &state = settings.value("wsjtx/state").toByteArray();

if (!state.isNull())
if (!state.isEmpty())
{
ui->tableView->horizontalHeader()->restoreState(state.toByteArray());
ui->tableView->horizontalHeader()->restoreState(state);
}
}

Expand Down

0 comments on commit aab7269

Please sign in to comment.