From 144b4f94eebdd2953a1b9c71ab83ca40b5ee5dab Mon Sep 17 00:00:00 2001 From: d Date: Sun, 16 Jun 2024 19:39:49 +0200 Subject: [PATCH] Updating code --- src/Changelog | 2 + src/TROUBLESHOUTING | 7 + src/awardswidget.cpp | 2 +- src/database.cpp | 892 +++++++----------------- src/database.h | 4 +- src/dataproxy_sqlite.cpp | 72 +- src/dxccstatuswidget.cpp | 1 - src/dxcluster/dxcluster.cpp | 10 +- src/dxcluster/dxspot.cpp | 93 +++ src/dxcluster/dxspot.h | 80 +++ src/frequency.cpp | 10 - src/main.cpp | 2 +- src/mainwindow.cpp | 73 +- src/setupdialog.cpp | 58 +- src/setuppages/setuppagelogs.cpp | 24 +- src/setuppages/setuppageworldeditor.cpp | 4 +- src/src.pro | 2 + src/utilities.cpp | 28 +- src/world.cpp | 4 +- tests/tests.pro | 1 + tests/tst_database/tst_database.cpp | 16 +- tests/tst_dxspot/tst_dxspot.cpp | 124 ++++ tests/tst_dxspot/tst_dxspot.pro | 31 + tests/tst_frequency/tst_frequency.cpp | 6 +- tests/tst_frequency/tst_frequency.pro | 2 +- 25 files changed, 766 insertions(+), 782 deletions(-) create mode 100644 src/TROUBLESHOUTING create mode 100644 src/dxcluster/dxspot.cpp create mode 100644 src/dxcluster/dxspot.h create mode 100644 tests/tst_dxspot/tst_dxspot.cpp create mode 100644 tests/tst_dxspot/tst_dxspot.pro diff --git a/src/Changelog b/src/Changelog index 2e3054d2..89d796b0 100644 --- a/src/Changelog +++ b/src/Changelog @@ -1,6 +1,7 @@ TODO: Update the DB (modes table) updateToLatest() => updateTo026 WIP: Try to optimize bool DataProxy_SQLite::fillEmptyDXCCInTheLog() WIP: Working in the update of the table awarddxcc in DB class +WIP: - Bugfix: DB in alternative locations was not always found. (WIP #706) TESTS to do during RC releases: - ADIF log Import @@ -33,6 +34,7 @@ TBD - 2.4 - Bugfix: CQ & ITU zones may be wrong for callsigns from specific DXCC if coming from WSJTX. - Bugfix: ClubLog date was not properly managed. + Mar 2024 - 2.3.4 - BugFix: After Editing a QSO, lotw_qsl_rcvd is emptied (Closes #656, #659) (TNX N6PAZ, EA5WA) - Bugfix: Keep data of SAT tab when entering a QSO stopped working. (TNX EA5WA) diff --git a/src/TROUBLESHOUTING b/src/TROUBLESHOUTING new file mode 100644 index 00000000..4def4b89 --- /dev/null +++ b/src/TROUBLESHOUTING @@ -0,0 +1,7 @@ +Linux - Raspbian + +Error message in the console when KLog start: + qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in "" + +Solution: install qt6-wayland package + sudo apt install qt6-wayland \ No newline at end of file diff --git a/src/awardswidget.cpp b/src/awardswidget.cpp index dae374f6..3a87e64c 100644 --- a/src/awardswidget.cpp +++ b/src/awardswidget.cpp @@ -358,7 +358,7 @@ void AwardsWidget::showAwards() showDXMarathon(selectedYear); emit debugLog(Q_FUNC_INFO, "END", logLevel); - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; } void AwardsWidget::showDXMarathon(const int _year) diff --git a/src/database.cpp b/src/database.cpp index ba6a4c50..50348ee5 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -30,27 +30,30 @@ DataBase::DataBase(const QString &_parentClass, const QString &_DBName) { Q_UNUSED(_parentClass); - //qDebug() << "DataBase::DataBase: PLAIN: " << _parentClass << " / Name = " << _DBName ; + qDebug() << Q_FUNC_INFO << _parentClass << " / Name = " << _DBName ; logLevel = None; constrid = 1; created = false; - + qDebug() << Q_FUNC_INFO << " 001"; util = new Utilities(Q_FUNC_INFO); + qDebug() << Q_FUNC_INFO << " 003"; softVersion = util->getVersion(); + qDebug() << Q_FUNC_INFO << " 004"; dbName = _DBName; - //connect(this, SIGNAL(debugLog(QString, QString, int)), this, SLOT(slotPrintErrors(QString, QString, int)) ); - //qDebug() << "DataBase::DataBase1: dbName: " << dbName ; - - //db = QSqlDatabase::database(); - + qDebug() << Q_FUNC_INFO << " dbName: " << dbName ; dbVersion = DBVersionf; + qDebug() << Q_FUNC_INFO << " 005"; if (!createConnection(QString(Q_FUNC_INFO)+"1")) + { + qDebug() << Q_FUNC_INFO << " 006:Could not create a connection"; return; - //qDebug() << "DataBase::DataBase: PLAIN - connection Name: " << dbConnectionName ; - //qDebug() << "DataBase::DataBase: PLAIN - DB Name: " << db.databaseName() ; + } + qDebug() << Q_FUNC_INFO << " 010"; + qDebug() << Q_FUNC_INFO << " - connection Name: " << dbConnectionName ; + qDebug() << Q_FUNC_INFO << " - DB Name: " << db.databaseName() ; insertPreparedQueries.clear(); insertQueryFields.clear(); - //qDebug() << "DataBase::DataBase: PLAIN: - END" ; + qDebug() << Q_FUNC_INFO << " - END" ; } DataBase::DataBase(const QString &_parentClass, const QString &_softVersion, const QString &_DBName) @@ -82,7 +85,6 @@ DataBase::DataBase(const QString &_parentClass, const QString &_softVersion, con //qDebug() << "DataBase::DataBase2: END" ; } - DataBase::~DataBase() { logEvent(Q_FUNC_INFO, "Start", Debug); @@ -242,53 +244,54 @@ bool DataBase::reConnect(const QString &_DBName) bool DataBase::createConnection(const QString &function, bool newDB) { - //qDebug() << "DataBase::createConnection: " << function << "-" << QString::number(dbVersion) << "/" << softVersion ; + qDebug() << Q_FUNC_INFO << " - Start"; + qDebug() << Q_FUNC_INFO << " :" << function << "-" << QString::number(dbVersion) << "/" << softVersion ; logEvent(Q_FUNC_INFO, "Start", Debug); Q_UNUSED(function); Q_UNUSED(newDB); QString stringQuery; QSqlQuery query; - //qDebug() << Q_FUNC_INFO << ": check if open"; + qDebug() << Q_FUNC_INFO << ": check if open"; if (!db.isOpen()) { - //qDebug() << "DataBase::createConnection: DB NOT Opened" ; + qDebug() << Q_FUNC_INFO << ": DB NOT Opened" ; if (!db.isValid()) { - //qDebug() << "DataBase::createConnection: DB is not valid, let's call addDataBase" ; + qDebug() << Q_FUNC_INFO << ": DB is not valid, let's call addDataBase" ; if (!db.isOpen()) { - //qDebug() << "DataBase::createConnection: DB is NOT open, let's open: connection name" << db.connectionName(); + qDebug() << Q_FUNC_INFO << ": DB is NOT open, let's open: connection name" << db.connectionName(); QSqlDatabase::removeDatabase("qt_sql_default_connection"); db = QSqlDatabase::addDatabase("QSQLITE"); } - //qDebug() << "DataBase::createConnection: Now we call setDatabaseName" ; + qDebug() << Q_FUNC_INFO << ": Now we call setDatabaseName" ; db.setDatabaseName(dbName); - //qDebug() << "DataBase::createConnection: end of not valid" ; + qDebug() < TMP data table to operate and be deleted afterwards - //qDebug() << "DataBase::createTableEntity" ; + qDebug() << Q_FUNC_INFO << " - Start"; - QString stringQuery = QString(); - //QSqlQuery query; - if (NoTmp) - { - stringQuery = "CREATE TABLE entity" ; - } - else - { - stringQuery = "CREATE TABLE entitytemp" ; - } + QString table = "entity"; + if (!NoTmp) + table = "entitytemp"; - stringQuery = stringQuery + QString( " (id INTEGER PRIMARY KEY AUTOINCREMENT, " + QString stringQuery = QString("CREATE TABLE %1 (id INTEGER PRIMARY KEY AUTOINCREMENT, " "name VARCHAR(40) NOT NULL," "cqz INTEGER NOT NULL, " "ituz INTEGER NOT NULL, " - "cont INTEGER NOT NULL, " + "continent INTEGER NOT NULL, " "latitude REAL NOT NULL, " "longitude REAL NOT NULL, " "utc REAL NOT NULL, " @@ -2929,9 +2916,7 @@ bool DataBase::createTableEntity(const bool NoTmp) "todate VARCHAR(10), " "isoname VARCHAR(10), " "UNIQUE (dxcc, mainprefix), " - "FOREIGN KEY (cont) REFERENCES continent(id) )"); - - //qDebug() << "DataBase::createTableEntity END" ; + "FOREIGN KEY (continent) REFERENCES continent(id) )").arg(table); return execQuery(Q_FUNC_INFO, stringQuery); //TODO: To add some columns in this the table to mark if worked/confirmed/band/Mode } @@ -3208,239 +3193,74 @@ bool DataBase::howManyQSOsInLog(const int i) bool DataBase::updateTo006() {// Updates the DB to 0.0.6 - //qDebug() << "DataBase::updateTo006: latestRead: " << getDBVersion() ; - bool IAmIn006 = false; - bool IAmIn005 = false; - bool ErrorUpdating = false; + qDebug() << Q_FUNC_INFO << ": latestRead: " << getDBVersion() ; + QString stringQuery = QString(); - bool sqlOk = false; - latestReaded = getDBVersion().toFloat(); + double latestReaded = getDBVersion().toFloat(); if (latestReaded >= 0.006f) - { return true; - } - else - { - IAmIn006 = false; - } - while (!IAmIn006 && !ErrorUpdating) - { - //qDebug() << "DataBase::updateTo006: - Still not in 006" ; - while (!IAmIn005 && !ErrorUpdating) - { - //qDebug() << "DataBase::updateTo006: - And still not in 005" ; - IAmIn005 = updateTo005(); - } - //qDebug() << "DataBase::updateTo006: - Already in 005" ; - if (ErrorUpdating) - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(0)" ; - return false; - } + if (!updateTo005()) + return false; - sqlOk = updateDBVersion(softVersion, "0.006"); + if (!recreatePropModes()) + return false; + if (!updateTableLog(6)) + return false; - if(sqlOk) - { - //qDebug() << "DataBase::updateTo006: - DB Updated" ; - sqlOk = recreatePropModes(); + if (!createTableBand(false)) + return false; - if(sqlOk) - { - //qDebug() << "DataBase::updateTo006: - recreatePropModes OK" ; - sqlOk = updateTableLog(6); // We copy the log into logtemp - } - else - { - //qDebug() << "DataBase::updateTo006: - recreatePropModes NOK" ; - ErrorUpdating = true; - IAmIn006 = false; - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(1)" ; - return false; - } + if (!populateTableBand(false)) + return false; - sqlOk = createTableBand(false); // We create the bandTemp - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - createTableBand OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(2)" ; - ErrorUpdating = true; - //return false; - } + if (!updateBandIdTableLogToNewOnes()) + return false; - sqlOk = populateTableBand(false); // Populate the bandTemp - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - populateTableBand OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(3)" ; - ErrorUpdating = true; - } + if (!updateBandIdTableAward(1)) + return false; - sqlOk = updateBandIdTableLogToNewOnes(); - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - updateBandIdTableLogToNewOnes OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(4)" ; - ErrorUpdating = true; - } + if (!updateBandIdTableAward(2)) + return false; - sqlOk = updateBandIdTableAward(1); // DXCC - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - updateBandIdTableAward 1 OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(5)" ; - ErrorUpdating = true; - } + if (!execQuery(Q_FUNC_INFO, "DROP TABLE band")) + return false; - sqlOk = updateBandIdTableAward(2); // WAZ - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - updateBandIdTableAward 2 OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(6)" ; - ErrorUpdating = true; - } + if (!execQuery(Q_FUNC_INFO, "ALTER TABLE bandtemp RENAME TO band")) + return false; + if (!updateTheModeTableAndSyncLog()) + return false; - if (execQuery(Q_FUNC_INFO, "DROP TABLE band")) - { - if (execQuery(Q_FUNC_INFO, "ALTER TABLE bandtemp RENAME TO band")) - { - //qDebug() << "DataBase::updateTo006 - bandtemp renamed" ; - } - else - { - //qDebug() << "DataBase::updateTo006 - ERROR - bandtemp not renamed" ; - ErrorUpdating = true; - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(7)" ; - } - } - else - { - //qDebug() << "DataBase::updateTo006 - ERROR - bandtemp not dropped" ; - ErrorUpdating = true; - IAmIn006 = false; - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(8)" ; - ErrorUpdating = true; - } + if (!createTableClubLogStatus()) + return false; - sqlOk = updateTheModeTableAndSyncLog(); - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - updateTheModeTableAndSyncLog OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(9)" ; - ErrorUpdating = true; - } + if (!populateTableClubLogStatus()) + return false; - sqlOk = createTableClubLogStatus(); - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - createTableClubLogStatus OK" ; - sqlOk = populateTableClubLogStatus(); - if (sqlOk) - { - //qDebug() << "DataBase::updateTo006: - populateTableClubLogStatus OK" ; - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(10)" ; - ErrorUpdating = true; - } - } - else - { - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(11)" ; - ErrorUpdating = true; - } - } - else - {// Version not updated - //qDebug() << "DataBase::updateTo006: - DB NOT Updated" ; - ErrorUpdating = true; - IAmIn006 = false; - //qDebug() << "DataBase::updateTo006: UPDATED NOK!(12)" ; - ErrorUpdating = true; - } - //qDebug() << "DataBase::updateTo006: - IAmIn006 = TRUE" ; - IAmIn006 = true; - } - //DO ALL THE TASKS TO BE IN 0.006 from 0.005 HERE and set ErrorUpdating if it is not possible. - //qDebug() << "DataBase::updateTo006 - I am in 006 " ; - //qDebug() << "DataBase::updateTo006 - END " ; - //qDebug() << "DataBase::updateTo006: UPDATED OK!" ; - if (!IAmIn006) - { - // emit debugLog(Q_FUNC_INFO, "2", 7); - } - return IAmIn006; + return updateDBVersion(softVersion, "0.006"); } bool DataBase::updateTableLog(const int _v) { - //qDebug() << "DataBase::updateTableLog " ; - createTableLog(false); - QString queryString; - switch (_v) - { - case 6: // If 6, we copy in logtemp the full data coming from the old log. This way, the structure of - // the log table is updated without any data loss. - queryString = QString ("INSERT INTO logtemp (qso_date, call, rst_sent, rst_rcvd, bandid, modeid, srx, stx, cqz, ituz, dxcc, address, age, cnty, comment, a_index, ant_az, ant_el, ant_path, arrl_sect, band_rx, checkcontest, class, contacted_op, contest_id, country, credit_submitted, credit_granted, distance, email, eq_call, eqsl_qslrdate, eqsl_qslsdate, eqsl_qsl_rcvd, eqsl_qsl_sent, force_init, freq, freq_rx, gridsquare, iota, iota_island_id, k_index, lat, lon, lotw_qslrdate, lotw_qslsdate, lotw_qsl_rcvd, lotw_qsl_sent, max_bursts, ms_shower, my_city, my_cnty, my_country, my_cq_zone, my_gridsquare, my_iota, my_iota_island_id, my_lat, my_lon, my_name, my_rig, my_sig, my_sig_info, my_state, my_street, name, notes, nr_bursts, nr_pings, operator, owner_callsign, pfx, precedence, prop_mode, public_key, qslmsg, qslrdate, qslsdate, qsl_rcvd, qsl_sent, qsl_rcvd_via, qsl_sent_via, qsl_via, qso_complete, qso_random, qth, rx_pwr, sat_mode, sat_name, sfi, sig, sig_info, srx_string, stx_string, state, station_callsign, swl, ten_ten, tx_pwr, web, qso_date_off, marked, lognumber) SELECT qso_date, call, rst_sent, rst_rcvd, bandid, modeid, srx, stx, cqz, ituz, dxcc, address, age, cnty, comment, a_index, ant_az, ant_el, ant_path, arrl_sect, band_rx, checkcontest, class, contacted_op, contest_id, country, credit_submitted, credit_granted, distance, email, eq_call, eqsl_qslrdate, eqsl_qslsdate, eqsl_qsl_rcvd, eqsl_qsl_sent, force_init, freq, freq_rx, gridsquare, iota, iota_island_id, k_index, lat, lon, lotw_qslrdate, lotw_qslsdate, lotw_qsl_rcvd, lotw_qsl_sent, max_bursts, ms_shower, my_city, my_cnty, my_country, my_cq_zone, my_gridsquare, my_iota, my_iota_island_id, my_lat, my_lon, my_name, my_rig, my_sig, my_sig_info, my_state, my_street, name, notes, nr_bursts, nr_pings, operator, owner_callsign, pfx, precedence, prop_mode, public_key, qslmsg, qslrdate, qslsdate, qsl_rcvd, qsl_sent, qsl_rcvd_via, qsl_sent_via, qsl_via, qso_complete, qso_random, qth, rx_pwr, sat_mode, sat_name, sfi, sig, sig_info, srx_string, stx_string, state, station_callsign, swl, ten_ten, tx_pwr, web, qso_date_off, marked, lognumber FROM log"); - break; - default: - //qDebug() << "DataBase::updateTableLog FALSE END" ; + qDebug() << Q_FUNC_INFO; + if (_v!=6) return false; - //break; - } - if (execQuery(Q_FUNC_INFO, queryString)) - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - Query executed" ; - queryString = "DROP TABLE log"; - if (execQuery(Q_FUNC_INFO, queryString)) - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - Table log dropped" ; + if (createTableLog(false)) + return false; - queryString = "ALTER TABLE logtemp RENAME TO log" ; - if (execQuery(Q_FUNC_INFO, queryString)) - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - tmp renamed - END" ; - return true; - } - else - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - Renaming failed" ; - } - } - else - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - Table log Not dropped" ; - } - } - else - { - //qDebug() << "DataBase::updateTableLog: " << QString::number(_v) << " - query failed" ; - } - //qDebug() << "DataBase::updateTableLog END" ; - return false; + QString queryString = QString ("INSERT INTO logtemp (qso_date, call, rst_sent, rst_rcvd, bandid, modeid, srx, stx, cqz, ituz, dxcc, address, age, cnty, comment, a_index, ant_az, ant_el, ant_path, arrl_sect, band_rx, checkcontest, class, contacted_op, contest_id, country, credit_submitted, credit_granted, distance, email, eq_call, eqsl_qslrdate, eqsl_qslsdate, eqsl_qsl_rcvd, eqsl_qsl_sent, force_init, freq, freq_rx, gridsquare, iota, iota_island_id, k_index, lat, lon, lotw_qslrdate, lotw_qslsdate, lotw_qsl_rcvd, lotw_qsl_sent, max_bursts, ms_shower, my_city, my_cnty, my_country, my_cq_zone, my_gridsquare, my_iota, my_iota_island_id, my_lat, my_lon, my_name, my_rig, my_sig, my_sig_info, my_state, my_street, name, notes, nr_bursts, nr_pings, operator, owner_callsign, pfx, precedence, prop_mode, public_key, qslmsg, qslrdate, qslsdate, qsl_rcvd, qsl_sent, qsl_rcvd_via, qsl_sent_via, qsl_via, qso_complete, qso_random, qth, rx_pwr, sat_mode, sat_name, sfi, sig, sig_info, srx_string, stx_string, state, station_callsign, swl, ten_ten, tx_pwr, web, qso_date_off, marked, lognumber) SELECT qso_date, call, rst_sent, rst_rcvd, bandid, modeid, srx, stx, cqz, ituz, dxcc, address, age, cnty, comment, a_index, ant_az, ant_el, ant_path, arrl_sect, band_rx, checkcontest, class, contacted_op, contest_id, country, credit_submitted, credit_granted, distance, email, eq_call, eqsl_qslrdate, eqsl_qslsdate, eqsl_qsl_rcvd, eqsl_qsl_sent, force_init, freq, freq_rx, gridsquare, iota, iota_island_id, k_index, lat, lon, lotw_qslrdate, lotw_qslsdate, lotw_qsl_rcvd, lotw_qsl_sent, max_bursts, ms_shower, my_city, my_cnty, my_country, my_cq_zone, my_gridsquare, my_iota, my_iota_island_id, my_lat, my_lon, my_name, my_rig, my_sig, my_sig_info, my_state, my_street, name, notes, nr_bursts, nr_pings, operator, owner_callsign, pfx, precedence, prop_mode, public_key, qslmsg, qslrdate, qslsdate, qsl_rcvd, qsl_sent, qsl_rcvd_via, qsl_sent_via, qsl_via, qso_complete, qso_random, qth, rx_pwr, sat_mode, sat_name, sfi, sig, sig_info, srx_string, stx_string, state, station_callsign, swl, ten_ten, tx_pwr, web, qso_date_off, marked, lognumber FROM log"); + + if (!execQuery(Q_FUNC_INFO, queryString)) + return false; + + if (!execQuery(Q_FUNC_INFO, "DROP TABLE log")) + return false; + + queryString = "ALTER TABLE logtemp RENAME TO log" ; + return execQuery(Q_FUNC_INFO, queryString); } @@ -3459,124 +3279,64 @@ bool DataBase::createTableClubLogStatus() bool DataBase::populateTableClubLogStatus() { - //qDebug() << "populateTableClubLogStatus" ; + qDebug() << Q_FUNC_INFO; QString queryString = "INSERT INTO clublog_status (shortname, name) VALUES ('Y', 'Uploaded')"; + if (!execQuery(Q_FUNC_INFO, queryString)) + return false; + queryString = "INSERT INTO clublog_status (shortname, name) VALUES ('N', 'Do not upload')"; + if (!execQuery(Q_FUNC_INFO, queryString)) + return false; - if (execQuery(Q_FUNC_INFO, queryString)) - { - queryString = "INSERT INTO clublog_status (shortname, name) VALUES ('N', 'Do not upload')"; - if (execQuery(Q_FUNC_INFO, queryString)) - { - queryString = "INSERT INTO clublog_status (shortname, name) VALUES ('M', 'Modified')"; - //qDebug() << "populateTableClubLogStatus END" ; - return execQuery(Q_FUNC_INFO, queryString); - } - } - //qDebug() << "populateTableClubLogStatus FALSE END" ; - return false; + queryString = "INSERT INTO clublog_status (shortname, name) VALUES ('M', 'Modified')"; + return execQuery(Q_FUNC_INFO, queryString); } -bool DataBase::updateTableEntity() +bool DataBase::recreateTableEntity() { - //qDebug() << "DataBase::updateTableEntity" ; - bool result = false; + qDebug() << Q_FUNC_INFO << " - Start"; QString stringQuery; - bool sqlOk; - result = createTableEntity(false); // Now we have a temp entity table with the correct format - if (result) - { - //qDebug() << "DataBase::updateTableEntity: Table entitytemp created!" ; - // Now we need to move all the data from the old to the temp entity table. - - stringQuery = QString("INSERT INTO entitytemp (name, cqz, ituz, cont, latitude, longitude, utc, dxcc, mainprefix, deleted, sincedate, todate) SELECT name, cqz, ituz, cont, latitude, longitude, utc, dxcc, mainprefix, deleted, sincedate, todate FROM entity"); + if (!createTableEntity(false)) + return false; - sqlOk = execQuery(Q_FUNC_INFO, stringQuery); + qDebug() << Q_FUNC_INFO << " - 10"; + stringQuery = QString("INSERT INTO entitytemp (name, cqz, ituz, continent, latitude, longitude, utc, dxcc, mainprefix, deleted, sincedate, todate) SELECT name, cqz, ituz, continent, latitude, longitude, utc, dxcc, mainprefix, deleted, sincedate, todate FROM entity"); + if (!execQuery(Q_FUNC_INFO, stringQuery)) + return false; - if (sqlOk) - { - //qDebug() << "DataBase::updateTableEntity: Data copied from entity to entitytemp!" ; - stringQuery = "DROP TABLE entity"; - if (execQuery(Q_FUNC_INFO, stringQuery)) - { - //qDebug() << "DataBase::updateTableEntity: Table entity DELETED" ; - stringQuery = "ALTER TABLE entitytemp RENAME TO entity"; - return execQuery(Q_FUNC_INFO, stringQuery); - } - else - { - return false; - } - } - else - { - //qDebug() << "DataBase::updateTableEntity: Data NOT copied from entity to entitytemp!" ; - //TODO: If it fails, we should manage errors... - return false; - } - } - else - { - //qDebug() << "DataBase::updateTableEntity: Table entitytemp NOT created!" ; + qDebug() << Q_FUNC_INFO << " - 30"; + stringQuery = "DROP TABLE entity"; + if (!execQuery(Q_FUNC_INFO, stringQuery)) return false; - } - //return false; + qDebug() << Q_FUNC_INFO << " - 30"; + stringQuery = "ALTER TABLE entitytemp RENAME TO entity"; + return execQuery(Q_FUNC_INFO, stringQuery); } bool DataBase::updateTableLogs() { - //qDebug() << "DataBase::updateTableLogs" ; - bool result = false; + //qDebug() << "DataBase::updateTableLogs" ; QString stringQuery; - bool sqlOk; - - result = createTableLogs(false); // Now we have a temp entity table with the correct format - - if (result) - { - //qDebug() << "DataBase::updateTableLogs: Table logstemp created!" ; - // Now we need to move all the data from the old to the temp logs table. - stringQuery = QString("INSERT INTO logstemp (logdate, stationcall, comment, logtype, logtypen) SELECT logdate, stationcall, comment, logtype, logtypen FROM logs"); + if (!createTableLogs(false)) // Now we have a temp entity table with the correct format + return false; - sqlOk = execQuery(Q_FUNC_INFO, stringQuery); + //qDebug() << "DataBase::updateTableLogs: Table logstemp created!" ; + // Now we need to move all the data from the old to the temp logs table. - if (sqlOk) - { - //qDebug() << "DataBase::updateTableLogs: data copied" ; + stringQuery = QString("INSERT INTO logstemp (logdate, stationcall, comment, logtype, logtypen) SELECT logdate, stationcall, comment, logtype, logtypen FROM logs"); + if (!execQuery(Q_FUNC_INFO, stringQuery)) + return false; - stringQuery = "DROP TABLE logs"; - if (execQuery(Q_FUNC_INFO, stringQuery)) - { - //qDebug() << "DataBase::updateTableLogs: Table logs DELETED" ; - stringQuery = "ALTER TABLE logstemp RENAME TO logs"; - return execQuery(Q_FUNC_INFO, stringQuery); - } - else - { - //qDebug() << "DataBase::updateTableLogs: Table logs NOT DELETED" ; - return false; - } - } - else - { - //queryErrorManagement(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); - //qDebug() << "DataBase::updateTableLogs: data NOT copied" ; - //TODO: If it fails, we should manage errors... - return false; - } - } - else - { - //qDebug() << "DataBase::updateTableLogs: Table logstemp NOT created!" ; + stringQuery = "DROP TABLE logs"; + if (!execQuery(Q_FUNC_INFO, stringQuery)) return false; - } - //qDebug() << "DataBase::updateTableLogs: END" ; - //return false; + stringQuery = "ALTER TABLE logstemp RENAME TO logs"; + return execQuery(Q_FUNC_INFO, stringQuery); } bool DataBase::updateModeIdFromSubModeId() @@ -3749,8 +3509,6 @@ bool DataBase::updateModeIdFromSubModeId() return false; } //qDebug() << Q_FUNC_INFO << ": CHECK IF this is seen - END" ; - //query.finish(); - //return false; } @@ -4117,6 +3875,7 @@ bool DataBase::updateModeIdTableAward(const int _db) QString field = "mode"; QString awardSelected = QString(); + // Map database ID to table and award names switch (_db) { case 1: // table = "awarddxcc"; @@ -4142,7 +3901,6 @@ bool DataBase::updateModeIdTableAward(const int _db) QString sq = QString(); bool sqlOk2 = false; - bool sqlOk3 = false; int bandFound = -1; int id = -1; int qsos; @@ -4169,6 +3927,7 @@ bool DataBase::updateModeIdTableAward(const int _db) return false; } + // Progress dialog setup int step = util->getProgresStepForDialog(qsos); QString progressmsg = QString(QObject::tr("Updating mode information in %1 status...")).arg(awardSelected); @@ -4179,136 +3938,98 @@ bool DataBase::updateModeIdTableAward(const int _db) sq = QString("SELECT %1, id FROM %2 ORDER BY %3 DESC").arg(field).arg(table).arg(field); - sqlOk = query.exec(sq); - - //qDebug() << "DataBase::updateModeIdTableAward (query): " << query.lastQuery() ; - if (sqlOk) + if (!query.exec(sq)) { - while (query.next() && (!cancel) ) - { - bandtxt = QString(); - bandFound = -1; - - if (query.isValid()) - { - i++; - - if (( (i % step )== 0) ) - { // To update the speed I will only show the progress once each X QSOs - aux = QObject::tr("Updating bands information...") + "\n" + QObject::tr("Progress: ") + QString::number(i) + "/" + QString::number(qsos); - progress.setLabelText(aux); - progress.setValue(i); - } + queryErrorManagement(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); + //qDebug() << "DataBase::updateModeIdTableAward: FALSE END-4" ; + query.finish(); + return false; + } + //qDebug() << "DataBase::updateModeIdTableAward (query): " << query.lastQuery() ; + while (query.next() && (!cancel) ) + { + bandtxt = QString(); + bandFound = -1; - bandFound = (query.value(0)).toInt(); - id = (query.value(1)).toInt(); - //qDebug() << "DataBase::updateModeIdTableAward: bandfound: " << QString::number(bandFound) ; - //qDebug() << "DataBase::updateModeIdTableAward: id: " << QString::number(id) ; + if (query.isValid()) + { + i++; + if (( (i % step )== 0) ) + { // To update the speed I will only show the progress once each X QSOs + aux = QObject::tr("Updating bands information...") + "\n" + QObject::tr("Progress: ") + QString::number(i) + "/" + QString::number(qsos); + progress.setLabelText(aux); + progress.setValue(i); + } - bandtxt = getSubModeNameFromNumber(bandFound, true); + bandFound = (query.value(0)).toInt(); + id = (query.value(1)).toInt(); + //qDebug() << "DataBase::updateModeIdTableAward: bandfound: " << QString::number(bandFound) ; + //qDebug() << "DataBase::updateModeIdTableAward: id: " << QString::number(id) ; - //qDebug() << "DataBase::updateModeIdTableAward: mode found: " << bandtxt << "/" << QString::number(bandFound) ; + bandtxt = getSubModeNameFromNumber(bandFound, true); - sq = QString("SELECT id FROM modetemp WHERE submode='%1'").arg(bandtxt); - sqlOk2 = query2.exec(sq); + //qDebug() << "DataBase::updateModeIdTableAward: mode found: " << bandtxt << "/" << QString::number(bandFound) ; + sq = QString("SELECT id FROM modetemp WHERE submode='%1'").arg(bandtxt); + sqlOk2 = query2.exec(sq); - //qDebug() << "DataBase::updateModeIdTableAward (query2): " << query2.lastQuery() ; - if (sqlOk2) + //qDebug() << "DataBase::updateModeIdTableAward (query2): " << query2.lastQuery() ; + if (sqlOk2) + { + if (query2.next()) { - if (query2.next()) + if (query2.isValid()) { - if (query2.isValid()) - { - bandFound = query2.value(0).toInt(); - query2.finish(); - - sq = QString ("UPDATE %1 SET %2='%3' WHERE id='%4'").arg(table).arg(field).arg(bandFound).arg(id); - sqlOk3 = execQuery(Q_FUNC_INFO, sq); - - if (sqlOk3) - { - //qDebug() << "DataBase::updateModeIdTableAward: ID: " << QString::number(id) << " updated to: " << QString::number(bandFound) <<"/"<< bandtxt ; - } - else - { - //queryErrorManagement(Q_FUNC_INFO, query3.lastError().databaseText(), query3.lastError().nativeErrorCode(), query3.lastQuery()); - //qDebug() << "DataBase::updateModeIdTableAward: ID: " << QString::number(id) << " NOT updated-2" ; + bandFound = query2.value(0).toInt(); + query2.finish(); - //qDebug() << "DataBase::updateModeIdTableAward - QSOs not updated to main log" ; - } - } - else - { - //qDebug() << "DataBase::updateModeIdTableAward: query2 not valid " ; - } + sq = QString ("UPDATE %1 SET %2='%3' WHERE id='%4'").arg(table).arg(field).arg(bandFound).arg(id); + cancel = !execQuery(Q_FUNC_INFO, sq); } - else - { - //qDebug() << "DataBase::updateModeIdTableAward: query2 not next " ; - } - } - else - { - queryErrorManagement(Q_FUNC_INFO, query2.lastError().databaseText(), query2.lastError().nativeErrorCode(), query2.lastQuery()); - query2.finish(); - //qDebug() << "DataBase::updateModeIdTableAward: ID: " << QString::number(id) << " NOT updated-1" ; } } - - if ( progress.wasCanceled() ) + else { - if (!alreadyCancelled) - { - alreadyCancelled = true; - - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("KLog - DB update")); - aux = QObject::tr("Canceling this update will cause data inconsistencies and possibly data loss. Do you still want to cancel?"); - msgBox.setText(aux); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::No); - int ret = msgBox.exec(); - switch (ret) { - case QMessageBox::Yes: - // Yes was clicked - cancel = true; - break; - - case QMessageBox::No: - // No Save was clicked - cancel = false; - progress.setCancelButton(nullptr); - break; - default: - // should never be reached - cancel = false; - break; - } - } + queryErrorManagement(Q_FUNC_INFO, query2.lastError().databaseText(), query2.lastError().nativeErrorCode(), query2.lastQuery()); + query2.finish(); + //qDebug() << "DataBase::updateModeIdTableAward: ID: " << QString::number(id) << " NOT updated-1" ; } } - if (cancel && (!alreadyCancelled)) + if ( progress.wasCanceled() ) { - //qDebug() << "DataBase::updateModeIdTableAward: FALSE END-3" ; - query.finish(); - return false; + if (!alreadyCancelled) + { + alreadyCancelled = true; + + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("KLog - DB update")); + aux = QObject::tr("Canceling this update will cause data inconsistencies and possibly data loss. Do you still want to cancel?"); + msgBox.setText(aux); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int ret = msgBox.exec(); + switch (ret) { + case QMessageBox::Yes: + // Yes was clicked + cancel = true; + break; + case QMessageBox::No: + // No Save was clicked + cancel = false; + progress.setCancelButton(nullptr); + break; + default: + // should never be reached + cancel = false; + break; + } + } } - //qDebug() << "DataBase::updateModeIdTableAward: END OK" ; - query.finish(); - return true; } - else - { - queryErrorManagement(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); - //qDebug() << "DataBase::updateModeIdTableAward: FALSE END-4" ; - query.finish(); - return false; - } - //qDebug() << "DataBase::updateModeIdTableAward: Checkif seen END" ; - //query.finish(); - //return false; + + query.finish(); + return !(cancel && (!alreadyCancelled)); } /* @@ -4653,9 +4374,9 @@ bool DataBase::updateTo009() //qDebug() << "DataBase::updateTo009: - createTableSatellites OK" ; //if (populateTableSatellites(true)) - if (updateTableEntity()) + if (recreateTableEntity()) { - //qDebug() << "DataBase::updateTo009: - updateTableEntity OK" ; + //qDebug() << "DataBase::updateTo009: - recreateTableEntity OK" ; if (updateTheEntityTableISONames()) { //qDebug() << "DataBase::updateTo009: - isonames updated" ; @@ -5269,82 +4990,43 @@ bool DataBase::isTheTableExisting(const QString &_tableName) QSqlQuery query; QString sq = QString("SELECT COUNT(name) FROM sqlite_master WHERE name='%1'").arg(_tableName); - bool sqlOK = query.exec(sq); - if (sqlOK) - { - if (query.next()) - { - if (query.isValid()) - { - int _n = (query.value(0)).toInt(); - query.finish(); - return (_n>0); - } - } - } - else - { - // emit debugLog(Q_FUNC_INFO, "2", 7); + if (query.exec(sq)) return false; - } - // emit debugLog(Q_FUNC_INFO, "3", 7); - return false; + + if (!query.next()) + return false; + + if (!query.isValid()) + return false; + + int _n = (query.value(0)).toInt(); + query.finish(); + return (_n>0); } bool DataBase::hasTheTableData(const QString &_tableName) { - //qDebug() << "DataBase::hasTheTableData" << _tableName ; + //qDebug() << Q_FUNC_INFO << ": " << _tableName ; QSqlQuery query; QString stringQuery = QString("SELECT count(id) FROM %1").arg(_tableName); - bool sqlOK = query.exec(stringQuery); - - if (sqlOK) - { - query.next(); - if (query.isValid()) - { - //qDebug() << "DataBase::hasTheTableData - valid" ; - int _num = (query.value(0)).toInt(); - query.finish(); - if (_num > 0) - { - //qDebug() << "DataBase::hasTheTableData - DB Exists" ; - return true; - } - else - { - //qDebug() << "DataBase::hasTheTableData - DB does not Exist" ; - // emit debugLog(Q_FUNC_INFO, "1", 7); - return false; - } - } - else - { - //qDebug() << "DataBase::hasTheTableData - not valid" ; - query.finish(); - // emit debugLog(Q_FUNC_INFO, "2", 7); - return false; - } - } - else + if (!query.exec(stringQuery)) { - //qDebug() << "DataBase::hasTheTableData: LastQuery: " << query.lastQuery() ; - //qDebug() << "DataBase::hasTheTableData: LastError-data: " << query.lastError().databaseText() ; - //qDebug() << "DataBase::hasTheTableData: LastError-driver: " << query.lastError().driverText() ; - //qDebug() << "DataBase::hasTheTableData LastError-n: " << QString::number(query.lastError().nativeErrorCode() ) ; - //qDebug() << "DataBase::updateTheEntityTableISONames" ; queryErrorManagement(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); - query.finish(); - // emit debugLog(Q_FUNC_INFO, "3", 7); return false; } - //qDebug() << "DataBase::isTheDBCreated: END FALSE" ; - //query.finish(); - //return false; + if (!query.next()) + return false; + + if (!query.isValid()) + return false; + + int _num = (query.value(0)).toInt(); + query.finish(); + return (_num > 0); } bool DataBase::updateTo011() @@ -6285,66 +5967,28 @@ bool DataBase::updateTo025() // Updates the DB to 0.025: // Adds the mods on ADIF 3.1.3 - //qDebug() << "DataBase::updateto025: latestRead: " << getDBVersion() ; - bool IAmIn024 = false; - bool ErrorUpdating = false; + //qDebug() << Q_FUNC_INFO << " latestRead: " << getDBVersion() ; + latestReaded = getDBVersion().toFloat(); if (latestReaded >= 0.025f) { - //qDebug() << "DataBase::updateto025: - I am in 023" ; + //qDebug() << Q_FUNC_INFO << " - I am in 023" ; return true; } - else - { - //qDebug() << "DataBase::updateto014: - I am not in 0.014 I am in: " << getDBVersion() ; - while (!IAmIn024 && !ErrorUpdating) - { - //qDebug() << "DataBase::updateto015: - Check if I am in 024: !" ; - IAmIn024 = updateTo014(); - if (IAmIn024) - { - //qDebug() << "DataBase::updateto015: - updateTo013 returned TRUE - I am in 0.024: " << QString::number(latestReaded) ; - } - else - { - //qDebug() << "DataBase::updateto015: - updateTo011 returned FALSE - I am NOT in 0.024: " << QString::number(latestReaded) ; - ErrorUpdating = false; - } - } - if (ErrorUpdating) - { - //qDebug() << "DataBase::updateto025: - I Could not update to: " << QString::number(dbVersion) ; - // emit debugLog(Q_FUNC_INFO, "1", 7); - return false; - } - } - // Now I am in the previous version and I can update the DB. + if (!updateTo014()) + return false; - if ((updateTheModeTableAndSyncLog()) && (recreatePropModes ())) - { - //qDebug() << "DataBase::updateTo025: - updateTheModeTableAndSyncLog OK" ; - } - else - { - //qDebug() << "DataBase::updateTo025: UPDATED NOK!(9)" ; - //ErrorUpdating = true; - } + // Now I am in the previous version and I can update the DB. + if (!updateTheModeTableAndSyncLog()) + return false; - if (updateDBVersion(softVersion, "0.025")) - { - //qDebug() << "DataBase::updateto025: - We are in 025! " ; - } - else - { - //qDebug() << "DataBase::updateto025: - Failed to go to 024! " ; - // emit debugLog(Q_FUNC_INFO, "2", 7); + if (!recreatePropModes ()) return false; - } - //qDebug() << "DataBase::updateTo025: UPDATED OK!" ; - return true; + + return updateDBVersion(softVersion, "0.025"); } bool DataBase::updateTo026() @@ -6352,47 +5996,26 @@ bool DataBase::updateTo026() // Updates the DB to 0.026: // Recreates entity table to make UTC a real value // Adds many Modes & Submodes from ADIF 3.1.4 - - //qDebug() << "DataBase::updateto025: latestRead: " << getDBVersion() ; - bool IAmIn025 = false; - bool ErrorUpdating = false; + //qDebug() << Q_FUNC_INFO << " latestRead: " << getDBVersion() ; latestReaded = getDBVersion().toFloat(); if (latestReaded >= 0.026f) { - //qDebug() << "DataBase::updateto025: - I am in 023" ; + //qDebug() << Q_FUNC_INFO << " - I am in 026" ; return true; } - else - { - //qDebug() << "DataBase::updateto024: - I am not in 0.014 I am in: " << getDBVersion() ; - while (!IAmIn025 && !ErrorUpdating) - { - //qDebug() << "DataBase::updateto025: - Check if I am in 024: !" ; - IAmIn025 = updateTo024(); - if (IAmIn025) - { - //qDebug() << "DataBase::updateto025: - updateTo013 returned TRUE - I am in 0.024: " << QString::number(latestReaded) ; - } - else - { - //qDebug() << "DataBase::updateto025: - updateTo011 returned FALSE - I am NOT in 0.024: " << QString::number(latestReaded) ; - ErrorUpdating = false; - } - } - if (ErrorUpdating) - { - //qDebug() << "DataBase::updateto025: - I Could not update to: " << QString::number(dbVersion) ; - // emit debugLog(Q_FUNC_INFO, "1", 7); - return false; - } - } + qDebug() << Q_FUNC_INFO << " - 10" ; + if (!updateTo025()) + return false; - // Now I am in the previous version and I can update the DB. - if (recreateTableEntity() && (updateTheModeTableAndSyncLog())) - { - return updateDBVersion(softVersion, "0.026"); - } - return false; + qDebug() << Q_FUNC_INFO << " - 20" ; + if (!recreateTableEntity()) + return false; + + qDebug() << Q_FUNC_INFO << " - 30" ; + if (!updateTheModeTableAndSyncLog()) + return false; + qDebug() << Q_FUNC_INFO << " - 40" ; + return updateDBVersion(softVersion, "0.026"); } bool DataBase::updateAwardDXCCTable() @@ -6931,35 +6554,24 @@ void DataBase::queryErrorManagement(const QString &_functionFailed, const QStrin Q_UNUSED(errorCodeS); Q_UNUSED(_nativeError); Q_UNUSED(_failedQuery); - //qDebug() << Q_FUNC_INFO << ": constrid : " << QString::number(constrid) ; - //qDebug() << Q_FUNC_INFO << ": Function : " << _functionFailed ; - //qDebug() << Q_FUNC_INFO << ": Native : " << _nativeError ; - //qDebug() << Q_FUNC_INFO << ": Error : " << _functionFailed << errorCodeS ; - //qDebug() << Q_FUNC_INFO << ": Query failed: " << _failedQuery ; + //qDebug() << Q_FUNC_INFO << ": constrid : " << QString::number(constrid) ; + //qDebug() << Q_FUNC_INFO << ": Function : " << _functionFailed ; + //qDebug() << Q_FUNC_INFO << ": Native : " << _nativeError ; + //qDebug() << Q_FUNC_INFO << ": Error : " << _functionFailed << errorCodeS ; + //qDebug() << Q_FUNC_INFO << ": Query failed: " << _failedQuery ; } bool DataBase::execQuery(const QString &function, const QString &stringQuery) { //qDebug() << "DataBase::execQuery: " << function << " : " << stringQuery ; QSqlQuery query; - - if (query.exec(stringQuery)) - { - while (query.isActive()) - { - //qDebug() << "DataBase::execQuery: Still active... " ; - query.finish(); - } - //qDebug() << "DataBase::execQuery: No longer active... let's continue" ; - return true; - } - else + bool ok = query.exec(stringQuery); + query.finish(); + if (!ok) { queryErrorManagement(function, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); - query.finish(); - // emit debugLog(Q_FUNC_INFO, "1", 7); - return false; } + return ok; } void DataBase::logEvent(const QString &_func, const QString &_msg, DebugLogLevel _level) diff --git a/src/database.h b/src/database.h index 3c13e3c2..6bfba289 100644 --- a/src/database.h +++ b/src/database.h @@ -61,7 +61,6 @@ class DataBase : public QObject public: DataBase(const QString &_parentClass, const QString &_DBName); - //DataBase(const QString &_softVersion, bool inmemoryonly = false); DataBase(const QString &_parentClass, const QString &_softVersion, const QString &_DBName); //virtual ~DataBase(); ~DataBase(); @@ -164,9 +163,8 @@ class DataBase : public QObject bool recreateTableLog(); bool createTableLog(bool temp = false); // false creates the production DB. True a temporal one. bool createTableLogs(const bool real=true); // real = true creates the production DB. False a temporal one. - bool recreateTableEntity(); bool createTableEntity(const bool NoTmp); - bool updateTableEntity(); + bool recreateTableEntity(); bool createTableClubLogStatus(); bool populateTableClubLogStatus(); diff --git a/src/dataproxy_sqlite.cpp b/src/dataproxy_sqlite.cpp index f6d79fe0..d58e76fd 100644 --- a/src/dataproxy_sqlite.cpp +++ b/src/dataproxy_sqlite.cpp @@ -31,38 +31,36 @@ DataProxy_SQLite::DataProxy_SQLite(const QString &_parentFunction, const QString &_softVersion) { #ifdef QT_DEBUG - //qDebug() << Q_FUNC_INFO << _softVersion << _parentFunction; + qDebug() << Q_FUNC_INFO << _softVersion << _parentFunction; #else - //qDebug() << Q_FUNC_INFO << "Running a release build"; + qDebug() << Q_FUNC_INFO << "Running a release build"; #endif (void)_parentFunction; - //qDebug() << Q_FUNC_INFO << ": " << _softVersion << _parentFunction; + qDebug() << Q_FUNC_INFO << ": " << _softVersion << _parentFunction; logLevel = None; - //qDebug() << Q_FUNC_INFO << " - 45"; + qDebug() << Q_FUNC_INFO << " - 45"; util = new Utilities(Q_FUNC_INFO); - //qDebug() << Q_FUNC_INFO << " - 46"; + qDebug() << Q_FUNC_INFO << " - 46"; util->setVersion(_softVersion); - //qDebug() << Q_FUNC_INFO << " - 47"; + qDebug() << Q_FUNC_INFO << " - 47"; util->setCallValidation(false); - //qDebug() << Q_FUNC_INFO << " - 48"; + qDebug() << Q_FUNC_INFO << " - 48: " << util->getKLogDBFile(); db = new DataBase(Q_FUNC_INFO, _softVersion, util->getKLogDBFile()); - //qDebug() << Q_FUNC_INFO << " - 49"; + qDebug() << Q_FUNC_INFO << " - 49"; dbCreated = db->createConnection(Q_FUNC_INFO); - //qDebug() << Q_FUNC_INFO << " - 50"; + qDebug() << Q_FUNC_INFO << " - 50"; util->setLongPrefixes(getLongPrefixes()); - //qDebug() << Q_FUNC_INFO << " - 51"; + qDebug() << Q_FUNC_INFO << " - 51"; util->setSpecialCalls(getSpecialCallsigns()); - //qDebug() << Q_FUNC_INFO << " - 52"; + qDebug() << Q_FUNC_INFO << " - 52"; qso = new QSO; - //qDebug() << Q_FUNC_INFO << " - 53"; - - //qDebug() << Q_FUNC_INFO << " - 54"; + qDebug() << Q_FUNC_INFO << " - 53"; searching = false; executionN = 0; connect(db, SIGNAL(debugLog(QString, QString, DebugLogLevel)), this, SLOT(slotCaptureDebugLogs(QString, QString, DebugLogLevel)) ); - //qDebug() << Q_FUNC_INFO << " - END"; + qDebug() << Q_FUNC_INFO << " - END"; logEvent (Q_FUNC_INFO, "END", Debug); } @@ -2170,7 +2168,7 @@ QStringList DataProxy_SQLite::getFilteredLocators(const QString &_band, const QS bool DataProxy_SQLite::updateAwardDXCC() { - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; fillEmptyDXCCInTheLog(); return db->updateAwardDXCCTable(); //qDebug() << Q_FUNC_INFO << " - END"; @@ -6218,7 +6216,7 @@ int DataProxy_SQLite::getQSOsWithContinent(const QString &_cont, const int _logN bool sqlOK; if (_logNumber < 0) { - queryString = QString("SELECT COUNT (DISTINCT id) FROM log where cont = '%1'").arg(_cont); + queryString = QString("SELECT COUNT (DISTINCT id) FROM log where continent = '%1'").arg(_cont); } else { @@ -6546,34 +6544,39 @@ bool DataProxy_SQLite::addNewLog (const QStringList _qs) bool DataProxy_SQLite::doesThisLogExist(const int _log) { - qDebug() << "DataProxy_SQLite::doesThisLogExist: " << QString::number(_log); - qDebug() << "DataProxy_SQLite::doesThisLogExist - Name:" << db->getDBName(); + //qDebug() << "DataProxy_SQLite::doesThisLogExist: " << QString::number(_log); + //qDebug() << "DataProxy_SQLite::doesThisLogExist - Name:" << db->getDBName(); QSqlQuery query; + //SELECT COUNT (*) FROM log WHERE lognumber='3' + //SELECT COUNT (*) FROM logs WHERE id='1' - QString queryString = QString("SELECT id FROM logs WHERE id='%1'").arg(_log); + QString queryString = QString("SELECT COUNT (*) FROM logs WHERE id='%1'").arg(_log); bool sqlOK = query.exec(queryString); - qDebug() << Q_FUNC_INFO << " query: " << query.lastQuery() ; + //qDebug() << Q_FUNC_INFO << " query: " << query.lastQuery() ; if (!sqlOK) { - qDebug() << Q_FUNC_INFO << " - END False 1"; + //qDebug() << Q_FUNC_INFO << " - END False 1"; return false; } if (!query.next()) { - qDebug() << Q_FUNC_INFO << " - END False 2"; + //qDebug() << Q_FUNC_INFO << " - END False 2"; return false; } if (!query.isValid()) { - qDebug() << Q_FUNC_INFO << " - END False 3"; + //qDebug() << Q_FUNC_INFO << " - END False 3"; return false; } - int i = query.value(0).toInt(); - qDebug() << Q_FUNC_INFO << " - Value: " << QString::number(i); - qDebug() << Q_FUNC_INFO << " - END TRUE"; + return (query.value(0).toInt() >0); + + /* + //int i = query.value(0).toInt(); + //qDebug() << Q_FUNC_INFO << " - Value: " << QString::number(i); + //qDebug() << Q_FUNC_INFO << " - END TRUE"; return true; if (sqlOK) @@ -6583,20 +6586,20 @@ bool DataProxy_SQLite::doesThisLogExist(const int _log) if (query.isValid()) { query.finish(); - qDebug() << "DataProxy_SQLite::doesThisLogExist: END TRUE" ; + //qDebug() << "DataProxy_SQLite::doesThisLogExist: END TRUE" ; return true; } else { query.finish(); - qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 1" ; + //qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 1" ; return false; } } else { query.finish(); - qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 2" ; + //qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 2" ; return false; } } @@ -6604,11 +6607,12 @@ bool DataProxy_SQLite::doesThisLogExist(const int _log) { emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery()); query.finish(); - qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 3" ; + //qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 3" ; return false; } - qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 4" ; + //qDebug() << "DataProxy_SQLite::doesThisLogExist: END FALSE 4" ; return false; + */ } int DataProxy_SQLite::getContinentIdFromContinentShortName(const QString &_n) @@ -6649,8 +6653,8 @@ QString DataProxy_SQLite::getContinentShortNameFromEntity(const int _n) // SELECT DISTINCT dxcc, bandid, modeid, id, lognumber from log WHERE qsl_rcvd='Y' OR lotw_qsl_rcvd='Y' GROUP BY dxcc, bandid, modeid QSqlQuery query; - QString queryString= QString("SELECT cont FROM entity WHERE dxcc='%1'").arg(_n); - //QString queryString= QString("SELECT continent.shortname FROM entity JOIN continent ON entity.cont=continent.shortname WHERE dxcc='%1'").arg(_n); + QString queryString= QString("SELECT continent FROM entity WHERE dxcc='%1'").arg(_n); + //QString queryString= QString("SELECT continent.shortname FROM entity JOIN continent ON entity.continent=continent.shortname WHERE dxcc='%1'").arg(_n); bool sqlOK = query.exec(queryString); if (sqlOK) diff --git a/src/dxccstatuswidget.cpp b/src/dxccstatuswidget.cpp index 71b6459e..49a85f20 100644 --- a/src/dxccstatuswidget.cpp +++ b/src/dxccstatuswidget.cpp @@ -127,7 +127,6 @@ void DXCCStatusWidget::update() { emit debugLog (Q_FUNC_INFO, "Start", Debug); //qDebug() << Q_FUNC_INFO << ": " << QTime::currentTime().toString("HH:mm:ss"); - //int entities = world->getHowManyEntities(); int entities = dataProxy->getMaxEntityID(false); if (!awards->updateDXCCBandsStatus (-1)) // We update all { diff --git a/src/dxcluster/dxcluster.cpp b/src/dxcluster/dxcluster.cpp index c7d3db8c..afbaa717 100644 --- a/src/dxcluster/dxcluster.cpp +++ b/src/dxcluster/dxcluster.cpp @@ -222,7 +222,6 @@ void DXClusterWidget::connectToDXCluster() dxClusterListWidget->addItem (new dxClusterSpotItem(dxClusterListWidget, tr("Trying to connect to the server") + "\n", awards->getDefaultColor())); } - void DXClusterWidget::slotClusterDisplayError(QAbstractSocket::SocketError socketError) { //qDebug() << Q_FUNC_INFO; @@ -354,6 +353,8 @@ void DXClusterWidget::slotClusterDataArrived() if (spot.valid) { qDebug() << Q_FUNC_INFO << " - Spot IS valid"; + qDebug() << Q_FUNC_INFO << " - Spot Freq: " << spot.freq.toQString(); + _entityStatus.entityId = world->getQRZARRLId(spot.dxcall); spotBand = QString::number(dataProxy->getBandIdFromFreq(spot.freq.toDouble()) ); @@ -585,14 +586,14 @@ bool DXClusterWidget::isConnected() DXSpot DXClusterWidget::readItem(const QString _stringSpot) { - //qDebug() << Q_FUNC_INFO; + qDebug() << Q_FUNC_INFO; DXSpot spot = DXSpot(); spot.valid = false; if (_stringSpot.length()<5) return spot; - Frequency _fr; + //Frequency _fr; //dxClusterString = ((item->data(0)).toString()).simplified(); @@ -614,6 +615,7 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot) spot.freq.fromQString((fields.at(3)), KHz); spot.dxcall = fields.at(4); spot.valid = true; + qDebug() << Q_FUNC_INFO << ": Identified: Freq1: " << spot.freq.toQString(); } else if (fields.last().endsWith(">")) { // 14250.0 EA0XXX 12-Apr-2020 2140Z Comment @@ -622,6 +624,8 @@ DXSpot DXClusterWidget::readItem(const QString _stringSpot) spot.freq.fromQString((fields.at(0)), KHz); spot.dxcall = fields.at(1); spot.valid = true; + + qDebug() << Q_FUNC_INFO << ": Identified: Freq2: " << spot.freq.toQString(); } else if ((fields.at(0) == "To" ) && (fields.at(1) == "ALL" )) { // To ALL Comment diff --git a/src/dxcluster/dxspot.cpp b/src/dxcluster/dxspot.cpp new file mode 100644 index 00000000..d9644866 --- /dev/null +++ b/src/dxcluster/dxspot.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + dxspot.cpp - description + ------------------- + begin : apr 2024 + copyright : (C) 2024 by Jaime Robles + email : jaime@robles.es + ***************************************************************************/ + +/***************************************************************************** + * This file is part of KLog. * + * * + * KLog is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * KLog is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with KLog. If not, see . * + * * + *****************************************************************************/ +#include "dxspot.h" + +DXSpot::DXSpot() +{ + valid = false; +} + +DXSpot::DXSpot(DXSpot *_other) +{ + dxcall = _other->dxcall; + spotter = _other->spotter; + freq = _other->freq; // Might need a copy constructor for Frequency as well + comment = _other->comment; + dateTime = _other->dateTime; + clickStatus = _other->clickStatus; + valid = _other->valid; +} + +DXSpot::~DXSpot(){} + +void DXSpot::clear() +{ + dxcall.clear(); + freq.clear(); + spotter.clear(); + dateTime.currentDateTimeUtc(); + valid = false; + clickStatus = NoClick; +} + +void DXSpot::operator=(DXSpot const &_other) +{ + dxcall = _other.dxcall; + freq = _other.freq; // Might need a copy constructor for Frequency as well + spotter = _other.spotter; + comment = _other.comment; + dateTime = _other.dateTime; + clickStatus = _other.clickStatus; + valid = _other.valid; +} + +void DXSpot::setValid(const bool _v){valid = _v;} +bool DXSpot::isValid(){return valid;} + +void DXSpot::setDXCall(const QString &_c){dxcall = _c;} +QString DXSpot::getDxCall(){return dxcall;} + +void DXSpot::setSpotter(const QString &_c){spotter = _c;} +QString DXSpot::getSpotter(){return spotter;} + +void DXSpot::setComment(const QString &c){comment = c;} +QString DXSpot::getComment(){return comment;} + +void DXSpot::setDateTime(const QDateTime &d){if (d.isValid()) dateTime = d;} +QDateTime DXSpot::getDateTime(){ return dateTime;} + +void DXSpot::setClickStatus(const MouseClicks &_s ){clickStatus = _s;} +bool DXSpot::getClickStatus(){return clickStatus;} + +void DXSpot::setFrequency(Frequency f) +{ + if (f.isValid()) + freq = f; +} +Frequency DXSpot::getFrequency() +{ + return &freq; +} diff --git a/src/dxcluster/dxspot.h b/src/dxcluster/dxspot.h new file mode 100644 index 00000000..b58a0570 --- /dev/null +++ b/src/dxcluster/dxspot.h @@ -0,0 +1,80 @@ +#ifndef DXSPOT_H +#define DXSPOT_H +/*************************************************************************** + dxspot.h - description + ------------------- + begin : Apr 2024 + copyright : (C) 2024 by Jaime Robles + email : jaime@robles.es + ***************************************************************************/ + +/***************************************************************************** + * This file is part of KLog. * + * * + * KLog is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * KLog is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with KLog. If not, see . * + * * + *****************************************************************************/ +/* + This class implements DXSpot. +*/ +#include +#include +#include "../klogdefinitions.h" +#include "../frequency.h" + +class DXSpot : public QObject +{ + Q_OBJECT + friend class tst_DXSpot; + +public: + DXSpot(); + DXSpot(DXSpot *_other); + ~DXSpot(); + void operator=(DXSpot const &_other); + void clear(); + + void setValid(const bool _v); + bool isValid(); + + void setDXCall(const QString &c); + QString getDxCall(); + void setSpotter(const QString &c); + QString getSpotter(); + + void setComment(const QString &c); + QString getComment(); + + void setDateTime(const QDateTime &d); + QDateTime getDateTime(); + + void setClickStatus(const MouseClicks &_s ); + bool getClickStatus(); + + void setFrequency(Frequency f); + Frequency getFrequency(); + +signals: + +private: + QString dxcall; + Frequency freq; + QString spotter; + QString comment; + QDateTime dateTime; + MouseClicks clickStatus; + bool valid; +}; + +#endif // DXSPOT_H diff --git a/src/frequency.cpp b/src/frequency.cpp index b7776fe2..7e4fb5d7 100644 --- a/src/frequency.cpp +++ b/src/frequency.cpp @@ -36,17 +36,7 @@ Frequency::Frequency(const double _f, FreqUnits _u) { freq = normalize(_f, _u); } -//Frequency::Frequency(const QString &_parentName){} -/* - Frequency::Frequency(const QString &_parentName, const Frequency &_f) -{ - if(this != &_f) - { - *this = _f; - } -} -*/ Frequency::~Frequency(){} void Frequency::clear() diff --git a/src/main.cpp b/src/main.cpp index 30ba23ad..e42a201b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) wizard->exec(); } else - { + { //qDebug() << Q_FUNC_INFO << " - Start of DB Activities" << (QTime::currentTime()).toString("HH:mm:ss"); DataBase *db = new DataBase(Q_FUNC_INFO, version, util.getKLogDBFile()); //qDebug() << Q_FUNC_INFO << " - After Start of DB Activities"; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8acb8c68..7a9dd0ad 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -334,7 +334,7 @@ void MainWindow::checkHomeDir() void MainWindow::init() { - qDebug() << Q_FUNC_INFO << " - Start - " << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - Start - " << (QTime::currentTime()).toString("HH:mm:ss") ; logLevel = Debug; logEvent(Q_FUNC_INFO, "Start", Debug); checkHomeDir(); @@ -342,13 +342,13 @@ void MainWindow::init() checkDebugFile(); - qDebug() << Q_FUNC_INFO << " - 00" ; + //qDebug() << Q_FUNC_INFO << " - 00" ; util->setLongPrefixes(dataProxy->getLongPrefixes()); util->setSpecialCalls(dataProxy->getSpecialCallsigns()); - qDebug() << Q_FUNC_INFO << " - 000" ; + //qDebug() << Q_FUNC_INFO << " - 000" ; setupDialog->init(softwareVersion, 0, configured); - qDebug() << Q_FUNC_INFO << " - 01" ; + //qDebug() << Q_FUNC_INFO << " - 01" ; filemanager->init(); @@ -367,7 +367,7 @@ void MainWindow::init() //Default band/modes bands << "10M" << "15M" << "20M" << "40M" << "80M" << "160M"; modes << "SSB" << "CW"; - qDebug() << Q_FUNC_INFO << " - 00" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 00" << (QTime::currentTime()).toString("HH:mm:ss") ; hamlibActive = false; hamlibModeNotADIFSupported = false; @@ -379,7 +379,7 @@ void MainWindow::init() setCleaning(false); - qDebug() << Q_FUNC_INFO << " - 10" ; + //qDebug() << Q_FUNC_INFO << " - 10" ; dxClusterWidget->init(); @@ -404,7 +404,7 @@ void MainWindow::init() selectedYear = 0; defaultMode = 1; defaultBand = 1; - qDebug() << Q_FUNC_INFO << " - 20" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 20" << (QTime::currentTime()).toString("HH:mm:ss") ; currentMode = 1; currentModeShown = currentMode; @@ -419,7 +419,7 @@ void MainWindow::init() UDPServerStart = false; // By default the UDP server is started - qDebug() << Q_FUNC_INFO << " - 30" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 30" << (QTime::currentTime()).toString("HH:mm:ss") ; currentEntity = -1; // To optimize the calls to different world methods if the entity does not change. Used in slotQRZTextChanged previousEntity = -1;// To optimize the calls to different world methods if the entity does not change. @@ -450,7 +450,7 @@ void MainWindow::init() dxclusterSendSpotsToMap = false; keepSatPage = false; - qDebug() << Q_FUNC_INFO << " - 40" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 40" << (QTime::currentTime()).toString("HH:mm:ss") ; clublogActive = false; clublogRealTime = false; @@ -461,7 +461,7 @@ void MainWindow::init() callingUpdate = false; // to control whether the update is mannually launched or at the begining setModifying(false); - qDebug() << Q_FUNC_INFO << " - 50" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 50" << (QTime::currentTime()).toString("HH:mm:ss") ; selectedYear = (dateTime->currentDateTime()).date().year(); loggWinAct->setShortcut(Qt::CTRL | Qt::Key_L); @@ -486,22 +486,22 @@ void MainWindow::init() checkExistingData(); readSettingsFile(); - qDebug() << Q_FUNC_INFO << " - 70" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 70" << (QTime::currentTime()).toString("HH:mm:ss") ; mapWindow->init(); - qDebug() << Q_FUNC_INFO << " - 71" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 71" << (QTime::currentTime()).toString("HH:mm:ss") ; logWindow->createlogPanel(currentLog); - qDebug() << Q_FUNC_INFO << " - 72" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 72" << (QTime::currentTime()).toString("HH:mm:ss") ; awards->setManageModes(manageMode); - qDebug() << Q_FUNC_INFO << " - 73" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 73" << (QTime::currentTime()).toString("HH:mm:ss") ; if (dataProxy->getNumberOfManagedLogs()<1) { - qDebug() << Q_FUNC_INFO << " - 73.1" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 73.1" << (QTime::currentTime()).toString("HH:mm:ss") ; openSetup(6); - qDebug() << Q_FUNC_INFO << " - 73.2" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 73.2" << (QTime::currentTime()).toString("HH:mm:ss") ; } - qDebug() << Q_FUNC_INFO << " - 74" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 74" << (QTime::currentTime()).toString("HH:mm:ss") ; awardsWidget->fillOperatingYears(); awardsWidget->showAwards(); @@ -510,37 +510,37 @@ void MainWindow::init() dxClusterWidget->setCurrentLog(currentLog); dxClusterAssistant->init(); - qDebug() << Q_FUNC_INFO << " - 80" << (QTime::currentTime()).toString("HH:mm:ss") ; - qDebug() << Q_FUNC_INFO << ": calling Software update ..." << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 80" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << ": calling Software update ..." << (QTime::currentTime()).toString("HH:mm:ss") ; checkVersions(); - qDebug() << Q_FUNC_INFO << " - 90" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 90" << (QTime::currentTime()).toString("HH:mm:ss") ; currentBandShown = dataProxy->getIdFromBandName(mainQSOEntryWidget->getBand()); - qDebug() << Q_FUNC_INFO << " - 91" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 91" << (QTime::currentTime()).toString("HH:mm:ss") ; currentModeShown = dataProxy->getIdFromModeName(mainQSOEntryWidget->getMode()); - qDebug() << Q_FUNC_INFO << " - 92" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 92" << (QTime::currentTime()).toString("HH:mm:ss") ; currentBand = currentBandShown; currentMode = currentModeShown; timerInfoBars = new QTimer(this); - qDebug() << Q_FUNC_INFO << " - Calling createUI" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - Calling createUI" << (QTime::currentTime()).toString("HH:mm:ss") ; createUI(); - qDebug() << Q_FUNC_INFO << " - Calling slotClearButtonClicked" << (QTime::currentTime()).toString("HH:mm:ss") ; - qDebug() << Q_FUNC_INFO << " - 100"; + //qDebug() << Q_FUNC_INFO << " - Calling slotClearButtonClicked" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - 100"; slotClearButtonClicked(Q_FUNC_INFO); - qDebug() << Q_FUNC_INFO << " - 110"; + //qDebug() << Q_FUNC_INFO << " - 110"; infoWidget->showInfo(-1); - qDebug() << Q_FUNC_INFO << " - 120"; + //qDebug() << Q_FUNC_INFO << " - 120"; //lotwTQSLpath = util->getTQSLsPath() + util->getTQSLsFileName(); world->readWorld (); upAndRunning = true; mainQSOEntryWidget->setUpAndRunning(upAndRunning); - qDebug() << Q_FUNC_INFO << " - 130"; + //qDebug() << Q_FUNC_INFO << " - 130"; applySettings (); - qDebug() << Q_FUNC_INFO << " - END" << (QTime::currentTime()).toString("HH:mm:ss") ; + //qDebug() << Q_FUNC_INFO << " - END" << (QTime::currentTime()).toString("HH:mm:ss") ; logEvent(Q_FUNC_INFO, "END", Debug); } @@ -5334,7 +5334,7 @@ void MainWindow::slotAnalyzeDxClusterSignal(DXSpot _spot) void MainWindow::slotDXClusterSpotArrived(const QString _dxCall, const double _freq) { - qDebug() << Q_FUNC_INFO << ": " << _dxCall; + //qDebug() << Q_FUNC_INFO << ": " << _dxCall; //qDebug() << Q_FUNC_INFO << ": " << _freq.toQString(); //(void)_dxCall; //(void)_freq; @@ -5347,14 +5347,13 @@ void MainWindow::slotDXClusterSpotArrived(const QString _dxCall, const double _f pQSO.status = ATNO; //pQSO.freq = _freq; dxClusterAssistant->newDXClusterSpot(pQSO); - qDebug() << Q_FUNC_INFO << ": Calling assistant with DXCall Valid: " << _dxCall; + //qDebug() << Q_FUNC_INFO << ": Calling assistant with DXCall Valid: " << _dxCall; //qDebug() << Q_FUNC_INFO << ": Calling assistant with Freq: " << _freq.toQString(); //dxClusterAssistant->newDXClusterSpot(_dxCall, ATNO, _freq.toDouble()); - } else { - qDebug() << Q_FUNC_INFO << ": DXCall not valid: " << _dxCall; + //qDebug() << Q_FUNC_INFO << ": DXCall not valid: " << _dxCall; } @@ -6484,7 +6483,7 @@ void MainWindow::slotNewLogLevel(DebugLogLevel l) bool MainWindow::loadSettings() { logEvent(Q_FUNC_INFO, "Start", Debug); - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; QSettings settings(util->getCfgFile (), QSettings::IniFormat); //qDebug() << Q_FUNC_INFO << " - 10 - General"; @@ -6548,14 +6547,14 @@ bool MainWindow::loadSettings() dxClusterWidget->loadSettings (); settings.endGroup (); - qDebug() << Q_FUNC_INFO << " - 60 - colors"; + //qDebug() << Q_FUNC_INFO << " - 60 - colors"; settings.beginGroup ("Colors"); #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) - qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor: " << settings.value("NewOneColor").toString(); + //qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor: " << settings.value("NewOneColor").toString(); newOneColor.fromString(QAnyStringView((settings.value ("NewOneColor", "#FF0000").toString ()))); //newOneColor.setNamedColor(settings.value ("NewOneColor", "#FF0000").toString ()); - qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor-2: " << newOneColor.name(QColor::HexRgb); + //qDebug() << Q_FUNC_INFO << " - 61 - NewOneColor-2: " << newOneColor.name(QColor::HexRgb); neededColor.fromString(QAnyStringView((settings.value ("NeededColor","#FF8C00").toString ()))); workedColor.fromString(QAnyStringView((settings.value ("WorkedColor", "#FFD700").toString ()))); confirmedColor.fromString(QAnyStringView((settings.value ("ConfirmedColor", "#32CD32").toString ()))); diff --git a/src/setupdialog.cpp b/src/setupdialog.cpp index 256c372d..35a5eca8 100644 --- a/src/setupdialog.cpp +++ b/src/setupdialog.cpp @@ -188,28 +188,28 @@ void SetupDialog::connectActions() void SetupDialog::setData(const QString &_softwareVersion, const int _page, const bool _alreadyConfigured) { - qDebug() << Q_FUNC_INFO << " - " << _softwareVersion << "/" << QString::number(_page); + //qDebug() << Q_FUNC_INFO << " - " << _softwareVersion << "/" << QString::number(_page); logEvent(Q_FUNC_INFO, "Start", Debug); nolog = !(haveAtleastOneLog()); firstTime = !_alreadyConfigured; if (firstTime) { - qDebug() << Q_FUNC_INFO << " - Running for the FIRST time"; + //qDebug() << Q_FUNC_INFO << " - Running for the FIRST time"; } else { - qDebug() << Q_FUNC_INFO << " - Running NOT for the FIRST time"; + //qDebug() << Q_FUNC_INFO << " - Running NOT for the FIRST time"; miscPage->setUseDefaultDBPath(miscPage->getDefaultDBPath()); } - qDebug() << Q_FUNC_INFO << " - 10"; + //qDebug() << Q_FUNC_INFO << " - 10"; setSoftVersion(_softwareVersion); - qDebug() << Q_FUNC_INFO << " - 20"; + //qDebug() << Q_FUNC_INFO << " - 20"; slotReadConfigData (); - qDebug() << Q_FUNC_INFO << " - 30"; + //qDebug() << Q_FUNC_INFO << " - 30"; setPage(_page); - qDebug() << Q_FUNC_INFO << " - 40"; + //qDebug() << Q_FUNC_INFO << " - 40"; logEvent(Q_FUNC_INFO, "END", Debug); - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; } void SetupDialog::setSoftVersion(const QString &_softwareVersion) @@ -338,22 +338,22 @@ void SetupDialog::loadDarkMode() bool SetupDialog::loadSettings() { - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; if (!QFile::exists(util->getCfgFile ())) { - qDebug() << Q_FUNC_INFO << " - Nothing to load"; + //qDebug() << Q_FUNC_INFO << " - Nothing to load"; return false; } QSettings settings(util->getCfgFile (), QSettings::IniFormat); - qDebug() << Q_FUNC_INFO << " - 10 - General"; + //qDebug() << Q_FUNC_INFO << " - 10 - General"; version = settings.value ("Version").toString(); //latestBackup = settings.value ("LatestBackup").toString (); - qDebug() << Q_FUNC_INFO << " - 20 - user"; + //qDebug() << Q_FUNC_INFO << " - 20 - user"; userDataPage->loadSettings(); - qDebug() << Q_FUNC_INFO << " - 30 - bands"; + //qDebug() << Q_FUNC_INFO << " - 30 - bands"; settings.beginGroup ("BandMode"); QStringList listAux; @@ -372,23 +372,23 @@ bool SetupDialog::loadSettings() bandModePage->setActiveBands (bands); settings.endGroup (); - qDebug() << Q_FUNC_INFO << " - 40 - logview"; + //qDebug() << Q_FUNC_INFO << " - 40 - logview"; logViewPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 50 - dxcluster"; + //qDebug() << Q_FUNC_INFO << " - 50 - dxcluster"; dxClusterPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 60 - colors"; + //qDebug() << Q_FUNC_INFO << " - 60 - colors"; colorsPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 70 - misc"; + //qDebug() << Q_FUNC_INFO << " - 70 - misc"; miscPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 80 - logs"; + //qDebug() << Q_FUNC_INFO << " - 80 - logs"; logsPage->loadSettings(); - qDebug() << Q_FUNC_INFO << " - 90 - elog"; + //qDebug() << Q_FUNC_INFO << " - 90 - elog"; eLogPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 100 - UDP"; + //qDebug() << Q_FUNC_INFO << " - 100 - UDP"; UDPPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 110 - Sats"; + //qDebug() << Q_FUNC_INFO << " - 110 - Sats"; hamlibPage->loadSettings (); - qDebug() << Q_FUNC_INFO << " - 120 - END"; + //qDebug() << Q_FUNC_INFO << " - 120 - END"; return true; } @@ -465,12 +465,12 @@ void SetupDialog::slotOkButtonClicked() void SetupDialog::slotReadConfigData() { - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; logEvent(Q_FUNC_INFO, "Start", Debug); if (firstTime) //if (!QFile::exists (util->getCfgFile ())) { - qDebug() << Q_FUNC_INFO << " - FirstTime"; + //qDebug() << Q_FUNC_INFO << " - FirstTime"; setDefaults(); bands.removeDuplicates(); modes.removeDuplicates(); @@ -479,9 +479,9 @@ void SetupDialog::slotReadConfigData() bandModePage->setActiveBands(bands); //logViewPage->setActiveFields(logViewFields); } - qDebug() << Q_FUNC_INFO << " - 30"; + //qDebug() << Q_FUNC_INFO << " - 30"; loadSettings(); - qDebug() << Q_FUNC_INFO << " - 40"; + //qDebug() << Q_FUNC_INFO << " - 40"; //dxClusterPage->setDxclusterServersComboBox(dxClusterServers); //dxClusterPage->setSelectedDxClusterServer(dxClusterServerToUse); @@ -500,7 +500,7 @@ void SetupDialog::slotReadConfigData() bandModePage->setActiveBands(bands); //logViewPage->setActiveFields(logViewFields); - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; logEvent(Q_FUNC_INFO, "END", Debug); } @@ -592,7 +592,7 @@ bool SetupDialog::isValidMode (const QString &b) void SetupDialog::setDefaults() { - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; logEvent(Q_FUNC_INFO, "Start", Debug); miscPage->setRealTime("TRUE"); miscPage->setUTCTime("TRUE"); @@ -636,7 +636,7 @@ void SetupDialog::setDefaults() bands << "10M" << "12M" << "15M" << "17M" << "20M" << "40M" << "80M" << "160M"; bands.removeDuplicates(); } - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; logEvent(Q_FUNC_INFO, "END", Debug); } diff --git a/src/setuppages/setuppagelogs.cpp b/src/setuppages/setuppagelogs.cpp index 7d13ae0d..112bacc3 100644 --- a/src/setuppages/setuppagelogs.cpp +++ b/src/setuppages/setuppagelogs.cpp @@ -429,7 +429,7 @@ void SetupPageLogs::showEvent(QShowEvent *event) void SetupPageLogs::saveSettings() { - qDebug() << Q_FUNC_INFO ; + //qDebug() << Q_FUNC_INFO ; Utilities util(Q_FUNC_INFO); QSettings settings(util.getCfgFile (), QSettings::IniFormat); //settings.beginGroup ("Logs"); @@ -439,31 +439,31 @@ void SetupPageLogs::saveSettings() void SetupPageLogs::loadSettings() { - qDebug() << Q_FUNC_INFO << " - Start"; + //qDebug() << Q_FUNC_INFO << " - Start"; Utilities util(Q_FUNC_INFO); - qDebug() << Q_FUNC_INFO << " - 00"; + //qDebug() << Q_FUNC_INFO << " - 00"; QSettings settings(util.getCfgFile (), QSettings::IniFormat); - qDebug() << Q_FUNC_INFO << " - 01"; + //qDebug() << Q_FUNC_INFO << " - 01"; int i = settings.value("SelectedLog").toInt(); - qDebug() << Q_FUNC_INFO << " - 02"; + //qDebug() << Q_FUNC_INFO << " - 02"; if (!dataProxy->doesThisLogExist(i)) { - qDebug() << Q_FUNC_INFO << " - 10"; + //qDebug() << Q_FUNC_INFO << " - 10"; i = 0; while((!dataProxy->doesThisLogExist(i)) && (i <500)) {//TODO If a user has more than 500 logs it may fail... i++; //qDebug() << Q_FUNC_INFO << " - Log: " << QString::number(i); } - qDebug() << Q_FUNC_INFO << " - 49"; + //qDebug() << Q_FUNC_INFO << " - 49"; } - qDebug() << Q_FUNC_INFO << " - 50"; + //qDebug() << Q_FUNC_INFO << " - 50"; selectedLog = i; - qDebug() << Q_FUNC_INFO << " - 51"; + //qDebug() << Q_FUNC_INFO << " - 51"; logsView->selectRow(1); - qDebug() << Q_FUNC_INFO << " - 52"; + //qDebug() << Q_FUNC_INFO << " - 52"; QModelIndex index = logsModel->index(selectedLog, 0); - qDebug() << Q_FUNC_INFO << " - 53"; + //qDebug() << Q_FUNC_INFO << " - 53"; logsView->setCurrentIndex(index); - qDebug() << Q_FUNC_INFO << " - END"; + //qDebug() << Q_FUNC_INFO << " - END"; } diff --git a/src/setuppages/setuppageworldeditor.cpp b/src/setuppages/setuppageworldeditor.cpp index 6bf167cb..8ebb974b 100644 --- a/src/setuppages/setuppageworldeditor.cpp +++ b/src/setuppages/setuppageworldeditor.cpp @@ -153,7 +153,7 @@ void SetupPageWorldEditor::createWorldPanel() worldView->setColumnHidden(columns, false); columns = rec.indexOf("dxcc"); worldView->setColumnHidden(columns, false); - columns = rec.indexOf("cont"); + columns = rec.indexOf("continent"); worldView->setColumnHidden(columns, false); columns = rec.indexOf("cqz"); worldView->setColumnHidden(columns, false); @@ -210,7 +210,7 @@ void SetupPageWorldEditor::createWorldModel() worldModel->setHeaderData(nameCol, Qt::Horizontal, tr("Entity")); nameCol = rec.indexOf("dxcc"); worldModel->setHeaderData(nameCol, Qt::Horizontal, tr("ARRL ID")); - nameCol = rec.indexOf("cont"); + nameCol = rec.indexOf("continent"); worldModel->setHeaderData(nameCol, Qt::Horizontal, tr("Continent")); nameCol = rec.indexOf("cqz"); worldModel->setHeaderData(nameCol, Qt::Horizontal, tr("CQ Zone")); diff --git a/src/src.pro b/src/src.pro index 6639c498..5b1a44cb 100644 --- a/src/src.pro +++ b/src/src.pro @@ -94,6 +94,7 @@ HEADERS += setupdialog.h \ database.h \ dataproxy_sqlite.h \ downloadcty.h \ \ + dxcluster/dxspot.h \ frequency.h \ dxccstatuswidget.h \ dxcluster/dxcluster.h \ @@ -173,6 +174,7 @@ SOURCES += main.cpp \ charts/statsfieldperbandwidget.cpp \ dxcluster/dxcluster.cpp \ dxcluster/dxclusterassistant.cpp \ + dxcluster/dxspot.cpp \ elogqrzlog.cpp \ eqslutilities.cpp \ frequency.cpp \ diff --git a/src/utilities.cpp b/src/utilities.cpp index fbe8d768..c49068ce 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -529,7 +529,33 @@ QString Utilities::getDBPath() QString Utilities::getKLogDBFile() { // Returns the full path to the main DB - return getDBPath() + "/logbook.dat"; + qDebug() << Q_FUNC_INFO << " - Start"; + QSettings settings(getCfgFile (), QSettings::IniFormat); + qDebug() << Q_FUNC_INFO << " - CFG: " << getCfgFile(); + QString dbFile; + QString filename = "/logbook.dat"; + + if (!QFile::exists(getCfgFile ())) + return getDBPath() + filename; + //qDebug() << Q_FUNC_INFO << " - Config file DOES NOT Exist"; + //CRITICAL ERROR TO BE MANAGED, KLOG SHOULD STOP + + settings.beginGroup ("Misc"); + + if (!settings.contains("DBPath")) + { + //qDebug() << Q_FUNC_INFO << " - DBPath DOES NOT Exist, returning default"; + return getDBPath() + filename; + } + + dbFile = settings.value("DBPath").toString () + filename; + qDebug() << Q_FUNC_INFO << "DBPath: " << dbFile; + + if (QFile::exists(dbFile)) + return dbFile; + + qDebug() << Q_FUNC_INFO << " - DBPath file DOES NOT Exist, returning default"; + return getDBPath() + filename; } QString Utilities::getKLogDBBackupFile() diff --git a/src/world.cpp b/src/world.cpp index 566f1d69..4dbfb30f 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -591,13 +591,13 @@ bool World::addEntity(const QString &_name, const int _cq, const int _itu, const { QSqlQuery query; - query.prepare("INSERT INTO entity (name, cqz, ituz, cont, latitude, longitude, utc, dxcc, mainprefix) " + query.prepare("INSERT INTO entity (name, cqz, ituz, continent, latitude, longitude, utc, dxcc, mainprefix) " "VALUES (:name, :cqz, :ituz, :cont, :lat, :lon, :utc, :dxcc, :mainpref)"); query.bindValue(":name", _name); // name query.bindValue(":cqz", _cq); // CQ query.bindValue(":ituz", _itu); // ITU - query.bindValue(":cont", _contId); // Cont + query.bindValue(":continent", _contId); // Cont query.bindValue(":lat", _lat); // Lat query.bindValue(":lon", _lon); // Lon query.bindValue(":utc", _utc); // UTC diff --git a/tests/tests.pro b/tests/tests.pro index 507ff9fc..22241abd 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -3,6 +3,7 @@ SUBDIRS=\ tst_main \ tst_wizard \ tst_adif \ + tst_dxspot \ tst_frequency \ tst_utilities \ tst_mainqsoentrywidget \ diff --git a/tests/tst_database/tst_database.cpp b/tests/tst_database/tst_database.cpp index b8df83d0..fa793004 100644 --- a/tests/tst_database/tst_database.cpp +++ b/tests/tst_database/tst_database.cpp @@ -309,16 +309,23 @@ void tst_DataBase::test_checks() void tst_DataBase::test_CreateDB() { + qDebug() << Q_FUNC_INFO << "000"; Utilities util(Q_FUNC_INFO); + qDebug() << Q_FUNC_INFO << "001"; QFile file(util.getCTYFile()); + qDebug() << Q_FUNC_INFO << "003"; QCOMPARE( file.exists(), true); // Check if the CTYDAT file is available - + qDebug() << Q_FUNC_INFO << "003"; DataProxy_SQLite dataProxy(Q_FUNC_INFO, version); - //qDebug() << Q_FUNC_INFO << "003"; + qDebug() << Q_FUNC_INFO << "004"; World world(&dataProxy, Q_FUNC_INFO); + qDebug() << Q_FUNC_INFO << "005"; QCOMPARE(world.create(util.getCTYFile()), true); // Read the CTY.CSV file into the DB + qDebug() << Q_FUNC_INFO << "006"; QCOMPARE(db->hasTheTableData("entity"), true); + qDebug() << Q_FUNC_INFO << "007"; QCOMPARE(db->hasTheTableData("prefixesofentity"), true); + qDebug() << Q_FUNC_INFO << "999"; } @@ -383,10 +390,15 @@ void tst_DataBase::cleanup() void tst_DataBase::test_Constructor() { + qDebug() << Q_FUNC_INFO << "- Start"; QString _version = QString ("99.9"); + qDebug() << Q_FUNC_INFO << "- 001"; util = new Utilities(Q_FUNC_INFO); + qDebug() << Q_FUNC_INFO << "- 002"; db = new DataBase(Q_FUNC_INFO, _version, util->getKLogDBFile()); + qDebug() << Q_FUNC_INFO << "- 003"; QCOMPARE(db->createConnection(Q_FUNC_INFO), true); + qDebug() << Q_FUNC_INFO << " - END"; } QTEST_APPLESS_MAIN(tst_DataBase) diff --git a/tests/tst_dxspot/tst_dxspot.cpp b/tests/tst_dxspot/tst_dxspot.cpp new file mode 100644 index 00000000..5c8586f9 --- /dev/null +++ b/tests/tst_dxspot/tst_dxspot.cpp @@ -0,0 +1,124 @@ +/*************************************************************************** + tst_dxspot.h - description + ------------------- + begin : Apr 2024 + copyright : (C) 2024 by Jaime Robles + email : jaime@robles.es + ***************************************************************************/ + +/**************************************************************************** + * This file is part of Testing suite of KLog. * + * * + * KLog is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * The testing suite of KLog is distributed in the hope that it will * + * be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with Testing suite of KLog. * + * If not, see . * + * * + *****************************************************************************/ + +#include +#include +#include "../../src/dxcluster/dxspot.h" +#include "../../src/klogdefinitions.h" +#include "QtCore/qobject.h" +#include "QtCore/qtmetamacros.h" +#include "QtTest/qtestcase.h" + + +class tst_DXSpot : public QObject +{ + Q_OBJECT + +public: + tst_DXSpot(); + ~tst_DXSpot(); + +private slots: + void initTestCase(); //will be called before the first test function is executed. + //void initTestCase_data(); // will be called to create a global test data table. + void cleanupTestCase(); //will be called after the last test function was executed. + void test_Constructors(); + void test_Basic(); + + +private: + DXSpot *spot; +}; + +tst_DXSpot::tst_DXSpot() +{ + spot = new DXSpot; +} + +tst_DXSpot::~tst_DXSpot() +{ + delete(spot); + +} + +void tst_DXSpot::initTestCase() +{ + spot->clear(); +} + +void tst_DXSpot::cleanupTestCase() +{ + //qDebug("Called after last test."); +} + +void tst_DXSpot::test_Constructors() +{ + DXSpot spot1; + QVERIFY2(!spot1.isValid(), "Constructor-1 not working"); + spot1.setValid(true); + DXSpot spot2(&spot1); + QVERIFY2(spot2.isValid(), "Constructor-2 not working"); +} + +void tst_DXSpot::test_Basic() +{ + spot->clear(); + QVERIFY2(!spot->isValid(), "Clear not working"); + spot->setValid(true); + QVERIFY2(spot->isValid(), "setValid not working"); + + spot->setDXCall("EA0XX"); + QVERIFY2(spot->getDxCall() == "EA0XX", "dxCall not working"); + + spot->setSpotter("EA0XX"); + QVERIFY2(spot->getSpotter() == "EA0XX", "spotter not working"); + + spot->setComment("Comment"); + QVERIFY2(spot->getComment() == "Comment", "comment not working"); + + QDateTime t = QDateTime::currentDateTime(); + spot->setDateTime(t); + QVERIFY2(spot->getDateTime() == t, "dateTime not working"); + + //enum MouseClicks {NoClick, RightClick, SingleClick, DoubleClick}; + spot->setClickStatus(NoClick); + QVERIFY2(spot->getClickStatus() == NoClick, "Click Status 0 not working"); + + spot->setClickStatus(RightClick); + QVERIFY2(spot->getClickStatus() == RightClick, "Click Status 1 not working"); + + spot->setClickStatus(SingleClick); + QVERIFY2(spot->getClickStatus() == SingleClick, "Click Status 2 not working"); + + spot->setClickStatus(DoubleClick); + QVERIFY2(spot->getClickStatus() == DoubleClick, "Click Status 3 not working"); +} + +QTEST_APPLESS_MAIN(tst_DXSpot) + +#include "tst_dxspot.moc" + diff --git a/tests/tst_dxspot/tst_dxspot.pro b/tests/tst_dxspot/tst_dxspot.pro new file mode 100644 index 00000000..3d0db22b --- /dev/null +++ b/tests/tst_dxspot/tst_dxspot.pro @@ -0,0 +1,31 @@ +QT += testlib + + +CONFIG += qt console warn_on depend_includepath testcase +CONFIG -= app_bundle + +TEMPLATE = app + +#QMAKE_CXXFLAGS += -Wall -Wextra -Werror +#QMAKE_CFLAGS += -Wall -Wextra -Werror + +HEADERS += \ + ../../src/frequency.h \ + ../../src/dxcluster/dxspot.h \ + ../../src/klogdefinitions.h + +SOURCES += tst_dxspot.cpp \ + ../../src/dxcluster/dxspot.cpp \ + ../../src/frequency.cpp + + + +isEmpty(QMAKE_LRELEASE) { + win32|os2:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe + else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease + unix { + !exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease-qt5 } + } else { + !exists($$QMAKE_LRELEASE) { QMAKE_LRELEASE = lrelease } + } +} diff --git a/tests/tst_frequency/tst_frequency.cpp b/tests/tst_frequency/tst_frequency.cpp index f801ae6f..0440edbc 100644 --- a/tests/tst_frequency/tst_frequency.cpp +++ b/tests/tst_frequency/tst_frequency.cpp @@ -1,8 +1,8 @@ /*************************************************************************** - tst_Frequency.h - description + tst_frequency.h - description ------------------- - begin : Jan 2021 - copyright : (C) 2021 by Jaime Robles + begin : Apr 2024 + copyright : (C) 2024 by Jaime Robles email : jaime@robles.es ***************************************************************************/ diff --git a/tests/tst_frequency/tst_frequency.pro b/tests/tst_frequency/tst_frequency.pro index d12cfbed..f526d06d 100644 --- a/tests/tst_frequency/tst_frequency.pro +++ b/tests/tst_frequency/tst_frequency.pro @@ -14,7 +14,7 @@ HEADERS += \ ../../src/klogdefinitions.h SOURCES += tst_frequency.cpp \ - ../../src/frequency.cpp \ + ../../src/frequency.cpp