Skip to content

Commit

Permalink
QSOs were not properly shown after a reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
ea4k committed Jan 4, 2025
1 parent d7282fd commit 5d8c1a3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 42 deletions.
7 changes: 3 additions & 4 deletions src/Changelog
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
TODO: Review the KLog first start. Reading cty.dat is terribly slow.


TODO-Bug: Add QSOs from wsjtx does not work. Failure close to int QSO::toDB(int _qsoId) Maybe related to QSO dupe (it was already fixed)
WIP: Subdivisions only works with the main prefix. It is needed to find the prefix (EB, EC for EA and so on)
TODO-Test: Add tests to test the subsivisions
TODO-Test: the copy constructor of QSO
Complete: void MainWindow::slotQSOReceived(const QSO &_qso) to add the QSO
Check the bug that makes WSJTX not logging automatically

TODO-Test: Add tests to test the subsivisions
TODO-Test: the copy constructor of QSO


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
Expand Down
8 changes: 4 additions & 4 deletions src/logmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ 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);
if (!setColumns(columns))
{
//qDebug() << Q_FUNC_INFO << " - ERROR on setColumns";
//qDebug() << Q_FUNC_INFO << " - ERROR on setColumns";
return false;
}

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

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

Expand Down
18 changes: 10 additions & 8 deletions src/logwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ LogWindow::~LogWindow()

void LogWindow::setColumns(const QStringList &_columns)
{
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
columns.clear();
//qDebug() << Q_FUNC_INFO << "llamando a filterValidFields";
//qDebug() << Q_FUNC_INFO << "llamando a filterValidFields";
columns << dataProxy->filterValidFields(_columns);
logModel->setColumns(columns);
//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
}

void LogWindow::sortColumn(const int _c)
Expand Down Expand Up @@ -105,10 +105,12 @@ void LogWindow::setDefaultData()

void LogWindow::createlogPanel(const int _currentLog)
{
//qDebug() << Q_FUNC_INFO << " - Start : " << QString::number(_currentLog);
//qDebug() << Q_FUNC_INFO << " - Start : " << QString::number(_currentLog);
currentLog = _currentLog;
if (!logModel->createlogModel(currentLog))
//qDebug() << Q_FUNC_INFO << " - ERROR creating model";
{
//qDebug() << Q_FUNC_INFO << " - ERROR creating model";
}

logView->setModel(logModel);
logView->setCurrentIndex(logModel->index(0, 0));
Expand Down Expand Up @@ -192,19 +194,19 @@ void LogWindow::showColumn(const QString &_columnName)

void LogWindow::refresh()
{
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
if (!logModel->select())
{
//qDebug() << Q_FUNC_INFO << " - ERROR on select()";
//qDebug() << Q_FUNC_INFO << " - Error refreshing log:" << logModel->lastError().text();
QMessageBox msgBox;
msgBox.setText(tr("There was a problem with the log, please restart KLog and contact the development team if the error persist."));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}

//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
}

void LogWindow::createActions()
Expand Down
28 changes: 15 additions & 13 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3495,6 +3495,7 @@ void MainWindow::slotOpenWiki()
logEvent(Q_FUNC_INFO, "END", Debug);
}


bool MainWindow::applySettings()
{
//qDebug() << Q_FUNC_INFO << " - Start";
Expand Down Expand Up @@ -5737,21 +5738,22 @@ void MainWindow::slotShowQSOsFromDXCCWidget(QList<int> _qsos)
}


