Fixed the entity addition after modification

Lot of work still pending, this is not working
This commit is contained in:
d 2024-06-20 20:15:20 +02:00
parent 572b4fcb19
commit 17ea6502a7
24 changed files with 811 additions and 582 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,8 @@
#include <QDateTime>
#include <QInputDialog>
#include <QProgressDialog>
//#include "database/queryexecutor.h"
#include "database/db_adif_primary_subdvisions_data.h"
#include "utilities.h"
#include "global.h"
@ -66,7 +68,7 @@ public:
~DataBase();
QString getSoftVersion();
QString getDBVersion();
float getDBVersion();
QString getDBName();
bool createConnection(const QString &function, bool newDB=false); // If true that means that we are creating the DB,
@ -123,6 +125,7 @@ private:
bool execQuery(const QString &function, const QString &stringQuery);
bool updateEntity (const QString &_codeString, const int _code);
bool createDataBase();
bool setPragma(); // Defines the PRAGMA for the DB
bool isTheDBCreated();
bool isTheTableExisting(const QString &_tableName);
bool hasTheTableData(const QString &_tableName);
@ -237,6 +240,7 @@ private:
QMap<QString, int> modeQMap;
Utilities *util;
QueryExecutor *exe;
QSqlDatabase db;
QString dbDir, dbName;

View File

@ -0,0 +1,93 @@
#include "db_adif_primary_subdvisions_data.h"
DB_ADIF_Primary_Subdvisions_data::DB_ADIF_Primary_Subdvisions_data(const QString &_parentClass)
{
Q_UNUSED(_parentClass);
qDebug() << Q_FUNC_INFO << _parentClass ;
}
bool DB_ADIF_Primary_Subdvisions_data::addData()
{
/*
stringQuery = stringQuery + QString(" (id INTEGER PRIMARY KEY AUTOINCREMENT, "
"dxcc INTEGER NOT NULL, " // arrlId (281)
"name VARCHAR NOT NULL, " // Madrid
"shortname VARCHAR NOT NULL, " // M
"prefix VARCHAR, " // EA4
"cqz INTEGER NOT NULL, " // 14
"ituz INTEGER NOT NULL, " // 37
"regionalgroup VARCHAR, " // Comunidad de Madrid
"regionalid INTEGER, " // Oblast in Russia or any other Id
"start_date DATETIME, "
"end_date DATETIME, "
"deleted VARCHAR, "
"UNIQUE (id, shortname, name), "
"FOREIGN KEY (cqz) REFERENCES entity (cqz), "
"FOREIGN KEY (ituz) REFERENCES entity (ituz), "
"FOREIGN KEY (dxcc) REFERENCES entity (dxcc) )");
*/
if (!isDBCreated())
return false;
if (!add_EA6_21())
return false;
return add_EA_281();
}
bool DB_ADIF_Primary_Subdvisions_data::isDBCreated()
{
return true;
}
bool DB_ADIF_Primary_Subdvisions_data::addValues(const QString &rows, const QStringList &values)
{
// This function will add all the values that come in the QStringList
// It receives the list of rows and the values that will feed the table with the
// values for primary subdivisions (provinces?) of the DXCC entity.
QueryExecutor exe(Q_FUNC_INFO);
QString sq = QString("INSERT INTO primary_subdivisions (%1) VALUES ").arg(rows);
QString aux, oneValue;
foreach (aux, values)
{
oneValue = QString("%1 (%2))").arg(sq).arg(aux);
if (!exe.execQuery(Q_FUNC_INFO, oneValue))
return false;
}
return true;
}
bool DB_ADIF_Primary_Subdvisions_data::add_EA6_21()
{
// This function contains the Primary Subdivision data for Balearic is
// Source of data is https://www.adif.org (version 3.1.4)
// Last modification 20240620
QString rows = QString("dxcc, name, shortname, prefix, cqz, ituz, regionalgroup, regionalid, start_date, end_date, deleted");
QStringList values;
values.clear();
values << "'21', 'Baleares', 'IB', 'EA6', '14', '37', 'Islas Baleares', '-1', '', '', 'N'";
return addValues(rows, values);
}
bool DB_ADIF_Primary_Subdvisions_data::add_EA_281()
{
// This function contains the Primary Subdivision data for Spain
// Source of data is https://www.adif.org (version 3.1.4)
// Last modification 20240620
QString rows = QString("dxcc, name, shortname, prefix, cqz, ituz, regionalgroup, regionalid, start_date, end_date, deleted");
QStringList values;
values.clear();
values << "'281', 'Madrid', 'M', 'EA4', '14', '37', 'Madrid', '-1', '', '', 'N'"
<< "'281', 'Asturias', 'O', 'EA1', '14', '37', 'Asturias', '-1', '', '', 'N'"
<< "'281', 'Avila', 'AV', 'EA1', '14', '37', 'Castilla y León', '-1', '', '', 'N'";
return addValues(rows, values);
}

View File

@ -0,0 +1,28 @@
#ifndef DB_ADIF_PRIMARY_SUBDVISIONS_DATA_H
#define DB_ADIF_PRIMARY_SUBDVISIONS_DATA_H
#include <QObject>
#include "queryexecutor.h"
class DB_ADIF_Primary_Subdvisions_data : public QObject
{
Q_OBJECT
public:
explicit DB_ADIF_Primary_Subdvisions_data(const QString &_parentClass);
bool addData();
signals:
private:
// To add new entity data, a new function should be created.
// The format should be "add_MAIN-PREFIX-ARRLid
QueryExecutor *exe;
bool isDBCreated(); // This function checks if the DB is created.
bool addValues(const QString &rows, const QStringList &values);
bool add_EA6_21(); // Adds the data for Balearic Is
bool add_EA_281(); // Adds the data for Spain
};
#endif // DB_ADIF_PRIMARY_SUBDVISIONS_DATA_H

View File

