Merge branch 'master' into coverity_scan

This commit is contained in:
ea4k 2022-04-14 22:54:11 +02:00 committed by GitHub
commit 896a1beb7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 512 deletions

View File

@ -43,3 +43,6 @@ matrix:
script:
- make
after_success:
- coveralls --exclude lib --exclude tests --gcov-options '\-lp'

View File

@ -1,3 +0,0 @@
files:
- source: /src/translations/
translation: /src/translations/klog_%two_letters_code%.ts

View File

@ -1,3 +1,4 @@
TBD - 2.2
- Bugfix: Clublog QSO status export to file was not properly done.
- Improvement: General code cleaning (coveralls.io)

View File

@ -62,6 +62,19 @@ void FileManager::init()
dbCreated = false;
rstTXDefault = false;
rstRXDefault = false;
duplicatedQSOSlotInSecs = 0;
sendEQSLByDefault = false;
db = new DataBase(Q_FUNC_INFO, klogVersion, util->getKLogDBFile());
klogVersion = _softVersion;
//dataProxyPrepared = new DataProxy_SQLite(klogVersion);
klogDir = _klogDir;
ignoreUnknownAlways = false;
usePreviousStationCallsignAnswerAlways = false;
world = new World(dataProxy, klogDir, Q_FUNC_INFO);
awards = new Awards(dataProxy, Q_FUNC_INFO);
noMoreQso = false;
hashLogs.clear();
util->setVersion(klogVersion);

View File

@ -1,70 +0,0 @@
#ifndef KLOGDEFINITIONS_H
#define KLOGDEFINITIONS_H
/***************************************************************************
klogdefinitions.h - description
-------------------
begin : oct 2020
copyright : (C) 2020 by Jaime Robles
user : 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 <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include <QString>
enum ExportMode {ModeLotW, ModeADIF, ModeClubLog, ModeEQSL, ModeQRZ};
enum OnLineProvider {ClubLog, LoTW, eQSL, QRZ}; //, HamQTH, HRDLog
enum OnlineErrorCode {Ok, Fail};
enum OnlineErrorReason {Other, Auth, DupeQSO, WrongLogBook};
enum DebugLogLevel {Info, Debug};
enum ValidFieldsForStats {DXCC, GridSquare};
struct EntityData { // Used to pass a list of data from World to dxccstatuswidget
int dxcc;
QString mainprefix;
QString name;
QString isoname;
};
struct EntityBandStatus { // Used to pass a list of data from Awards to dxccstatuswidget
int dxcc;
int bandid;
bool confirmed;
};
extern bool callsignCheck;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 2))
#define QT_SKIP Qt::SkipEmptyParts
#define QT_ENDL Qt::endl
#define QT_RETURNBYVALUE Qt::ReturnByValue
#else
#define QT_SKIP QString::SkipEmptyParts
#define QT_ENDL endl
#define QT_RETURNBYVALUE
#endif
#if QT_VERSION>=0x041502
#else
#endif
#endif // KLOGDEFINITIONS_H

View File

@ -154,6 +154,7 @@ MainWindow::MainWindow(const QString &_klogDir, const QString &tversion)
//qDebug() << Q_FUNC_INFO << ": 51: " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
setupDialog = new SetupDialog(dataProxy, this);
//qDebug() << Q_FUNC_INFO << ": satTabWidget to be created " << QT_ENDL;
satTabWidget = new MainWindowSatTab(dataProxy);
//qDebug() << Q_FUNC_INFO << ": 52: " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
@ -186,6 +187,7 @@ MainWindow::MainWindow(const QString &_klogDir, const QString &tversion)
//qDebug() << Q_FUNC_INFO << ": dxclusterwidget to be created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
//dxClusterWidget = new DXClusterWidget(dataProxy, dxclusterServerToConnect , dxclusterServerPort, this);
dxClusterWidget = new DXClusterWidget(dataProxy, this);
//qDebug() << Q_FUNC_INFO << ": Awards to be created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
awards = new Awards(dataProxy, Q_FUNC_INFO);
//qDebug() << Q_FUNC_INFO << ": Awards created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
@ -200,7 +202,9 @@ MainWindow::MainWindow(const QString &_klogDir, const QString &tversion)
//qDebug() << Q_FUNC_INFO << ": Software update to be created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
softUpdate = new SoftwareUpdate(softwareVersion);
//qDebug() << Q_FUNC_INFO << ": FileManager to be created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
filemanager = new FileManager(dataProxy);
//qDebug() << Q_FUNC_INFO << ": FileAwardManager to be created " << QTime::currentTime().toString("hh:mm:ss") << QT_ENDL;
fileAwardManager = new FileAwardManager(dataProxy, Q_FUNC_INFO);
@ -314,6 +318,7 @@ void MainWindow::init()
debugFileOpen = true;
logEvent(Q_FUNC_INFO, "KLog started!", Info);
}
configFileName = util->getCfgFile();
setupDialog->init(configFileName, softwareVersion, 0, !configured);
filemanager->init();
@ -8725,8 +8730,10 @@ void MainWindow::logEvent(const QString &_func, const QString &_msg, const Debug
// return;
// }
//Criticality
if (!debugFile->open(QIODevice::WriteOnly | QIODevice::Text)) /* Flawfinder: ignore */
//if (!debugFileOpen)
{
return;
}

