Skip to content

Commit

Permalink
Small work
Browse files Browse the repository at this point in the history
Logwindow does not show QSOs but they are in the log
  • Loading branch information
ea4k committed Nov 3, 2024
1 parent 45f9c39 commit 2cffdb0
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 111 deletions.
9 changes: 7 additions & 2 deletions src/Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
ODO: Working in void MainWindowInputOthers::setEntityAndPrefix
TODO: When a QSO is added, it is not shown in the logview
TODo: Test MainWindowInputOthers::setEntityAndPrefix
TODO: Improve the REGEX in callsign.cpp
TODO: Review the KLog first start. Reading cty.dat is terribly slow.
TODO: Working in void MainWindowInputOthers::setEntityAndPrefix
TODO-Bug: EA8, EA9 fails for subdivisions, it is detected as EA
TODO-Bug: CT9 is detected as Portugal but subdivision is properly detected

Expand All @@ -15,7 +19,7 @@ Complete: void MainWindow::slotQSOReceived(const QSO &_qso) to add the QSO
Check the bug that makes WSJTX not logging automatically


BUG: When entering/modifying a QSO thre is an error related to awarddxcc table not existing
BUG: When entering/modifying a QSO there is an error related to awarddxcc table not existing
TODO: After update, it is needed to restart KLog to be able to use the primary subdivisions
TODO-Bug: Review void tst_MainWindowInputQSO::test_GridLineEdit()

Expand All @@ -30,6 +34,7 @@ TODO: When completing with previous data the QSL is in red
TESTS to do during RC releases:
- ADIF log Import
- LoTW log Import
- Test different callsigns from different entities to see if entity is properly identified
- Edit QSO. Check how data comes from DB to the UI.
- Attention to name

Expand Down
24 changes: 19 additions & 5 deletions src/callsign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ Callsign::Callsign(const QString &callsign, QObject *parent) : QObject{parent},

QRegularExpression prefnRE = prefixRegEx();
QRegularExpressionMatch matchPrefix = prefnRE.match(fullCallsign);
/*
QRegularExpression re("^(?<date>\\d\\d)/(?<month>\\d\\d)/(?<year>\\d\\d\\d\\d)$");
QRegularExpressionMatch match = re.match("08/12/1985");
if (match.hasMatch()) {
QString date = match.captured("date"); // date == "08"
QString month = match.captured("month"); // month == "12"
QString year = match.captured("year"); // year == 1985
}
*/

if ( match.hasMatch() )
{
//it is a valid callsign
valid = true;
hostPrefixWithDelimiter = match.captured(1);
hostPrefix = match.captured(2);
hostPrefixWithDelimiter = match.captured("pref");
hostPrefix = match.captured("hostprefix");
base = match.captured(3);
basePrefix = match.captured(4);
basePrefixNumber = match.captured(5);
Expand Down Expand Up @@ -84,9 +94,13 @@ QRegularExpression Callsign::prefixRegEx()
}

QString Callsign::callsignRegExString()
{ // The REGEX can still get more group names
// ^(?<fullcall>(?<pref>[A-Z0-9]{1,2}[0-9]?\/)?(?<fullhomepref>(?<homepref>[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?<areanumber>[0-9]|[0-9]+))(?<suffix>[A-Z]+))([\/](?<additionalsuffix>[A-Z0-9]+))?
return QString("^(([A-Z0-9]{1,2}[0-9]?\\/)?(([A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])([0-9]|[0-9]+))([A-Z]+))([\\/]([A-Z0-9]+))?");
{
// Base callsign
// ^(?<basecall>(?<baseprefixwithnumber>(?<baseprefix>[A-Z][0-9]|[A-Z]|[A-Z]{1,2}|[0-9][A-Z]|E)(?<areanumber>[0-9]+))(?<basesuffix>[A-Z]+))

// Host prefix /must end in /

return QString("^(?<fullcall>(?<pref>[A-Z0-9]{1,2}[0-9]?\\/)?(?<fullhomepref>(?<hostpref>[A-Z][0-9]|[A-Z]{1,2}|[0-9][A-Z])(?<areanumber>[0-9]|[0-9]+))(?<suffix>[A-Z]+))([\/](?<additionalsuffix>[A-Z0-9]+))?");
}

QString Callsign::prefixRegExString()
Expand Down
8 changes: 4 additions & 4 deletions src/inputwidgets/mainwindowinputothers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString
prefUsed = callsign.getHostPrefixWithoutNumber();
}

qDebug() << Q_FUNC_INFO << "mainPref: " << mainPref;
qDebug() << Q_FUNC_INFO << "prefUsed: " << prefUsed;
//qDebug() << Q_FUNC_INFO << "mainPref: " << mainPref;
//qDebug() << Q_FUNC_INFO << "prefUsed: " << prefUsed;