@ -0,0 +1,34 @@
#include "queryexecutor.h"
QueryExecutor::QueryExecutor(const QString &_parentClass)
{
Q_UNUSED(_parentClass);
qDebug() << Q_FUNC_INFO << _parentClass ;
}
void QueryExecutor::queryErrorManagement(const QString &_functionFailed, const QString &errorCodeS, const QString &_nativeError, const QString &_failedQuery)
{
Q_UNUSED(_functionFailed);
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 ;
}
bool QueryExecutor::execQuery(const QString &function, const QString &stringQuery)
{
qDebug() << Q_FUNC_INFO << " " << function << " : " << stringQuery ;
QSqlQuery query;
query.prepare(stringQuery);
bool ok = query.exec(stringQuery);
query.finish();
if (!ok)
{
queryErrorManagement(function, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
}
return ok;
}

View File

@ -0,0 +1,21 @@
#ifndef QUERYEXECUTOR_H
#define QUERYEXECUTOR_H
#include <QObject>
#include <QSqlQuery>
#include <QSqlError>
class QueryExecutor : public QObject
{
Q_OBJECT
public:
explicit QueryExecutor(const QString &_parentClass);
bool execQuery(const QString &function, const QString &stringQuery);
void queryErrorManagement(const QString &_functionFailed, const QString &errorCodeS, const QString &_nativeError, const QString &_failedQuery);
private:
};
#endif // QUERYEXECUTOR_H

View File

@ -126,7 +126,7 @@ void DXCCStatusWidget::createUI()
void DXCCStatusWidget::update()
{
emit debugLog (Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO << ": " << QTime::currentTime().toString("HH:mm:ss");
qDebug() << Q_FUNC_INFO << ": " << QTime::currentTime().toString("HH:mm:ss");
int entities = dataProxy->getMaxEntityID(false);
if (!awards->updateDXCCBandsStatus (-1)) // We update all
{
@ -469,7 +469,7 @@ void DXCCStatusWidget::addEntity2(const QStringList &_ent)
void DXCCStatusWidget::setBands(const QString &_callingFunc, QStringList const &_ent, const bool _creating)
{// Receives the list of band names and defines the columns
//qDebug() << Q_FUNC_INFO << "(" << _callingFunc << ")" << QTime::currentTime().toString("HH:mm:ss");
qDebug() << Q_FUNC_INFO << "(" << _callingFunc << ")" << QTime::currentTime().toString("HH:mm:ss");
Q_UNUSED(_callingFunc);
//foreach(QString aux, _ent)
//{
@ -478,12 +478,12 @@ void DXCCStatusWidget::setBands(const QString &_callingFunc, QStringList const &
emit debugLog (Q_FUNC_INFO, "Start", Debug);
QStringList qs;
qs.clear();
//qDebug() << "DXCCStatusWidget::setBands - 01" << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 01" << QTime::currentTime().toString("HH:mm:ss");
qs << dataProxy->sortBandNamesBottonUp(_ent);
//qDebug() << "DXCCStatusWidget::setBands - 02: Lenght qs: " << QString::number(qs.size()) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 02: Lenght qs: " << QString::number(qs.size()) << QTime::currentTime().toString("HH:mm:ss");
if (qs.length()<0)
{
//qDebug() << "DXCCStatusWidget::setBands no bands received here " << QTime::currentTime().toString("HH:mm:ss") << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " no bands received here " << QTime::currentTime().toString("HH:mm:ss") << QTime::currentTime().toString("HH:mm:ss");
return;
}
@ -491,26 +491,26 @@ void DXCCStatusWidget::setBands(const QString &_callingFunc, QStringList const &
testBand.clear();
bandNames.clear();
//qDebug() << "DXCCStatusWidget::setBands - 03 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 03 " << QTime::currentTime().toString("HH:mm:ss");
validBands.clear();
validBands = dataProxy->getBandNames();
//qDebug() << "DXCCStatusWidget::setBands - 04 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 04 " << QTime::currentTime().toString("HH:mm:ss");
dxccView->clearSelection();
dxccView->clear();
for (int i = 0; i<qs.length(); i++)
{
//qDebug() << "DXCCStatusWidget::setBands-4.1: " << qs.at(i) <<" - " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << "-4.1: " << qs.at(i) <<" - " << QTime::currentTime().toString("HH:mm:ss");
testBand = qs.at(i);
if (validBands.contains(qs.at(i)))
{
bandNames.append(testBand);
//qDebug() << "DXCCStatusWidget::setBands-4.2: Added: " << bandNames.last() << " - " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << "-4.2: Added: " << bandNames.last() << " - " << QTime::currentTime().toString("HH:mm:ss");
}
//else
//{
//qDebug() << "DXCCStatusWidget::setBands -4.3 Not valid band: " << testBand << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " -4.3 Not valid band: " << testBand << QTime::currentTime().toString("HH:mm:ss");
//}
}
dxccView->setColumnCount(0);
@ -518,35 +518,35 @@ void DXCCStatusWidget::setBands(const QString &_callingFunc, QStringList const &
while(dxccView->columnCount()>0)
{
//qDebug() << "DXCCStatusWidget::setBands: Still pending: " << QString::number(dxccView->columnCount()) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << ": Still pending: " << QString::number(dxccView->columnCount()) << QTime::currentTime().toString("HH:mm:ss");
dxccView->removeColumn(0);
}
numberOfColumns = dxccView->columnCount();
//qDebug() << "DXCCStatusWidget::setBands: -6 All removed: " << QString::number(numberOfColumns) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << ": -6 All removed: " << QString::number(numberOfColumns) << QTime::currentTime().toString("HH:mm:ss");
numberOfColumns = 2 + bandNames.length(); //Prefix, Entity Name
//qDebug() << "DXCCStatusWidget::setBands - 7.1 - columnCount: " << QString::number(dxccView->columnCount()) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << "DXCCStatusWidget::setBands - 7.1 - numberOfColumns: " << QString::number(numberOfColumns) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.1 - columnCount: " << QString::number(dxccView->columnCount()) << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.1 - numberOfColumns: " << QString::number(numberOfColumns) << QTime::currentTime().toString("HH:mm:ss");
dxccView->setColumnCount(numberOfColumns);
//qDebug() << "DXCCStatusWidget::setBands - 7.2 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.2 " << QTime::currentTime().toString("HH:mm:ss");
dxccView->setRowCount(0);
//qDebug() << "DXCCStatusWidget::setBands - 7.3 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.3 " << QTime::currentTime().toString("HH:mm:ss");
QStringList headerqs;
//qDebug() << "DXCCStatusWidget::setBands - 7.4 " << QTime::currentTime()).toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.4 " << QTime::currentTime()).toString("HH:mm:ss");
headerqs.clear();
//qDebug() << "DXCCStatusWidget::setBands - 7.5 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 7.5 " << QTime::currentTime().toString("HH:mm:ss");
headerqs << tr("Prefix") << tr("Entity") << bandNames;
//qDebug() << "DXCCStatusWidget::setBands - 8 " << QTime::currentTime().toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - 8 " << QTime::currentTime().toString("HH:mm:ss");
dxccView->setHorizontalHeaderLabels(headerqs);
//qDebug() << "DXCCStatusWidget::setBands - 9 PRE-END" << QTime::currentTime().toString("HH:mm:ss");
qDebug() << Q_FUNC_INFO << " - 9 PRE-END" << QTime::currentTime().toString("HH:mm:ss");
if (_creating)
{
//qDebug() << "DXCCStatusWidget::setBands: 9.1 !_creating so updating!" << QTime::currentTime().toString("HH:mm:ss");
qDebug() << Q_FUNC_INFO << ": 9.1 !_creating so updating!" << QTime::currentTime().toString("HH:mm:ss");
update();
}
//qDebug() << "DXCCStatusWidget::setBands: END" << QTime::currentTime().toString("HH:mm:ss");
qDebug() << Q_FUNC_INFO << ": END" << QTime::currentTime().toString("HH:mm:ss");
emit debugLog (Q_FUNC_INFO, "Start", Debug);
}

View File

@ -38,6 +38,26 @@
#include "mainwindow.h"
#include "utilities.h"
int showNoDB()
{
QMessageBox msgBox;
Utilities util(Q_FUNC_INFO);
QString msg = QString("There is no DB in the KLog folder and could not create it. KLog can't continue like this.\n") +
QString("Please remove or rename the %1 file and restart KLog.").arg(util.getCfgFile());
msgBox.setWindowTitle("KLog");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setTextFormat(Qt::RichText);
msgBox.setText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return -1;
}
int main(int argc, char *argv[])
{
//qDebug() << Q_FUNC_INFO << " - Start! ";
@ -46,14 +66,10 @@ int main(int argc, char *argv[])
//qDebug() << QT_VERSION_STR;
QDir d1 = QDir();
//QCoreApplication::setApplicationVersion(QString(APP_VERSION));
//qDebug() << Q_FUNC_INFO << " - STARTED: ";
Utilities util(Q_FUNC_INFO);
QStringList arguments;
QTextStream cout(stdout);
//QCoreApplication::setOrganizationName("EA4K");
//QCoreApplication::setOrganizationDomain("klog.xyz");
//QCoreApplication::setApplicationName("KLog");
QApplication app(argc, argv);
QString iconSt;
@ -66,6 +82,7 @@ int main(int argc, char *argv[])
app.setApplicationVersion(QString(APP_VERSION));
QString version = QCoreApplication::applicationVersion();
//qDebug() << Q_FUNC_INFO << " - -10 ";
// Now we check if the user is executing from the command line
arguments.clear();
arguments << app.arguments();
@ -88,6 +105,7 @@ int main(int argc, char *argv[])
app.quit();
return 0;
}
//qDebug() << Q_FUNC_INFO << " - Start of translation activities: "<< (QTime::currentTime()).toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - Detected language: " << (QLocale::system().name()).left(2) << ".qm";
// Translations begin
@ -170,28 +188,28 @@ int main(int argc, char *argv[])
#endif
//qDebug() << Q_FUNC_INFO << " - -40 ";
if (missingTranslation)
{
//qDebug() << Q_FUNC_INFO << " - Translation missing! ";
QMessageBox msgBox;
QString urlTranslate = QString();
urlTranslate = "<p><a href=\"https://translate.google.com/?sl=auto&tl=auto#en/auto/No%20translation%20files%20for%20your%20language%20have%20been%20found%20so%20KLog%20will%20be%20shown%20in%20English.%0A%0AIf%20you%20have%20the%20klog_en.qm%20file%20for%20your%20language%2C%20you%20can%20copy%20it%20in%20the%20%2Fhome%2Fdevel%2F.klog%2F%20folder%20and%20restart%20KLog%20again.%0A%0A%20If%20you%20want%20to%20help%20to%20translate%20KLog%20into%20your%20language%2C%20please%20contact%20the%20author.\">TRANSLATE</a></p>";
{
//qDebug() << Q_FUNC_INFO << " - Translation missing! ";
QMessageBox msgBox;
QString urlTranslate = QString();
urlTranslate = "<p><a href=\"https://translate.google.com/?sl=auto&tl=auto#en/auto/No%20translation%20files%20for%20your%20language%20have%20been%20found%20so%20KLog%20will%20be%20shown%20in%20English.%0A%0AIf%20you%20have%20the%20klog_en.qm%20file%20for%20your%20language%2C%20you%20can%20copy%20it%20in%20the%20%2Fhome%2Fdevel%2F.klog%2F%20folder%20and%20restart%20KLog%20again.%0A%0A%20If%20you%20want%20to%20help%20to%20translate%20KLog%20into%20your%20language%2C%20please%20contact%20the%20author.\">TRANSLATE</a></p>";
QString msg = QString();
QString msg = QString();
msgBox.setWindowTitle("KLog");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setTextFormat(Qt::RichText);
QString language = (QLocale::system().name()).left(2); /* Flawfinder: ignore */
msgBox.setWindowTitle("KLog");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setTextFormat(Qt::RichText);
QString language = (QLocale::system().name()).left(2); /* Flawfinder: ignore */
msg = QString("No translation files for your language have been found so KLog will be shown in English.") + "<p>" +
QString("If you have the klog_%1.qm file for your language, you can copy it into the %2/translations/ folder and restart KLog.</p><p>If you want to help to translate KLog into your language, please contact the author.").arg(language).arg(QCoreApplication::applicationDirPath()) +
"</p>" + urlTranslate;
msg = QString("No translation files for your language have been found so KLog will be shown in English.") + "<p>" +
QString("If you have the klog_%1.qm file for your language, you can copy it into the %2/translations/ folder and restart KLog.</p><p>If you want to help to translate KLog into your language, please contact the author.").arg(language).arg(QCoreApplication::applicationDirPath()) +
"</p>" + urlTranslate;
msgBox.setText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
msgBox.setText(msg);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
//qDebug() << Q_FUNC_INFO << " - 1" << (QTime::currentTime()).toString("HH:mm:ss") ;
@ -202,6 +220,7 @@ int main(int argc, char *argv[])
/* Application Singleton
*
* We want to run only one instance of KLog application
*
*/
QSystemSemaphore semaphore("klogapp", 1); // create semaphore with unique ID klogapp
semaphore.acquire(); // Raise the semaphore, barring other instances to work with shared memory
@ -252,11 +271,10 @@ int main(int argc, char *argv[])
// END OF Application Singleton
QString klogDir = util.getHomeDir();
//configFileName = util.getCfgFile();
//qDebug() << Q_FUNC_INFO << " - 10";
//qDebug() << Q_FUNC_INFO << " - Setting klog dir: " << (QTime::currentTime()).toString("HH:mm:ss")<< QT_ENDL;;
// First step when running KLog, if the KLog folder does not exist, KLog creates it
if (!QDir::setCurrent (klogDir) )
{
//qDebug() << Q_FUNC_INFO << " - KLogDir does not exist.... creating ";
@ -275,7 +293,7 @@ int main(int argc, char *argv[])
//qDebug() << Q_FUNC_INFO << " - 51" << (QTime::currentTime()).toString("HH:mm:ss");
QSplashScreen splash(pixmap);
// If the KLog configuration file does not exist, we launch the wizard.
if (!((QFile::exists(util.getCfgFile ()))))
{
//qDebug() << Q_FUNC_INFO << " - Starting wizard... ";
@ -284,14 +302,15 @@ int main(int argc, char *argv[])
wizard->exec();
}
else
{
{ // KLog configuration file exists, let's look for the DB
//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";
if (!db->createConnection(Q_FUNC_INFO))
{
//qDebug() << Q_FUNC_INFO << " - Conection not created";
return -1; // Exits with an error; no DB has been created
return showNoDB();
//return -1; // Exits with an error; no DB has been created
}
else
{
@ -329,11 +348,8 @@ int main(int argc, char *argv[])
//qDebug() << Q_FUNC_INFO << " - 111 " << (QTime::currentTime()).toString("HH:mm:ss");
splash.finish(&mw);
//qDebug() << Q_FUNC_INFO << " - 112 " << (QTime::currentTime()).toString("HH:mm:ss");
mw.showNotWar();
//mw.showNotWar();
//qDebug() << Q_FUNC_INFO << " - 113 " << (QTime::currentTime()).toString("HH:mm:ss");
//qDebug() << Q_FUNC_INFO << " - END";
return app.exec();
}

View File

@ -290,80 +290,14 @@ void MainWindow::setWindowSize(const QSize &_size)
logEvent(Q_FUNC_INFO, "END", Debug);
}
void MainWindow::checkDebugFile()
void MainWindow::init_variables()
{
QFile debugFile(util->getDebugLogFile());
if (!debugFile.open(QIODevice::WriteOnly | QIODevice::Text)) /* Flawfinder: ignore */
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - File not open"));
QString aux = tr("It was not possible to open the debug file for writing. No debug log will be saved!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else
{
debugFile.close();
logEvent(Q_FUNC_INFO, "KLog started!", Debug);
}
}
void MainWindow::checkHomeDir()
{
if (!QDir::setCurrent ( util->getHomeDir () )){
QDir d1(util->getHomeDir ());
if (d1.mkdir(util->getHomeDir ()))
{
if (!QDir::setCurrent ( util->getHomeDir () ))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - KLog folder not found"));
QString aux = tr("It was not possible to define the KLog folder. Some functions may not work properly!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
}
}
void MainWindow::init()
{
//qDebug() << Q_FUNC_INFO << " - Start - " << (QTime::currentTime()).toString("HH:mm:ss") ;
logLevel = Debug;
logEvent(Q_FUNC_INFO, "Start", Debug);
checkHomeDir();
checkDebugFile();
//qDebug() << Q_FUNC_INFO << " - 00" ;
util->setLongPrefixes(dataProxy->getLongPrefixes());
util->setSpecialCalls(dataProxy->getSpecialCallsigns());
//qDebug() << Q_FUNC_INFO << " - 000" ;
setupDialog->init(softwareVersion, 0, configured);
//qDebug() << Q_FUNC_INFO << " - 01" ;
filemanager->init();
manualMode = false;
qrzAutoChanging = false;
qDebug() << Q_FUNC_INFO << " - Start";
QRZCOMAutoCheckAct->setCheckable(true);
QRZCOMAutoCheckAct->setChecked(false);
manualMode = false;
qrzAutoChanging = false;
logEvents = true;
hamlib->initClass();
util->setCallValidation (true);
infoLabel1T = QString();
infoLabel2T = QString();
qso->clear();
//Default band/modes
bands << "10M" << "15M" << "20M" << "40M" << "80M" << "160M";
modes << "SSB" << "CW";
@ -376,13 +310,8 @@ void MainWindow::init()
readingTheUI = false;
itIsANewversion = false;
setCleaning(false);
//qDebug() << Q_FUNC_INFO << " - 10" ;
dxClusterWidget->init();
infoLabel1T = QString();
infoLabel2T = QString();
infoTimeout = 2000; // default timeout
defaultADIFLogFile = "klog.adi";
@ -460,9 +389,6 @@ void MainWindow::init()
qrzcomSubscriber = false;
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") ;
selectedYear = (dateTime->currentDateTime()).date().year();
loggWinAct->setShortcut(Qt::CTRL | Qt::Key_L);
@ -483,13 +409,88 @@ void MainWindow::init()
confirmedColor.setNamedColor("red");
newOneColor.setNamedColor("green");
#endif
qDebug() << Q_FUNC_INFO << " - END";
}
void MainWindow::checkDebugFile()
{
QFile debugFile(util->getDebugLogFile());
if (!debugFile.open(QIODevice::WriteOnly | QIODevice::Text)) /* Flawfinder: ignore */
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - File not open"));
QString aux = tr("It was not possible to open the debug file for writing. No debug log will be saved!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
else
{
debugFile.close();
logEvent(Q_FUNC_INFO, "KLog started!", Debug);
}
}
void MainWindow::checkHomeDir()
{
if (!QDir::setCurrent ( util->getHomeDir () )){
QDir d1(util->getHomeDir ());
if (d1.mkdir(util->getHomeDir ()))
{
if (!QDir::setCurrent ( util->getHomeDir () ))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle(tr("KLog - KLog folder not found"));
QString aux = tr("It was not possible to define the KLog folder. Some functions may not work properly!");
msgBox.setText(aux);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
}
}
void MainWindow::init()
{
//qDebug() << Q_FUNC_INFO << " - Start - " << (QTime::currentTime()).toString("HH:mm:ss") ;
logLevel = Debug;
logEvent(Q_FUNC_INFO, "Start", Debug);
checkHomeDir();
checkDebugFile();
//qDebug() << Q_FUNC_INFO << " - 00" ;
util->setLongPrefixes(dataProxy->getLongPrefixes());
util->setSpecialCalls(dataProxy->getSpecialCallsigns());
//qDebug() << Q_FUNC_INFO << " - 000" ;
setupDialog->init(softwareVersion, 0, configured);
//qDebug() << Q_FUNC_INFO << " - 01" ;
filemanager->init();
init_variables();
hamlib->initClass();
util->setCallValidation (true);
qso->clear();
setCleaning(false);
//qDebug() << Q_FUNC_INFO << " - 10" ;
dxClusterWidget->init();
setModifying(false);
//qDebug() << Q_FUNC_INFO << " - 50" << (QTime::currentTime()).toString("HH:mm:ss") ;
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") ;
logWindow->createlogPanel(currentLog);
//qDebug() << Q_FUNC_INFO << " - 72" << (QTime::currentTime()).toString("HH:mm:ss") ;
@ -510,15 +511,15 @@ 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;
@ -546,19 +547,36 @@ void MainWindow::init()
void MainWindow::checkExistingData()
{
//qDebug() << Q_FUNC_INFO << " - " << (QTime::currentTime()).toString("HH:mm:ss") ;
qDebug() << Q_FUNC_INFO << " - " << (QTime::currentTime()).toString("HH:mm:ss") ;
bool existingData = QFile::exists(util->getKLogDBFile());
//qDebug() << Q_FUNC_INFO << " - 1" ;
qDebug() << Q_FUNC_INFO << " - 1" ;
ctyDatFile = util->getCTYFile();
//qDebug() << Q_FUNC_INFO << " - 2" ;
if (!existingData)
qDebug() << Q_FUNC_INFO << " - 2" ;
if (existingData)
{
//qDebug() << Q_FUNC_INFO << " - 3" ;
world->create(ctyDatFile);
//qDebug() << Q_FUNC_INFO << " - 4" ;
qDebug() << Q_FUNC_INFO << " - existingData TRUE" ;
}
else if (!world->hasSpecialEntities())
else
{
qDebug() << Q_FUNC_INFO << " - existingData FALSE" ;
}
if (world->hasSpecialEntities())
{
qDebug() << Q_FUNC_INFO << " - Special Entities TRUE" ;
}
else
{
qDebug() << Q_FUNC_INFO << " - Special Entities FALSE" ;
}
if ((!existingData) || (!world->hasSpecialEntities()))
{
qDebug() << Q_FUNC_INFO << " - Recreating world" ;
world->recreate(ctyDatFile);
qDebug() << Q_FUNC_INFO << " - 3" ;
//world->create(ctyDatFile);
qDebug() << Q_FUNC_INFO << " - 4" ;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
@ -578,8 +596,9 @@ void MainWindow::checkExistingData()
default:
break;
}
//qDebug() << Q_FUNC_INFO << " - 7" << (QTime::currentTime()).toString("HH:mm:ss") ;
qDebug() << Q_FUNC_INFO << " - 7" << (QTime::currentTime()).toString("HH:mm:ss") ;
}
qDebug() << Q_FUNC_INFO << " - END" ;
}
void MainWindow::readSettingsFile()
@ -3527,7 +3546,7 @@ void MainWindow::startServices()
void MainWindow::checkIfNewBandOrMode()
{//Checks the log to see if there is a QSO with a band/mode
//that is not currently selected as active
//qDebug() << "MainWindow::checkIfNewBandOrMode - START " << QTime::currentTime().toString("hh:mm:ss") ;
qDebug() << "MainWindow::checkIfNewBandOrMode - START " << QTime::currentTime().toString("hh:mm:ss") ;
logEvent(Q_FUNC_INFO, "Start", Debug);
QString currentBand = mainQSOEntryWidget->getBand();
QString currentMode = mainQSOEntryWidget->getMode();
@ -3562,11 +3581,11 @@ void MainWindow::checkIfNewBandOrMode()
mapWindow->setModes(modes);
//qDebug() << "MainWindow::checkIfNewBandOrMode - setting bands" << QTime::currentTime().toString("hh:mm:ss") ;
qDebug() << "MainWindow::checkIfNewBandOrMode - setting bands" << QTime::currentTime().toString("hh:mm:ss") ;
logEvent(Q_FUNC_INFO, "Setting bands", Debug);
dxccStatusWidget->setBands(Q_FUNC_INFO, bands, true);
//qDebug() << "MainWindow::checkIfNewBandOrMode - currentBand: " << currentBand << QTime::currentTime().toString("hh:mm:ss") ;
qDebug() << "MainWindow::checkIfNewBandOrMode - currentBand: " << currentBand << QTime::currentTime().toString("hh:mm:ss") ;
if (bands.contains(currentBand))
{
mainQSOEntryWidget->setBand(currentBand);
@ -5588,11 +5607,11 @@ void MainWindow::completeWithPreviousQSO(const QString &_call)
void MainWindow::slotValidBandsReceived(const QStringList &_b)
{
logEvent(Q_FUNC_INFO, "Start", Debug);
//qDebug() << Q_FUNC_INFO ;
qDebug() << Q_FUNC_INFO ;
dxccStatusWidget->setBands(Q_FUNC_INFO, _b, true);
satTabWidget->addBands(_b);
mapWindow->setBands(_b);
//qDebug() << Q_FUNC_INFO << " - END" ;
qDebug() << Q_FUNC_INFO << " - END" ;
logEvent(Q_FUNC_INFO, "END", Debug);
}

View File

@ -329,6 +329,7 @@ private slots:
private:
//void setWidgetsOrder();
void init_variables(); // Refactored from init()
void checkDebugFile(); // Refactored from init()
void checkExistingData(); // Refactored from init()
void readSettingsFile(); // Refactored from init()

View File

@ -92,6 +92,8 @@ HEADERS += setupdialog.h \
charts/statsgridsonsatswidget.h \
charts/statssentconfirmedpiechartwidget.h \
database.h \
database/db_adif_primary_subdvisions_data.h \
database/queryexecutor.h \
dataproxy_sqlite.h \
downloadcty.h \ \
dxcluster/dxspot.h \
@ -172,6 +174,8 @@ SOURCES += main.cpp \
adif.cpp \
awardswidget.cpp \
charts/statsfieldperbandwidget.cpp \
database/db_adif_primary_subdvisions_data.cpp \
database/queryexecutor.cpp \
dxcluster/dxcluster.cpp \
dxcluster/dxclusterassistant.cpp \
dxcluster/dxspot.cpp \

View File

@ -529,9 +529,9 @@ QString Utilities::getDBPath()
QString Utilities::getKLogDBFile()
{ // Returns the full path to the main DB
qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
QSettings settings(getCfgFile (), QSettings::IniFormat);
qDebug() << Q_FUNC_INFO << " - CFG: " << getCfgFile();
//qDebug() << Q_FUNC_INFO << " - CFG: " << getCfgFile();
QString dbFile;
QString filename = "/logbook.dat";
@ -549,12 +549,12 @@ QString Utilities::getKLogDBFile()
}
dbFile = settings.value("DBPath").toString () + filename;
qDebug() << Q_FUNC_INFO << "DBPath: " << dbFile;
//qDebug() << Q_FUNC_INFO << "DBPath: " << dbFile;
if (QFile::exists(dbFile))
return dbFile;
qDebug() << Q_FUNC_INFO << " - DBPath file DOES NOT Exist, returning default";
//qDebug() << Q_FUNC_INFO << " - DBPath file DOES NOT Exist, returning default";
return getDBPath() + filename;
}

View File

@ -36,9 +36,9 @@ To insert a (key, value) pair into the hash, you can use operator[]():
World::World(DataProxy_SQLite *dp, const QString &_parentFunction)
{
Q_UNUSED(_parentFunction);
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
//worldModel = new QSqlRelationalTableModel(this);
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
numberOfEntities = 0;
progressBarPosition = 0;
worldPrefixes.clear();
@ -55,51 +55,52 @@ World::World(DataProxy_SQLite *dp, const QString &_parentFunction)
util = new Utilities(Q_FUNC_INFO);
if (readWorld())
/*
if (readWorld())
{
//qDebug() << Q_FUNC_INFO << " - World TRUE";
//qDebug() << Q_FUNC_INFO << " - World TRUE";
}
else
{
//qDebug() << Q_FUNC_INFO << " - World FALSE";
//qDebug() << Q_FUNC_INFO << " - World FALSE";
}
//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
*/
}
World::~World()
{
//qDebug() << "World::~World";
//qDebug() << "World::~World";
delete(locator);
delete(util);
}
bool World::readWorld()
{ // Used to link a prefix with an Entity quickly, without quering the DB.
//qDebug() << Q_FUNC_INFO << " - Start";
//qDebug() << Q_FUNC_INFO << " - Start";
worldPrefixes.clear();
worldPrefixes = dataProxy->getWorldData();
if (worldPrefixes.size()>100)
{
//qDebug() << Q_FUNC_INFO << " - END true";
//qDebug() << Q_FUNC_INFO << " - END true";
util->setLongPrefixes(dataProxy->getLongPrefixes());
util->setSpecialCalls(dataProxy->getSpecialCallsigns());
return true;
}
//qDebug() << Q_FUNC_INFO << " - END false";
//qDebug() << Q_FUNC_INFO << " - END false";
return false;
}
bool World::recreate(const QString &_worldFile)
{
//qDebug() << Q_FUNC_INFO << ": " << _worldFile;
//qDebug() << Q_FUNC_INFO << ": " << _worldFile;
QSqlQuery query;
if (query.exec("DELETE FROM entity"))
{
//qDebug() << Q_FUNC_INFO << ": EMPTY entity" ;
//qDebug() << Q_FUNC_INFO << ": EMPTY entity" ;
if (query.exec("DELETE FROM prefixesofentity"))
{
//qDebug() << Q_FUNC_INFO << ": EMPTY prefixesofentity - END-1" ;
//qDebug() << Q_FUNC_INFO << ": EMPTY prefixesofentity - END-1" ;
return create(_worldFile);
//if (create(_worldFile))
@ -109,7 +110,7 @@ bool World::recreate(const QString &_worldFile)
}
else
{//TODO: Manage the query error
//qDebug() << Q_FUNC_INFO << ": FAILED TO EMPTY prefixesofentity - END-2" ;
//qDebug() << Q_FUNC_INFO << ": FAILED TO EMPTY prefixesofentity - END-2" ;
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return false;
}
@ -120,52 +121,52 @@ bool World::recreate(const QString &_worldFile)
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return false;
}
//qDebug() << Q_FUNC_INFO << " - END-4";
//qDebug() << Q_FUNC_INFO << " - END-4";
return false;
}
bool World::create(const QString &_worldFile)
{
//qDebug() << Q_FUNC_INFO << " " << _worldFile;
//qDebug() << Q_FUNC_INFO << " " << _worldFile;
if (readCTYCSV(_worldFile))
{
//qDebug() << Q_FUNC_INFO << " - 10" ;
//qDebug() << Q_FUNC_INFO << " - 10" ;
util->setLongPrefixes(dataProxy->getLongPrefixes());
util->setSpecialCalls(dataProxy->getSpecialCallsigns());
created = true;
//qDebug() << Q_FUNC_INFO << " - TRUE" ;
//qDebug() << Q_FUNC_INFO << " - TRUE" ;
}
else
{
//qDebug() << Q_FUNC_INFO << " - 20" ;
//qDebug() << Q_FUNC_INFO << " - 20" ;
created = false;
//qDebug() << Q_FUNC_INFO << " - FALSE" ;
//qDebug() << Q_FUNC_INFO << " - FALSE" ;
}
//qDebug() << Q_FUNC_INFO << " - 30" ;
//qDebug() << Q_FUNC_INFO << " - 30" ;
if (created)
{
//qDebug() << Q_FUNC_INFO << " - 40" ;
//qDebug() << Q_FUNC_INFO << " - 40" ;
created = insertSpecialEntities();
}
if (created)
{
//qDebug() << Q_FUNC_INFO << " - 50" ;
//qDebug() << Q_FUNC_INFO << " - 50" ;
if (dataProxy->updateISONames())
{
//qDebug() << Q_FUNC_INFO << " - 60" ;
//qDebug() << Q_FUNC_INFO << " updateISONames TRUE" ;
//qDebug() << Q_FUNC_INFO << " - 60" ;
//qDebug() << Q_FUNC_INFO << " updateISONames TRUE" ;
}
else
{
//qDebug() << Q_FUNC_INFO << " - 70" ;
//qDebug() << Q_FUNC_INFO << " updateISONames FALSE" ;
//qDebug() << Q_FUNC_INFO << " - 70" ;
//qDebug() << Q_FUNC_INFO << " updateISONames FALSE" ;
}
//qDebug() << Q_FUNC_INFO << " - 80" ;
//qDebug() << Q_FUNC_INFO << " - 80" ;
}
//qDebug() << Q_FUNC_INFO << " - 90" ;
//qDebug() << Q_FUNC_INFO << " - 90" ;
readWorld ();
//qDebug() << Q_FUNC_INFO << " - END" ;
//qDebug() << Q_FUNC_INFO << " - END" ;
return created;
}
@ -183,7 +184,7 @@ void World::createWorldModel()
QStringList World::processLine(const QString &_line)
{
//qDebug() << "World::processLine: received: " << _line;
//qDebug() << "World::processLine: received: " << _line;
//QString queryString;
QStringList aa;
QString line;
@ -193,14 +194,14 @@ QStringList World::processLine(const QString &_line)
{
line.replace(QChar('\''), QChar('_'));
}
//qDebug() << "World::processLine: Received: " << line;
//qDebug() << "World::processLine: Received: " << line;
//QSqlQuery query1;
nullValue=-1;
if ( (line.count(':') == 8 ) ) // First line of an Entity
{ //United States: 05: 08: NA: 43.00: 87.90: 5.0: K:
//qDebug() << "World::processLine first: " << line;
//qDebug() << Q_FUNC_INFO << ": first: " << line;
numberOfEntities++;
list.clear();
list << line.split(':');
@ -230,7 +231,7 @@ QStringList World::processLine(const QString &_line)
QStringList World::processLineP(const QString &_line, const int _processingEntity){
//Returns QStringList: prefix << dxcc << cqz << ituz OR CurrentEntity as a number
//qDebug() << "World::processLineP: Entity/received: " << QString::number(_processingEntity) << "/" << _line;
//qDebug() << Q_FUNC_INFO << ": Entity/received: " << QString::number(_processingEntity) << "/" << _line;
//QString queryString;
QString line;
int currentEntity = _processingEntity;
@ -245,7 +246,7 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
line.replace(QChar('\''), QChar('_'));
}
//qDebug() << "World::processLineP: Received: " << line;
//qDebug() << Q_FUNC_INFO << ": Received: " << line;
//QSqlQuery _queryp;
QStringList aa, _list;
aa.clear();
@ -258,7 +259,7 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
}
else if ( line.endsWith(';') ) // Last line of the Entity
{ // =WX4TM(4),=WX5S(3)[6],=WY5I(5)[8],=WY7I(4)[7],=WY7LL(4)[7],=WZ4F(4);
//qDebug() << "World::processLineP last line (; detected): " << line;
//qDebug() << Q_FUNC_INFO << ": last line (; detected): " << line;
_cqz = dataProxy->getCQzFromEntity(currentEntity);
_ituz = dataProxy->getITUzFromEntity(currentEntity);
@ -276,7 +277,7 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
}
else // More than just one prefix in the final line
{
//qDebug() << "World::processLineP Query (MORE one final)(line):" << line;
//qDebug() << Q_FUNC_INFO << ": Query (MORE one final)(line):" << line;
_list.clear();
_list << line.split(',');
aa.clear();
@ -285,20 +286,20 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
for (int i = 0; i < _list.size(); ++i)
{
// PROCESS THE LINE
//qDebug() << "World::processLineP LastLine prefixes" << _list.at(i);
//qDebug() << Q_FUNC_INFO << ": LastLine prefixes" << _list.at(i);
//readZones returns a QStringList: prefix, CQz, ITUz
prefixAndZones = readZones(_list.at(i), _cqz, _ituz);
//aa.clear();
aa << prefixAndZones.at(0) << QString::number(currentEntity) << prefixAndZones.at(1) << prefixAndZones.at(2);
//return aa;
}
//qDebug() << "World::processLineP: END" <<endl;
//qDebug() << Q_FUNC_INFO << " - END" ;
return aa;
}
}
else // Lines of the middle...
{ // =W4KW(4),=W4LC(4),=W4LSC(3)[6],=W4LWW(4),=W4NBS(4),=W4NI(4),=W4NTI(4),
//qDebug() << "World::processLine middle (no ; detected): " << line;
//qDebug() << Q_FUNC_INFO << ": middle (no ; detected): " << line;
_cqz = dataProxy->getCQzFromEntity(currentEntity);
_ituz = dataProxy->getITUzFromEntity(currentEntity);
@ -310,7 +311,7 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
if ((line.split(',')).size() == 1) // Only one prefix in the middle line
{ // Not usual, added this check for sanity reasons only
//qDebug() << "World::processLine Query: (only one middle) ";
//qDebug() << Q_FUNC_INFO << ": Query: (only one middle) ";
line = line.remove(',');
prefixAndZones = readZones(line, _cqz, _ituz);
aa.clear();
@ -320,7 +321,7 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
}
else
{
//qDebug() << "World::processLine Query: (MORE than one middle) ";
//qDebug() << Q_FUNC_INFO << ": Query: (MORE than one middle) ";
list.clear();
list << line.split(',');
@ -337,14 +338,14 @@ QStringList World::processLineP(const QString &_line, const int _processingEntit
}
}
}
//aa.clear();
//qDebug() << Q_FUNC_INFO << " - END";
return aa;
}
QStringList World::readZones (const QString &pref, const int _cq, const int _itu)
{
//Returns a QStringList: prefix, CQz, ITUz
//qDebug() << "World::readZones: (" << pref << "/" << QString::number(_cq) <<"/" << QString::number(_itu)<< ")";
//qDebug() << Q_FUNC_INFO << ": (" << pref << "/" << QString::number(_cq) <<"/" << QString::number(_itu)<< ")";
QStringList result;
int cq = _cq;
int itu = _itu;
@ -353,41 +354,41 @@ QStringList World::readZones (const QString &pref, const int _cq, const int _itu
if(aux.count('[')==1) // Check if has special CQz
{
//qDebug() << "World::readZones DETECTED [ !!!!";
//qDebug() << Q_FUNC_INFO << ": DETECTED [ !!!!";
qsizetype pos = aux.indexOf('[');
azone = aux.sliced(pos, 1);
//Following line was migrated from qt5
//azone = (aux.midRef(aux.indexOf('[')+1)).toString();
//qDebug() << "World::readZones (ITU)-1: " << aux << " right of " << QString::number(aux.indexOf('[')) << " = " << azone;
//qDebug() << Q_FUNC_INFO << ": (ITU)-1: " << aux << " right of " << QString::number(aux.indexOf('[')) << " = " << azone;
itu = (azone.left(azone.indexOf(']'))).toInt();
//qDebug() << "World::readZones (ITU)-2: " << azone.left(azone.indexOf(']'));
//qDebug() << Q_FUNC_INFO << ": (ITU)-2: " << azone.left(azone.indexOf(']'));
aux = aux.left(aux.indexOf('['));
//qDebug() << "World::readZones (ITU): " << pref << "/" << QString::number(itu) << "/" << aux;
//qDebug() << Q_FUNC_INFO << ": (ITU): " << pref << "/" << QString::number(itu) << "/" << aux;
}
if(aux.count('(')==1) // Check if has special CQz
{
//qDebug() << "World::readZones DETECTED ( !!!!";
//qDebug() << Q_FUNC_INFO << ": DETECTED ( !!!!";
qsizetype pos = aux.indexOf('(');
azone = aux.sliced(pos, 1);
//Following line was migrated from qt5
//azone = (aux.midRef(aux.indexOf('(')+1)).toString();
cq = (azone.left(azone.indexOf(')'))).toInt();
aux = aux.left(aux.indexOf('('));
//qDebug() << "World::readZones (CQ): " << pref << "/" << QString::number(cq) << "/" << aux;
//qDebug() << Q_FUNC_INFO << ": (CQ): " << pref << "/" << QString::number(cq) << "/" << aux;
}
//qDebug() << "World::readZones (Pref/CQ/ITU): " << pref << "= " << aux <<"/" << QString::number(cq) << "/" << QString::number(itu);
//qDebug() << Q_FUNC_INFO << ": (Pref/CQ/ITU): " << pref << "= " << aux <<"/" << QString::number(cq) << "/" << QString::number(itu);
result << aux << QString::number(cq) << QString::number(itu);
//qDebug() << "World::readZones (Pref/CQ/ITU): " << result;
//qDebug() << Q_FUNC_INFO << ": (Pref/CQ/ITU): " << result;
return result;
}
int World::getPrefixId(const QString &_prefix)
{
//qDebug() << Q_FUNC_INFO << " - Start: " << _prefix << "/" << QString::number(worldPrefixes.value(_prefix, -2));
//qDebug() << Q_FUNC_INFO << " - Start: " << _prefix << "/" << QString::number(worldPrefixes.value(_prefix, -2));
//This function receives the final prefix.
if (_prefix.length() < 1)
@ -399,7 +400,7 @@ int World::getPrefixId(const QString &_prefix)
QString World::getQRZEntityName(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
if (_qrz.length() < 1 )
{
return QString();
@ -420,7 +421,7 @@ QString World::getEntityName(const int _entityN)
int World::getQRZCqz(const QString &_qrz)
{
//qDebug() << "World::getQRZCqz: " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
if (_qrz.length() < 1 )
{
return -1;
@ -432,7 +433,7 @@ int World::getQRZCqz(const QString &_qrz)
int World::getQRZItuz(const QString &_qrz)
{
//qDebug() << "World::getQRZItuz: " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
if (_qrz.length() < 1 )
{
return -1;
@ -462,19 +463,19 @@ int World::getEntityItuz(const int _enti)
int World::getQRZARRLId(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
if (_qrz.length() < 1 )
{
return -1;
}
QString pref = util->getPrefixFromCall(_qrz);
//qDebug() << Q_FUNC_INFO << ": prefix: " << pref;
//qDebug() << Q_FUNC_INFO << ": prefix: " << pref;
return getPrefixId(pref);
}
QString World::getQRZEntityMainPrefix(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
if (_qrz.length() < 1 )
{
return "";
@ -509,13 +510,13 @@ bool World::isNewEntity(const int _entityN)
QString World::getQRZContinentShortName(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
return getContinentShortName (getQRZARRLId(_qrz));
}
QString World::getContinentShortName(const int _enti)
{
//qDebug() << "World::getQRZContinentShortName: " << QString::number(_enti);
//qDebug() << "World::getQRZContinentShortName: " << QString::number(_enti);
if ( _enti < 0 )
{
return "--";
@ -533,14 +534,14 @@ QString World::getContinentShortName(const int _enti)
QString World::getQRZContinentNumber(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
//qDebug() << Q_FUNC_INFO << ": " << _qrz;
int i = getQRZARRLId(_qrz);
return QString::number(getContinentNumber(i));
}
int World::getContinentNumber(const int _enti)
{
//qDebug() << "World::getQRZContinentNumber: " << QString::number(_enti);
//qDebug() << "World::getQRZContinentNumber: " << QString::number(_enti);
if (_enti <= 0)
{
return -1;
@ -568,13 +569,13 @@ double World::getLatitude(const int _enti)
QString World::getQRZLocator(const QString &_qrz)
{
//qDebug() << Q_FUNC_INFO << " - Start: " << _qrz;
//qDebug() << Q_FUNC_INFO << " - Start: " << _qrz;
if (_qrz.length() < 1)
{
return "";
}
int i = getQRZARRLId (_qrz);
//qDebug() << Q_FUNC_INFO << " - 2";
//qDebug() << Q_FUNC_INFO << " - 2";
return locator->getLocator(getLongitude(i), getLatitude (i));
}
@ -589,49 +590,69 @@ QString World::getLocator(const int _entityN)
bool World::addEntity(const QString &_name, const int _cq, const int _itu, const int _contId, const double _lat, const double _lon, const double _utc, const int _dxcc, const QString &_mainpref)
{
//qDebug() << Q_FUNC_INFO << " - Start";
/*
QString stringQuery = QString("CREATE TABLE %1 (id INTEGER PRIMARY KEY AUTOINCREMENT, "
"name VARCHAR(40) NOT NULL,"
"cqz INTEGER NOT NULL, "
"ituz INTEGER NOT NULL, "
"continent INTEGER NOT NULL, "
"latitude REAL NOT NULL, "
"longitude REAL NOT NULL, "
"utc REAL NOT NULL, "
"dxcc INTEGER NOT NULL, "
"mainprefix VARCHAR(15) NOT NULL, "
"deleted INTEGER, "
"sincedate VARCHAR(10), "
"todate VARCHAR(10), "
"isoname VARCHAR(10), "
"UNIQUE (dxcc, mainprefix), "
"FOREIGN KEY (continent) REFERENCES continent(id) )").arg(table);
*/
QSqlQuery query;
query.prepare("INSERT INTO entity (name, cqz, ituz, continent, latitude, longitude, utc, dxcc, mainprefix) "
"VALUES (:name, :cqz, :ituz, :cont, :lat, :lon, :utc, :dxcc, :mainpref)");
"VALUES (:name, :cqz, :ituz, :continent, :latitude, :longitude, :utc, :dxcc, :mainprefix)");
query.bindValue(":name", _name); // name
query.bindValue(":cqz", _cq); // CQ
query.bindValue(":ituz", _itu); // ITU
query.bindValue(":continent", _contId); // Cont
query.bindValue(":lat", _lat); // Lat
query.bindValue(":lon", _lon); // Lon
query.bindValue(":latitude", _lat); // Lat
query.bindValue(":longitude", _lon); // Lon
query.bindValue(":utc", _utc); // UTC
query.bindValue(":dxcc", _dxcc); // dxcc
query.bindValue(":mainpref", _mainpref); // Mainprefix
query.bindValue(":mainprefix", _mainpref); // Mainprefix
//qDebug() << Q_FUNC_INFO << " Entity name: " << _name;
//qDebug() << Q_FUNC_INFO << " Entity cqz: " << QString::number(_cq);
//qDebug() << Q_FUNC_INFO << " Entity ituz: " << QString::number(_itu);
//qDebug() << Q_FUNC_INFO << " Entity cont: " << QString::number(_contId);
//qDebug() << Q_FUNC_INFO << " Entity lat: " << QString::number(_lat);
//qDebug() << Q_FUNC_INFO << " Entity lon: " << QString::number(_lon);
//qDebug() << Q_FUNC_INFO << " Entity UTC: " << QString::number(_utc);
//qDebug() << Q_FUNC_INFO << " Entity ARRL: " << QString::number(_dxcc);
//qDebug() << Q_FUNC_INFO << " Entity Pref: " << _mainpref;
//qDebug() << Q_FUNC_INFO << " Entity name: " << _name;
//qDebug() << Q_FUNC_INFO << " Entity cqz: " << QString::number(_cq);
//qDebug() << Q_FUNC_INFO << " Entity ituz: " << QString::number(_itu);
//qDebug() << Q_FUNC_INFO << " Entity cont: " << QString::number(_contId);
//qDebug() << Q_FUNC_INFO << " Entity lat: " << QString::number(_lat);
//qDebug() << Q_FUNC_INFO << " Entity lon: " << QString::number(_lon);
//qDebug() << Q_FUNC_INFO << " Entity UTC: " << QString::number(_utc);
//qDebug() << Q_FUNC_INFO << " Entity ARRL: " << QString::number(_dxcc);
//qDebug() << Q_FUNC_INFO << " Entity Pref: " << _mainpref;
if (query.exec())
{
//qDebug() << Q_FUNC_INFO << " Entity data added OK: " << _name ;
//qDebug() << Q_FUNC_INFO << " Entity data added OK: " << _name ;
return true;
}
//else if (query.lastError().nativeErrorCode() == QString::number(19))
//{
//qDebug() << Q_FUNC_INFO << " Entity data NOT added: error19: " << _name ;
//qDebug() << Q_FUNC_INFO << " Entity data NOT added: error19: " << _name ;
//}
//else
//{
//qDebug() << Q_FUNC_INFO << " Entity data NOT added: error else: " << _name ;
//qDebug() << Q_FUNC_INFO << " Entity data NOT added: error else: " << _name ;
//emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
//qDebug() << Q_FUNC_INFO << " Entity data NOT added" ;
//qDebug() << Q_FUNC_INFO << " LastQuery: " << query.lastQuery() ;
//qDebug() << Q_FUNC_INFO << " LastError-data: " << query.lastError().databaseText() ;
//qDebug() << Q_FUNC_INFO << " LastError-driver: " << query.lastError().driverText() ;
//qDebug() << Q_FUNC_INFO << " LastError-n: " << query.lastError().nativeErrorCode();
//qDebug() << Q_FUNC_INFO << " Entity data NOT added" ;
//qDebug() << Q_FUNC_INFO << " LastQuery: " << query.lastQuery() ;
//qDebug() << Q_FUNC_INFO << " LastError-data: " << query.lastError().databaseText() ;
//qDebug() << Q_FUNC_INFO << " LastError-driver: " << query.lastError().driverText() ;
//qDebug() << Q_FUNC_INFO << " LastError-n: " << query.lastError().nativeErrorCode();
//}
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return false;
@ -639,10 +660,10 @@ bool World::addEntity(const QString &_name, const int _cq, const int _itu, const
bool World::addPrefix(const QString &_pref, const int _dxcc, const int _cqz, const int _ituz)
{
//qDebug() << Q_FUNC_INFO << ": _pref: " << _pref;
//qDebug() << Q_FUNC_INFO << ": _dxcc: " << QString::number(_dxcc);
//qDebug() << Q_FUNC_INFO << ": _cqz: " << QString::number(_cqz);
//qDebug() << Q_FUNC_INFO << ": _ituz: " << QString::number(_ituz);
//qDebug() << Q_FUNC_INFO << ": _pref: " << _pref;
//qDebug() << Q_FUNC_INFO << ": _dxcc: " << QString::number(_dxcc);
//qDebug() << Q_FUNC_INFO << ": _cqz: " << QString::number(_cqz);
//qDebug() << Q_FUNC_INFO << ": _ituz: " << QString::number(_ituz);
QSqlQuery query;
query.prepare("INSERT INTO prefixesofentity (prefix, dxcc, cqz, ituz) VALUES (:pref, :dxcc, :cqz, :ituz)");
@ -652,22 +673,22 @@ bool World::addPrefix(const QString &_pref, const int _dxcc, const int _cqz, con
query.bindValue(":ituz", _ituz); // ITU
if (query.exec())
{
//qDebug() << Q_FUNC_INFO << " Prefix data added OK: " << _pref ;
//qDebug() << Q_FUNC_INFO << " query: " << query.executedQuery();
//qDebug() << Q_FUNC_INFO << " query: " << query.lastQuery();
//qDebug() << Q_FUNC_INFO << " Prefix data added OK: " << _pref ;
//qDebug() << Q_FUNC_INFO << " query: " << query.executedQuery();
//qDebug() << Q_FUNC_INFO << " query: " << query.lastQuery();
return true;
}
else if (query.lastError().nativeErrorCode() == QString::number(19))
{
//qDebug() << Q_FUNC_INFO << " :Prefix data NOT added: error19: " << _pref ;
//qDebug() << Q_FUNC_INFO << " :Prefix data NOT added: error19: " << _pref ;
}
else
{
//qDebug() << Q_FUNC_INFO << " Pref data NOT added: error else: " << _pref ;
//qDebug() << Q_FUNC_INFO << " LastQuery: " << query.lastQuery() ;
//qDebug() << Q_FUNC_INFO << " LastError-data: " << query.lastError().databaseText() ;
//qDebug() << Q_FUNC_INFO << " LastError-driver: " << query.lastError().driverText() ;
//qDebug() << Q_FUNC_INFO << " LastError-n: " << query.lastError().nativeErrorCode();
//qDebug() << Q_FUNC_INFO << " Pref data NOT added: error else: " << _pref ;
//qDebug() << Q_FUNC_INFO << " LastQuery: " << query.lastQuery() ;
//qDebug() << Q_FUNC_INFO << " LastError-data: " << query.lastError().databaseText() ;
//qDebug() << Q_FUNC_INFO << " LastError-driver: " << query.lastError().driverText() ;
//qDebug() << Q_FUNC_INFO << " LastError-n: " << query.lastError().nativeErrorCode();
}
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().nativeErrorCode(), query.lastQuery());
return false;
@ -676,30 +697,30 @@ bool World::addPrefix(const QString &_pref, const int _dxcc, const int _cqz, con
bool World::readCTYCSV(const QString &_worldFile)
{
#ifdef KLOG_TESTING
//qDebug() << Q_FUNC_INFO << " - We are testing";
//qDebug() << Q_FUNC_INFO << " - We are testing";
#endif
#ifndef KLOG_TESTING
//qDebug() << Q_FUNC_INFO << " - We are NOT testing";
//qDebug() << Q_FUNC_INFO << " - We are NOT testing";
#endif
//qDebug() << Q_FUNC_INFO << _worldFile;
//qDebug() << Q_FUNC_INFO << _worldFile;
QString tq;
tq.clear();
qint64 beginingOfFile;
int numberOfLines = 0;
//qDebug() << Q_FUNC_INFO << " - 10";
//qDebug() << Q_FUNC_INFO << " - 10";
QFile file( _worldFile );
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) /* Flawfinder: ignore */
{
//qDebug() << Q_FUNC_INFO << ": File not found: END FALSE" << _worldFile;
//qDebug() << Q_FUNC_INFO << ": File not found: END FALSE" << _worldFile;
return false;
}
else
{
//qDebug() << Q_FUNC_INFO << " File found: " << _worldFile;
//qDebug() << Q_FUNC_INFO << " File found: " << _worldFile;
}
//qDebug() << Q_FUNC_INFO << " - 20";
//qDebug() << Q_FUNC_INFO << " - 20";
beginingOfFile = file.pos();
while (!file.atEnd()) {
@ -709,8 +730,8 @@ bool World::readCTYCSV(const QString &_worldFile)
}
numberOfLines++;
}
//qDebug() << Q_FUNC_INFO << " - 30";
//qDebug() << Q_FUNC_INFO << " - numberOfEntities: " << QString::number(numberOfEntities);
//qDebug() << Q_FUNC_INFO << " - 30";
//qDebug() << Q_FUNC_INFO << " - numberOfEntities: " << QString::number(numberOfEntities);
// The file is readed twice: 1: Main entity data; 2: prefixes.
// Starts with main data:
@ -721,16 +742,16 @@ bool World::readCTYCSV(const QString &_worldFile)
progress.setWindowModality(Qt::ApplicationModal);
#endif
numberOfEntities = 0; // Reset this variable to reuse it and assign the "dxcc" to the entities (temp solution)
//qDebug() << Q_FUNC_INFO << " - 40";
//qDebug() << Q_FUNC_INFO << " - 40";
// Prefixes information
//qDebug() << Q_FUNC_INFO << " - 50";
//qDebug() << Q_FUNC_INFO << " - 50";
QStringList stringList, stringListPrefixes, stringListProcessedPrefix;
int entN;
//qDebug() << Q_FUNC_INFO << " - 60";
//qDebug() << Q_FUNC_INFO << " - 60";
while (!file.atEnd()) {
#ifndef KLOG_TESTING
progress.setValue(progressBarPosition);
@ -748,18 +769,18 @@ bool World::readCTYCSV(const QString &_worldFile)
// 0 1 2 3 4 5 6 7 8 9
tq = file.readLine();
//qDebug() << Q_FUNC_INFO << " Line: " << tq;
//qDebug() << Q_FUNC_INFO << " Line: " << tq;
tq = tq.simplified();
//qDebug() << Q_FUNC_INFO << " Line simplified: " << tq;
//qDebug() << Q_FUNC_INFO << " Line simplified: " << tq;
tq = tq.trimmed();
//qDebug() << Q_FUNC_INFO << " Line trimmed: " << tq;
//qDebug() << Q_FUNC_INFO << " Line trimmed: " << tq;
tq.remove(QChar(';'), Qt::CaseInsensitive);
//qDebug() << Q_FUNC_INFO << " Line without ;: " << tq;
//qDebug() << Q_FUNC_INFO << " Line without ;: " << tq;
stringList << tq.split(',');
//qDebug() << Q_FUNC_INFO << " Line stringList-0: " << stringList.at(0);
//qDebug() << Q_FUNC_INFO << " Line stringList Length: " << QString::number(stringList.length());
//qDebug() << Q_FUNC_INFO << " Line stringList-0: " << stringList.at(0);
//qDebug() << Q_FUNC_INFO << " Line stringList Length: " << QString::number(stringList.length());
// stringList.at(9) contains an space separated list of prefixes for that entity
QString mPrefix = QString();
@ -774,8 +795,8 @@ bool World::readCTYCSV(const QString &_worldFile)
while ( (dataProxy->getEntityMainPrefix(entN)).size()>0 )
{
//qDebug() << Q_FUNC_INFO << " entN: " << QString::number(entN);
//qDebug() << Q_FUNC_INFO << " dataProxy->getEntityMainPrefix: " << QString::number(entN);
//qDebug() << Q_FUNC_INFO << " entN: " << QString::number(entN);
//qDebug() << Q_FUNC_INFO << " dataProxy->getEntityMainPrefix: " << QString::number(entN);
entN = entN + 1000;
}
entityNumber = entN;
@ -798,38 +819,38 @@ bool World::readCTYCSV(const QString &_worldFile)
bool entityAdded = addEntity(entName, cqz, ituz, contId, lat, lon, utc, entityNumber, mPrefix);
if (entityAdded)
{
//qDebug() << Q_FUNC_INFO << " Entity added: " << entName;
//qDebug() << Q_FUNC_INFO << " Entity added: " << entName;
}
else
{
//qDebug() << Q_FUNC_INFO << " Entity Not added: " << entName;
//qDebug() << Q_FUNC_INFO << " Entity Not added: " << entName;
}
if (entityAdded)
{
//qDebug() << Q_FUNC_INFO << " Let's going for the prefixes: ... if entity is not added, we should not go to the prefixes!" ;
//qDebug() << Q_FUNC_INFO << " Let's going for the prefixes: ... if entity is not added, we should not go to the prefixes!" ;
QString listOfPrefixesString = stringList.at(9);
stringListPrefixes << listOfPrefixesString.split(' ');
QString prefAux = QString();
for (int i = 0; i < stringListPrefixes.size(); ++i)
{
//qDebug() << Q_FUNC_INFO << " - 100 - " << stringListPrefixes.at(i);
//qDebug() << Q_FUNC_INFO << " - 100 - " << stringListPrefixes.at(i);
prefAux = stringListPrefixes.at(i);
//qDebug() << Q_FUNC_INFO << " - 101 - " << prefAux;
//qDebug() << Q_FUNC_INFO << " - 101 - " << prefAux;
QStringList stringListProcessedPrefix;
stringListProcessedPrefix.clear();
//qDebug() << Q_FUNC_INFO << " - 102 - " ;
//qDebug() << Q_FUNC_INFO << " - 102 - " ;
stringListProcessedPrefix << readZones (prefAux, cqz, ituz);
//qDebug() << Q_FUNC_INFO << " - 103 - " ;
//qDebug() << Q_FUNC_INFO << " - 103 - " ;
//Returns a QStringList: prefix, CQz, ITUz
bool prefixAdded = addPrefix(stringListProcessedPrefix.at(0), entityNumber, stringListProcessedPrefix.at(1).toInt(), stringListProcessedPrefix.at(2).toInt());
if (prefixAdded)
{
//qDebug() << Q_FUNC_INFO << ": Prefix added: " << stringListProcessedPrefix.at(0);
//qDebug() << Q_FUNC_INFO << ": Prefix added: " << stringListProcessedPrefix.at(0);
}
else
{
//qDebug() << Q_FUNC_INFO << ": Prefix NOT added: " << stringListProcessedPrefix.at(0);
//qDebug() << Q_FUNC_INFO << ": Prefix NOT added: " << stringListProcessedPrefix.at(0);
}
}
}
@ -838,27 +859,27 @@ bool World::readCTYCSV(const QString &_worldFile)
progress.setLabelText("Reading cty.csv ... \nNow reading " + mPrefix + " data");
#endif
#ifdef KLOG_TESTING
//qDebug() << Q_FUNC_INFO << QString("Reading cty.csv... Now reading %1").arg(mPrefix);
//qDebug() << Q_FUNC_INFO << QString("Reading cty.csv... Now reading %1").arg(mPrefix);
#endif
//qDebug() << Q_FUNC_INFO << " - progressBarPosition: " << QString::number(progressBarPosition);
//qDebug() << Q_FUNC_INFO << " - progressBarPosition: " << QString::number(progressBarPosition);
}
//qDebug() << Q_FUNC_INFO << " - 100";
//qDebug() << Q_FUNC_INFO << " - 100";
#ifndef KLOG_TESTING
progress.setValue(numberOfLines);
#endif
//qDebug() << Q_FUNC_INFO << " - 102";
//qDebug() << Q_FUNC_INFO << " - 102";
if (created)
{
//qDebug() << Q_FUNC_INFO << " - 110";
//qDebug() << Q_FUNC_INFO << " - 110";
dataProxy->updateISONames();
}
//qDebug() << Q_FUNC_INFO << " END TRUE " ;
//qDebug() << Q_FUNC_INFO << " END TRUE " ;
return true;
}
/*QStringList World::getEntitiesNames()
{
//qDebug() << "World::getEntitiesNames" ;
//qDebug() << "World::getEntitiesNames" ;
return dataProxy->getEntitiesNames();
}
*/
@ -870,7 +891,7 @@ int World::getHowManyEntities()
bool World::insertSpecialEntities()
{ //https://en.wikipedia.org/wiki/Non-ITU_prefix
//qDebug() << Q_FUNC_INFO;
//qDebug() << Q_FUNC_INFO;
// T9 to E7
// 4N & YZ to 4O
int entityID = dataProxy->getEntityIdFromMainPrefix("E7");
@ -883,7 +904,7 @@ bool World::insertSpecialEntities()
if (!sqlOK)
{
query.finish();
//qDebug() << Q_FUNC_INFO << " : T9 not added ";
//qDebug() << Q_FUNC_INFO << " : T9 not added ";
return false;
}
entityID = dataProxy->getEntityIdFromMainPrefix("4O");
@ -896,7 +917,7 @@ bool World::insertSpecialEntities()
if (!sqlOK)
{
query.finish();
//qDebug() << Q_FUNC_INFO << " : 4N not added ";
//qDebug() << Q_FUNC_INFO << " : 4N not added ";
return false;
}
queryString = QString("INSERT INTO prefixesofentity (prefix, dxcc, cqz, ituz) VALUES ('%1', '%2', '%3', '%4') ").arg("YZ").arg(entityID).arg(cqz).arg(ituz);
@ -905,16 +926,16 @@ bool World::insertSpecialEntities()
if (!sqlOK)
{
query.finish();
//qDebug() << Q_FUNC_INFO << " : YZ not added ";
//qDebug() << Q_FUNC_INFO << " : YZ not added ";
return false;
}
return true;
//qDebug() << Q_FUNC_INFO << " - END";
//qDebug() << Q_FUNC_INFO << " - END";
}
bool World::hasSpecialEntities()
{ // Checks if T9 is added to the list of prefixes to validate if special prefixes have been added.
//qDebug() << Q_FUNC_INFO;
//qDebug() << Q_FUNC_INFO;
QString queryString = QString("SELECT dxcc from prefixesofentity WHERE prefix='T9'");
QSqlQuery query;
bool sqlOK = query.exec(queryString);

View File

@ -31,6 +31,9 @@
#include "../../src/world.h"
#include "../../src/qso.h"
#include "../../src/dataproxy_sqlite.h"
#include "../../src/database/db_adif_primary_subdvisions_data.h"
#include "../../src/database/queryexecutor.h"
/*
initTestCase() will be called before the first test function is executed.
initTestCase_data() will be called to create a global test data table.

View File

@ -11,6 +11,8 @@ TEMPLATE = app
HEADERS += \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/global.h \
../../src/adif.h \
../../src/locator.h \
@ -27,6 +29,8 @@ SOURCES += tst_database.cpp \
../../src/world.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/qso.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/database.cpp
isEmpty(QMAKE_LRELEASE) {

View File

@ -13,6 +13,8 @@ HEADERS += \
../../src/utilities.h \
../../src/locator.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/klogdefinitions.h \
../../src/adif.h
@ -21,6 +23,8 @@ SOURCES += tst_dataproxy.cpp \
../../src/utilities.cpp \
../../src/locator.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/qso.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/adif.cpp

View File

@ -41,6 +41,8 @@ HEADERS += ../../src/setupdialog.h \
../../src/charts/statsgridsonsatswidget.h \
../../src/charts/statssentconfirmedpiechartwidget.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/dataproxy_sqlite.h \
../../src/downloadcty.h \
../../src/dxcluster/dxcluster.h \
@ -138,6 +140,8 @@ SOURCES += tst_main.cpp \
../../src/charts/statsgridsonsatswidget.cpp \
../../src/charts/statssentconfirmedpiechartwidget.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/downloadcty.cpp \
../../src/dxcluster/dxcluster.cpp \

View File

@ -17,7 +17,9 @@ HEADERS += \
../../src/locator.h \
../../src/klogdefinitions.h \
../../src/database.h \
../../src/adif.h
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/adif.h
SOURCES += tst_mainqsoentrywidget.cpp \
../../src/mainqsoentrywidget.cpp \
@ -26,6 +28,8 @@ SOURCES += tst_mainqsoentrywidget.cpp \
../../src/qso.cpp \
../../src/locator.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/adif.cpp

View File

@ -85,6 +85,8 @@ HEADERS += \
../../src/mainqsoentrywidget.h \
../../src/dataproxy_sqlite.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/klogdefinitions.h \
../../src/utilities.h \
../../src/qso.h \
@ -159,6 +161,8 @@ SOURCES += tst_mainwindow.cpp \
../../src/mainwindow.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/setuppages/hamlibnetworkconfigwidget.cpp \
../../src/setuppages/hamlibserialconfigwidget.cpp \
../../src/setuppages/setupentitydialog.cpp \

View File

@ -13,6 +13,8 @@ HEADERS += \
../../src/inputwidgets/mainwindowinputqso.h \
../../src/dataproxy_sqlite.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/utilities.h \
../../src/locator.h \
@ -22,6 +24,8 @@ SOURCES += tst_mainwindowinputqso.cpp \
../../src/inputwidgets/mainwindowinputqso.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/qso.cpp \
../../src/utilities.cpp \
../../src/locator.cpp \

View File

@ -25,6 +25,8 @@ HEADERS += \
../../src/locator.h \
../../src/klogdefinitions.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/adif.h
SOURCES += tst_mainwindowsattab.cpp \
@ -34,6 +36,8 @@ SOURCES += tst_mainwindowsattab.cpp \
../../src/utilities.cpp \
../../src/locator.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/adif.cpp

View File

@ -14,6 +14,8 @@ HEADERS += \
../../src/utilities.h \
../../src/dataproxy_sqlite.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/locator.h \
../../src/setuppages/setuppageelog.h \
@ -24,6 +26,8 @@ SOURCES += tst_setuppageelog.cpp \
../../src/utilities.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/qso.cpp \
../../src/locator.cpp \
../../src/setuppages/setuppageelog.cpp \

View File

@ -15,6 +15,8 @@ HEADERS += \
../../src/utilities.h \
../../src/dataproxy_sqlite.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/klogdefinitions.h \
../../src/locator.h \
@ -24,6 +26,8 @@ SOURCES += tst_utilities.cpp \
../../src/utilities.cpp \
../../src/dataproxy_sqlite.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/qso.cpp \
../../src/locator.cpp \
../../src/adif.cpp

View File

@ -14,6 +14,8 @@ HEADERS += \
../../src/locator.h \
../../src/utilities.h \
../../src/database.h \
../../src/database/queryexecutor.h \
../../src/database/db_adif_primary_subdvisions_data.h \
../../src/qso.h \
../../src/adif.h
@ -23,6 +25,8 @@ SOURCES += tst_world.cpp \
../../src/qso.cpp \
../../src/utilities.cpp \
../../src/database.cpp \
../../src/database/queryexecutor.cpp \
../../src/database/db_adif_primary_subdvisions_data.cpp \
../../src/locator.cpp \
../../src/adif.cpp