View File

@ -141,6 +141,11 @@ void SetupDialog::init(const QString &_configFile, const QString &_softwareVersi
}
//qDebug() << Q_FUNC_INFO << ": 5.3" << QT_ENDL;
nolog = !(haveAtleastOneLog());
connect(closeButton, SIGNAL(clicked()), this, SLOT(slotCancelButtonClicked()));
connect(okButton, SIGNAL(clicked()), this, SLOT(slotOkButtonClicked()));
connectActions();
//qDebug() << Q_FUNC_INFO << " - END" << QT_ENDL;
}
SetupDialog::~SetupDialog()

View File

@ -9,7 +9,9 @@ HamLibSerialConfigWidget::HamLibSerialConfigWidget(QWidget *parent) : QWidget(pa
flowControlComboBox = new QComboBox();
parityComboBox = new QComboBox();
stopBitsComboBox = new QComboBox();
scanSerialPortButton = new QPushButton();
//qDebug() << Q_FUNC_INFO << " - END";
}

View File

@ -1,351 +0,0 @@
/***************************************************************************
worldmapwidget.cpp - description
-------------------
begin : oct 2019
copyright : (C) 2019 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 <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include "worldmapwidget.h"
WorldMapWidget::WorldMapWidget() // : mapLabel (new QLabel), scrollArea (new QScrollArea), scaleFactor(1)
{
//qDebug() << "WorldMapWidget::WorldMapWidget" << QT_ENDL;
scrollArea = new QScrollArea;
mapQImage = new QImage;
setWindowTitle(tr("World map"));
//setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
width = 0;
height = 0;
createActions();
mapLabel = new QLabel();
mapLabel->setBackgroundRole(QPalette::Base);
mapLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
mapLabel->setScaledContents(true);
//mapLabel->setPixmap(QPixmap::fromImage(*mapQImage));
mapLabel->setWordWrap(true);
scrollArea->setBackgroundRole(QPalette::Dark);
scrollArea->setWidget(mapLabel);
scrollArea->setVisible(false);
setCentralWidget(scrollArea);
loadMap();
//drawLocators();
//QVBoxLayout *layout = new QVBoxLayout(this);
//layout->setSizeConstraint(QLayout::SetFixedSize);
//layout->addWidget(mapLabel);
//setLayout(layout);
//qDebug() << "WorldMapWidget::WorldMapWidget - END" << QT_ENDL;
}
WorldMapWidget::~WorldMapWidget()
{
//qDebug() << "WorldMapWidget::~WorldMapWidget" << QT_ENDL;
}
void WorldMapWidget::loadMap()
{
//qDebug() << "WorldMapWidget::loadMap" << QT_ENDL;
mapQImage->load(":/img/worldmap.j");
*mapQImage = mapQImage->convertToFormat(QImage::Format_RGB32);
//qDebug() << "WorldMapWidget::loadMap-10" << QT_ENDL;
//mapLabel->setPixmap(QPixmap::fromImage(*mapQImage));
//mapLabel->setWordWrap(true);
//qDebug() << "WorldMapWidget::loadMap-11" << QT_ENDL;
scaleFactor = 1.0;
//qDebug() << "WorldMapWidget::loadMap-12" << QT_ENDL;
fitToWindowAct->setEnabled(true);
//qDebug() << "WorldMapWidget::loadMap-13" << QT_ENDL;
updateActions();
//qDebug() << "WorldMapWidget::loadMap-14" << QT_ENDL;
// mapNormalizeSize();
if (!fitToWindowAct->isChecked())
{
mapLabel->adjustSize();
}
//qDebug() << "WorldMapWidget::loadMap-15" << QT_ENDL;
width = mapQImage->width();
height = mapQImage->height();
setImage(*mapQImage);
//qDebug() << "WorldMapWidget::loadMap-Size: " << QString::number(mapQImage->width()) <<"/" << QString::number(mapQImage->height()) << QT_ENDL;
//*mapQImage = mapQImage->scaledToWidth(1260);
//qDebug() << "WorldMapWidget::loadMap-reSize: " << QString::number(mapQImage->width()) <<"/" << QString::number(mapQImage->height()) << QT_ENDL;
}
void WorldMapWidget::drawLocator(const int _x, const int _y, const int _width, const int _height, const bool _confirmed)
{
//qDebug() << "WorldMapWidget::drawLocator: " << QString::number(_x) << QString::number(_y) << QString::number(_width) << QString::number(_height) << QT_ENDL;
QPainter qPainter(mapQImage);
//qPainter.setBrush(Qt::Dense4Pattern);
qPainter.setBrush(Qt::NoBrush);
if (_confirmed)
{
qPainter.setPen(Qt::green);
}
else
{
qPainter.setPen(Qt::red);
}
QPen pen(Qt::green);
pen.setWidth(1);
qPainter.setPen(pen);
qPainter.drawRect(_x,_y,_width,_height);
qPainter.end();
setImage(*mapQImage);
//qDebug() << "WorldMapWidget::drawLocator-END" << QT_ENDL;
}
void WorldMapWidget::drawLocatorText (const int _x, const int _y, const QString &loc, const bool _confirmed)
{
//qDebug() << "WorldMapWidget::Text" << QT_ENDL;
QPainter qPainter(mapQImage);
qPainter.setFont(QFont("Arial", 12, QFont::Bold));
if (_confirmed)
{
qPainter.setPen(Qt::green);
}
else
{
qPainter.setPen(Qt::red);
}
qPainter.drawText(_x+2,_y-2, loc);
qPainter.end();
setImage(*mapQImage);
//qDebug() << "WorldMapWidget::Text-END" << QT_ENDL;
}
void WorldMapWidget::drawLocators()
{
//qDebug() << "WorldMapWidget::drawLocators" << QT_ENDL;
if (width < 18 || height < 18)
{
return;
}
int x1, y1;
for (int i = 0; i < 180; i++)
{
for (int j = 0; j < 180; j++)
{
x1 = (i * (width / 180));
y1 = height - ((1+j) * (height / 180));
//qDebug() << "WorldMapWidget::drawLocators: " << QString::number(x1) << "/" << QString::number(y1) << "/" <<QString::number(width/18) << "/" << QString::number(height/18) << QT_ENDL;
//drawLocator(x1, y1, width/180, height/180, false);
drawLines(x1, y1);
//drawLocatorText(x1, y1+(height/18), QString(QChar(i+'A')) + QString(QChar(j+'A')), false);
}
}
setImage(*mapQImage);
//qDebug() << "WorldMapWidget::drawLocators-END" << QT_ENDL;
}
void WorldMapWidget::drawLines(const int _x, const int _y)
{
QPainter qPainter(mapQImage);
//qPainter.setBrush(Qt::Dense4Pattern);
qPainter.setBrush(Qt::NoBrush);
QPen pen(Qt::green, 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin);
//pen.setWidth(1);
qPainter.setPen(pen);
// Horizontal
qPainter.drawLine(0, _y, width, _y);
qPainter.drawLine(_x, 0, _x, height);
//qPainter.drawRect(_x,_y,_width,_height);
qPainter.end();
//setImage(*mapQImage);
}
void WorldMapWidget::slotZoomIn()
{
scaleImage(1.25);
}
void WorldMapWidget::slotZoomOut()
{
scaleImage(0.8);
}
void WorldMapWidget::slotFitToWindow()
{
bool fitToWindow = fitToWindowAct->isChecked();
scrollArea->setWidgetResizable(fitToWindow);
if(fitToWindow)
slotNormalSize();
updateActions();
}
void WorldMapWidget::slotNormalSize()
{
mapLabel->adjustSize();
scaleFactor = 1.0;
}
void WorldMapWidget::createActions()
{
QMenu *viewMenu = menuBar()->addMenu(tr("View"));
zoomInAct = viewMenu->addAction(tr("Zoom In(25%)"), this, &WorldMapWidget::slotZoomIn);
zoomInAct->setShortcut(QKeySequence::ZoomIn);
zoomInAct->setEnabled(false);
zoomOutAct = viewMenu->addAction(tr("Zoom Out(25%)"), this, &WorldMapWidget::slotZoomOut);
zoomOutAct->setShortcut(QKeySequence::ZoomOut);
zoomOutAct->setEnabled(false);
normalSizeAct = viewMenu->addAction(tr("Normal Size"), this, &WorldMapWidget::slotNormalSize);
normalSizeAct->setEnabled(false);
fitToWindowAct = viewMenu->addAction(tr("Fit to window"), this, &WorldMapWidget::slotFitToWindow);
fitToWindowAct->setEnabled(false);
}
void WorldMapWidget::setImage (const QImage &newImage)
{
*mapQImage = newImage;
mapLabel->setPixmap(QPixmap::fromImage(*mapQImage));
scaleFactor = 1.0;
scrollArea->setVisible(true);
fitToWindowAct->setEnabled(true);
updateActions();
if (!fitToWindowAct->isChecked())
mapLabel->adjustSize();
}
void WorldMapWidget::updateActions()
{
zoomInAct->setEnabled(!fitToWindowAct->isChecked());
zoomOutAct->setEnabled(!fitToWindowAct->isChecked());
normalSizeAct->setEnabled(!fitToWindowAct->isChecked());
}
void WorldMapWidget::scaleImage(double factor)
{
//Q_ASSERT(mapLabel->pixmap(Qt::ReturnByValue));
scaleFactor *= factor;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 2))
mapLabel->resize(scaleFactor * mapLabel->pixmap(Qt::ReturnByValue).size());
#else
mapLabel->resize(scaleFactor * mapLabel->pixmap()->size());
#endif
//mapLabel->resize(scaleFactor * mapLabel->pixmap(QT_RETURNBYVALUE)->size());
adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
adjustScrollBar(scrollArea->verticalScrollBar(), factor);
zoomInAct->setEnabled(scaleFactor < 15.0);
zoomOutAct->setEnabled(scaleFactor > 0.333);
}
void WorldMapWidget::adjustScrollBar(QScrollBar *scrollbar, double factor)
{
scrollbar->setValue(int(factor * scrollbar->value() + ((factor -1) * scrollbar->pageStep()/2)));
}
QRect WorldMapWidget::getScreenResolution()
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->geometry();
}
void WorldMapWidget::mapNormalizeSize()
{
int _xMax = (getScreenResolution()).height();
int mapWidth;
/*
if (_xMax < 640)
{
mapWidth = 360;
}
else if ((_xMax >= 640) && (_xMax < 1024))
{
mapWidth = 450;
}
else if ((_xMax >= 1024) && (_xMax < 1440))
{
mapWidth = 810;
}
else if ((_xMax >= 1440) && (_xMax < 2048))
{
mapWidth = 1080;
}
else
{
mapWidth = 1350;
}
*/
if (_xMax < 600)
{
mapWidth = 360;
}
else if ((_xMax >= 600) && (_xMax < 960))
{
mapWidth = 450;
}
else if ((_xMax >= 960) && (_xMax < 1080))
{
mapWidth = 810;
}
else if ((_xMax >= 1080) && (_xMax < 1536))
{
mapWidth = 1080;
}
else
{
mapWidth = 1350;
}
*mapQImage = mapQImage->scaledToHeight(mapWidth);
//qDebug() << "WorldMapWidget::mapNormalizeSize: Screen: " << QString::number(_xMax) << QT_ENDL;
//qDebug() << "WorldMapWidget::mapNormalizeSize: Map: " << QString::number(mapWidth) << QT_ENDL;
}

