Skip to content

Commit

Permalink
Logbook: Improved Flag display code
Browse files Browse the repository at this point in the history
  • Loading branch information
ik1vqy authored and foldynl committed Aug 11, 2024
1 parent 1f7f63b commit e2a9831
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
7 changes: 0 additions & 7 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,13 +1036,6 @@ WWFFEntity Data::lookupWWFF(const QString &reference)
return WWFFRet;
}

QString Data::dxccFlag(int dxcc) {
FCT_IDENTIFICATION;

qCDebug(function_parameters) << dxcc;
return flags.value(dxcc);
}

const char Data::translitTab[] = {
1, ' ', 1, '!', 2, 'C', '/', 2, 'P', 'S', 2, '$', '?', 2, 'Y', '=',
1, '|', 2, 'S', 'S', 1, '\"', 3, '(', 'c', ')', 1, 'a', 2, '<', '<',
Expand Down
4 changes: 2 additions & 2 deletions data/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Data : public QObject
SOTAEntity lookupSOTA(const QString &SOTACode);
POTAEntity lookupPOTA(const QString &POTACode);
WWFFEntity lookupWWFF(const QString &reference);
QString dxccFlag(int dxcc);
const QString dxccFlag(int dxcc) const {return flags.value(dxcc);} ;
QPair<QString, QString> legacyMode(const QString &mode);
QStringList satModeList() { return satModes.values();}
QStringList satModesIDList() { return satModes.keys(); }
Expand Down Expand Up @@ -127,7 +127,7 @@ public slots:
void loadPOTA();
void loadTZ();

QMap<int, QString> flags;
QHash<int, QString> flags;
QMap<QString, QString> contests;
QMap<QString, QString> propagationModes;
QMap<QString, QPair<QString, QString>> legacyModes;
Expand Down
12 changes: 3 additions & 9 deletions models/LogbookModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,10 @@ QVariant LogbookModel::data(const QModelIndex &index, int role) const
return QVariant();

if (role == Qt::DecorationRole && index.column() == COLUMN_CALL) {
QModelIndex dxcc_index = this->index(index.row(), COLUMN_DXCC);
int dxcc = QSqlTableModel::data(dxcc_index, Qt::DisplayRole).toInt();
QString flag = Data::instance()->dxccFlag(dxcc);
const QString &flag = Data::instance()->dxccFlag(QSqlTableModel::data(this->index(index.row(), COLUMN_DXCC), Qt::DisplayRole).toInt());

if (!flag.isEmpty()) {
return QIcon(QString(":/flags/16/%1.png").arg(flag));
}
else {
return QIcon(":/flags/16/unknown.png");
}
return ( !flag.isEmpty() ) ? QIcon(QString(":/flags/16/%1.png").arg(flag))
: QIcon(":/flags/16/unknown.png");
}

if (role == Qt::DecorationRole && (index.column() == COLUMN_QSL_RCVD || index.column() == COLUMN_QSL_SENT ||
Expand Down

0 comments on commit e2a9831

Please sign in to comment.