void MainWindow::slotQSOReceived(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << " - Start";
void MainWindow::slotQSOReceived(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << " - Start";
//logEvent(Q_FUNC_INFO, "Start", Debug);

if (!wsjtxAutoLog)
if (!askToAddQSOReceived(_qso))
return;
//qDebug() << Q_FUNC_INFO << "010";
//qDebug() << Q_FUNC_INFO << "010";
QSO q;
//qDebug() << Q_FUNC_INFO << "020";
//qDebug() << Q_FUNC_INFO << "020";
q.copy(_qso);
//qDebug() << Q_FUNC_INFO << "030";

//qDebug() << Q_FUNC_INFO << "Mode: " << q.getMode();
q.setLogId(currentLog);
//qDebug() << Q_FUNC_INFO << "030";
//qDebug() << Q_FUNC_INFO << "Call: " << q.getCall();
//qDebug() << Q_FUNC_INFO << "Mode: " << q.getMode();

int dxcc = world->getQRZARRLId(q.getCall());
//qDebug() << Q_FUNC_INFO << "040";
Expand All @@ -5765,7 +5767,7 @@ void MainWindow::slotQSOReceived(const QSO &_qso)

//qDebug() << Q_FUNC_INFO << "070";
int addedQSO = q.toDB();
//qDebug() << Q_FUNC_INFO << "080";
//qDebug() << Q_FUNC_INFO << "addedQSO: " << addedQSO;
if (addedQSO>0)
{
//qDebug() << Q_FUNC_INFO << "090";
Expand All @@ -5786,7 +5788,7 @@ void MainWindow::slotQSOReceived(const QSO &_qso)

bool MainWindow::askToAddQSOReceived(const QSO &_qso)
{
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(tr("KLog - QSO received - NEW"));
Expand Down Expand Up @@ -5834,7 +5836,7 @@ bool MainWindow::askToAddQSOReceived(const QSO &_qso)
bool MainWindow::showWSJTXDuplicatedMSG(const QSO &_qso)
{
QSO q = _qso;
//qDebug() << Q_FUNC_INFO << " - Calling isThisQSODuplicated with call: " << q.getCall();
//qDebug() << Q_FUNC_INFO << " - Calling isThisQSODuplicated with call: " << q.getCall();
if (!((dataProxy->isThisQSODuplicated(q, dupeSlotInSeconds)).length()>0))
return true;

Expand Down Expand Up @@ -6564,9 +6566,9 @@ bool MainWindow::loadSettings()
readActiveBands (settings.value("Bands", listAux).toStringList ());
settings.endGroup ();

//qDebug() << Q_FUNC_INFO << " - 40 - logview";
//qDebug() << Q_FUNC_INFO << " - 40 - logview";
logWindow->setColumns(settings.value ("LogViewFields").toStringList ());
//qDebug() << Q_FUNC_INFO << " - 41 - logs";
//qDebug() << Q_FUNC_INFO << " - 41 - logs";


//qDebug() << Q_FUNC_INFO << " - 50 - dxcluster";
Expand Down
26 changes: 13 additions & 13 deletions src/qso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3375,10 +3375,10 @@ bool QSO::setData(const QString &_adifPair)
int QSO::toDB(int _qsoId)
{ // This function will add or modify a QSO in the DB depending on the _qsoID.
// if _qsoID is >0 it should be an existing QSO in the DB.
//qDebug() << Q_FUNC_INFO << " - Start: qsoId: " << QString::number(_qsoId);
//qDebug() << Q_FUNC_INFO << " - Start: qsoId: " << QString::number(_qsoId);
if (!isComplete ())
{
//qDebug() << Q_FUNC_INFO << " - QSO NOT COMPLETE";
//qDebug() << Q_FUNC_INFO << " - QSO NOT COMPLETE";
return -1;
}

Expand All @@ -3389,38 +3389,38 @@ int QSO::toDB(int _qsoId)
queryString.clear();
if (_qsoId<=0)
{
//qDebug() << Q_FUNC_INFO << " - qsoID <=0";
//qDebug() << Q_FUNC_INFO << " - qsoID <=0";
queryString = getAddQueryString();
}
else
{
//qDebug() << Q_FUNC_INFO << " - qsoID>0";
//qDebug() << Q_FUNC_INFO << " - qsoID>0";
queryString = getModifyQueryString();
}
//qDebug() << Q_FUNC_INFO << " Query: " << queryString;;
//qDebug() << Q_FUNC_INFO << " Query: " << queryString;;

QSqlQuery query = getPreparedQuery(queryString);
//qDebug() << Q_FUNC_INFO << " qsoId: " << QString::number(_qsoId);
//qDebug() << Q_FUNC_INFO << " qsoId: " << QString::number(_qsoId);
if (_qsoId>0)
{
//qDebug() << Q_FUNC_INFO << " - binding ID";
//qDebug() << Q_FUNC_INFO << " - binding ID";
query.bindValue (":id", _qsoId);
}
//qDebug() << Q_FUNC_INFO << " - executing query";
//qDebug() << Q_FUNC_INFO << " - executing query";
if (query.exec())
{
//qDebug() << Q_FUNC_INFO << QString(": QSO ADDED/Modified: %1 - %2").arg(callsign).arg(getDateTimeOn().toString("yyyyMMdd-hhmm"));
//qDebug() << Q_FUNC_INFO << ": QSO ADDED/Modified: " << query.lastQuery ();
//qDebug() << Q_FUNC_INFO << QString(": QSO ADDED/Modified: %1 - %2").arg(callsign).arg(getDateTimeOn().toString("yyyyMMdd-hhmm"));
//qDebug() << Q_FUNC_INFO << ": QSO ADDED/Modified: " << query.lastQuery ();
if (_qsoId>0)
return _qsoId;
//db = new DataBase(Q_FUNC_INFO, _softVersion, util->getKLogDBFile());

return getLastInsertedQSO();
}
else
{

//qDebug() << Q_FUNC_INFO << QString(": QSO NOT ADDED/Modified: %1 - %2").arg(callsign).arg(_qsoId);
//qDebug() << Q_FUNC_INFO << ": QSO NOT ADDED/Modified: " << query.lastQuery ();
//qDebug() << Q_FUNC_INFO << ": QSO NOT ADDED/Modified: " << query.lastQuery ();
//qDebug() << Q_FUNC_INFO << ": Error: databaseText: " << query.lastError().databaseText();
//qDebug() << Q_FUNC_INFO << ": Error: text: " << query.lastError().text();
//qDebug() << Q_FUNC_INFO << ": Error: driverText: " << query.lastError().driverText();
Expand All @@ -3430,7 +3430,7 @@ int QSO::toDB(int _qsoId)
return -2;
}
query.finish();
//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
return 1;
}

Expand Down

0 comments on commit 5d8c1a3

Please sign in to comment.