if ((mainToUse.isEmpty()) && (prefUsed.isEmpty()))
return;
Expand All @@ -801,11 +801,11 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, prefUsed));
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with prefUSed, running for the main prefix";
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with prefUSed, running for the main prefix";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, mainToUse));
if (subdivisions.length()<1)
{
qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with mainpref, running just with the entity";
//qDebug() << Q_FUNC_INFO << " - Subdivisions is empty with mainpref, running just with the entity";
subdivisions.append(dataProxy->getPrimarySubDivisions(currentInt, QString()));
}
}
Expand Down
69 changes: 43 additions & 26 deletions src/logmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@

LogModel::LogModel(DataProxy_SQLite *dp, QObject *parent):QSqlRelationalTableModel(parent)
{
//qDebug() << Q_FUNC_INFO ;
qDebug() << Q_FUNC_INFO ;
//logModel = new QSqlRelationalTableModel(this);
dataProxy = dp;
util = new Utilities(Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << "llamando a filterValidFields";
qDebug() << Q_FUNC_INFO << "llamando a filterValidFields";
columns = dataProxy->filterValidFields(util->getDefaultLogFields());
setTable("log");

setEditStrategy(QSqlTableModel::OnFieldChange);
//qDebug() << Q_FUNC_INFO << " - END";
qDebug() << Q_FUNC_INFO << " - END";
}

void LogModel::createlogModel(const int _i)
bool LogModel::createlogModel(const int _i)
{
/*
Log_Id = 0,
Expand All @@ -64,28 +65,37 @@ the view should present the city's name field to the user.
This should be coherent with the logview
*/

//qDebug() << Q_FUNC_INFO ;

qDebug() << Q_FUNC_INFO ;

QString stringQuery = QString("lognumber='%1'").arg(_i);
//QSqlQuery query(stringQuery);
setFilter(stringQuery);
setColumns(columns);
if (!setColumns(columns))
{
qDebug() << Q_FUNC_INFO << " - ERROR on setColumns";
return false;
}

if (!select())
{
qDebug() << Q_FUNC_INFO << " - ERROR on select()";
return false;
}

select();
//qDebug() << Q_FUNC_INFO << " - END";
qDebug() << Q_FUNC_INFO << " - END";
return true;
}

void LogModel::setColumns(const QStringList &_columns)
bool LogModel::setColumns(const QStringList &_columns)
{
//qDebug() << Q_FUNC_INFO ;
//QString auxt;
//foreach(auxt, _columns)
//{
// //qDebug() << Q_FUNC_INFO << ": " << auxt;
//}
qDebug() << Q_FUNC_INFO ;
QString auxt;
foreach(auxt, _columns)
{
qDebug() << Q_FUNC_INFO << ": " << auxt;
}
columns.clear();
//qDebug() << Q_FUNC_INFO << "llamando a filterValidFields";
qDebug() << Q_FUNC_INFO << " - calling filterValidFields";
columns << dataProxy->filterValidFields(_columns);

QSqlQuery q;
Expand All @@ -94,15 +104,17 @@ This should be coherent with the logview

int nameCol;

bool sqlOK = q.exec(stringQuery);
if (!sqlOK)
if (!q.exec(stringQuery))
{
emit queryError(Q_FUNC_INFO, q.lastError().databaseText(), q.lastError().nativeErrorCode(), q.lastQuery());
emit queryError(Q_FUNC_INFO, q.lastError().databaseText(), q.lastError().nativeErrorCode(), q.lastQuery());
return false;
}
q.next();

if (!q.next())
return false;
rec = q.record(); // Number of columns

//qDebug() << "LogModel::createlogModel - columns: " << QString::number(rec.count());
qDebug() <<Q_FUNC_INFO << ": - columns: " << QString::number(rec.count());

if (_columns.contains("bandid"))
{
Expand Down Expand Up @@ -141,10 +153,15 @@ This should be coherent with the logview
foreach(aux, columns)
{
nameCol = rec.indexOf(aux);
setHeaderData(nameCol, Qt::Horizontal, util->getLogColumnName(aux));
//qDebug() << Q_FUNC_INFO << ": - " << aux;
}
//qDebug() << Q_FUNC_INFO << " - END";
if (!setHeaderData(nameCol, Qt::Horizontal, util->getLogColumnName(aux)))
{
qDebug() << Q_FUNC_INFO << ": - ERROR when adding the following column to the log view model: " << aux;
return false;
}
qDebug() << Q_FUNC_INFO << ": - " << aux;
}
qDebug() << Q_FUNC_INFO << " - END";
return true;
}
/*
void LogModel::showColumn(const QString &_columnName)
Expand Down
4 changes: 2 additions & 2 deletions src/logmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class LogModel : public QSqlRelationalTableModel
Q_OBJECT
public:
LogModel(DataProxy_SQLite *dp, QObject *parent);
void createlogModel(const int _i);
void setColumns(const QStringList &_columns);
bool createlogModel(const int _i);
bool setColumns(const QStringList &_columns);
private:
//void showColumn(const QString &_columnName);

Expand Down
Loading

0 comments on commit 2cffdb0

Please sign in to comment.