Skip to content

Commit

Permalink
Merge branch 'ImportSpeedOptimalization' into testing_0.31
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed Dec 17, 2023
2 parents 78a2415 + 5128ce7 commit 9fbf0de
Show file tree
Hide file tree
Showing 8 changed files with 402 additions and 459 deletions.
9 changes: 5 additions & 4 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ DxccStatus Data::dxccStatus(int dxcc, const QString &band, const QString &mode)

QSettings settings;
QVariant start = settings.value("dxcc/start");
if (!start.isNull()) {
if ( start.toDate().isValid() )
{
filter = QString("AND start_time >= '%1'").arg(start.toDate().toString("yyyy-MM-dd"));
}

Expand Down Expand Up @@ -420,9 +421,9 @@ QString Data::removeAccents(const QString &input)
/* https://www.medo64.com/2020/10/stripping-diacritics-in-qt/ */
/* More about normalization https://unicode.org/reports/tr15/ */

QString formD = input.normalized(QString::NormalizationForm_D);

const QString &formD = input.normalized(QString::NormalizationForm_D);
QString filtered;

for (int i = 0; i < formD.length(); i++)
{
if (formD.at(i).category() != QChar::Mark_NonSpacing)
Expand Down Expand Up @@ -762,7 +763,7 @@ DxccEntity Data::lookupDxcc(const QString &callsign)
}

QString lookupPrefix = callsign; // use the callsign with optional prefix as default to find the dxcc
Callsign parsedCallsign(callsign); // use Callsign to split the callsign into its parts
const Callsign parsedCallsign(callsign); // use Callsign to split the callsign into its parts

if ( parsedCallsign.isValid() )
{
Expand Down
532 changes: 220 additions & 312 deletions logformat/AdiFormat.cpp

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions logformat/AdiFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AdiFormat : public LogFormat
virtual void exportStart() override;

static QMap<QString, QString> fieldname2INTLNameMapping;

template<typename T>
static void preprocessINTLFields(T &contact)
{
Expand All @@ -41,6 +42,35 @@ class AdiFormat : public LogFormat
QSqlRecord &record);
void contactFields2SQLRecord(QMap<QString, QVariant> &contact,
QSqlRecord &record);

static const QString toString(const QVariant &);
static const QString toLower(const QVariant &);
static const QString toUpper(const QVariant &);
static const QString toYYYYMMDD(const QVariant &);

class ExportParams
{
public:
ExportParams() :
ADIFName(QString()),
outputType(QString()),
formatFct(nullptr),
isValid(false) {};
ExportParams(const QString &inADIFName,
const QString (*inFct)(const QVariant &) = &AdiFormat::toString,
const QString &inType = QString()) :
ADIFName(inADIFName),
outputType(inType),
formatFct(inFct),
isValid(true) {};
QString ADIFName;
QString outputType;
const QString (*formatFct)(const QVariant &);
bool isValid;
};

static QHash<QString, AdiFormat::ExportParams> DB2ADIFExportParams;

private:

void readField(QString& field,
Expand Down
8 changes: 4 additions & 4 deletions logformat/AdxFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ void AdxFormat::writeSQLRecord(const QSqlRecord &record, QMap<QString, QString>

// Add _INTL fields

QStringList fieldMappingList = fieldname2INTLNameMapping.values();
for ( const QString& value : qAsConst(fieldMappingList) )
const QStringList &fieldMappingList = fieldname2INTLNameMapping.values();
for ( const QString& value : fieldMappingList )
{
writeField(value, record.value(value).isValid(),
record.value(value).toString());
const QVariant &tmp = record.value(value);
writeField(value, tmp.isValid(), tmp.toString());
}
}

Expand Down
Loading

0 comments on commit 9fbf0de

Please sign in to comment.