View File

@ -1,88 +0,0 @@
#ifndef WORLDMAPWIDGET_H
#define WORLDMAPWIDGET_H
/***************************************************************************
worldmapwidget.h - description
-------------------
begin : oct 2019
copyright : (C) 2019 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 <https://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include <QtWidgets>
#include <QWidget>
//#include <QTextBrowser>
#include "klogdefinitions.h"
class QMenu;
class QScrollArea;
class QScrollBar;
class QAction;
class QLabel;
class WorldMapWidget: public QMainWindow
{
Q_OBJECT
public:
WorldMapWidget();
~WorldMapWidget();
void loadMap();
//void setText(const QString txt);
private slots:
//void slotAcceptButtonClicked();
void slotZoomIn();
void slotZoomOut();
void slotNormalSize();
void slotFitToWindow();
private:
//void loadMap();
void drawLocators();
void drawLocator(const int _x, const int _y, const int _width,const int _height, const bool _confirmed);
void drawLocatorText (const int _x, const int _y, const QString &loc, const bool _confirmed);
void drawLines(const int _x, const int _y);
void setImage (const QImage &newImage);
void updateActions();
void createActions();
void scaleImage(double factor);
void adjustScrollBar(QScrollBar *scrollbar, double factor);
QRect getScreenResolution();
void mapNormalizeSize();
//void keyPressEvent(QKeyEvent *event);
//QTextBrowser *textBrowser;
//QString text;
QScrollArea *scrollArea;
QLabel *mapLabel;
QImage *mapQImage;
int width, height;
double scaleFactor;
QAction *zoomInAct;
QAction *zoomOutAct;
QAction *fitToWindowAct;
QAction *normalSizeAct;
};
#endif // WorldMapWidget_H