1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
/***************************************************************************
statsgridsonsatswidget.cpp - description
-------------------
begin : dec 2020
copyright : (C) 2020 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 "statsgridsonsatswidget.h"
StatsGridsOnSatsWidget::StatsGridsOnSatsWidget(DataProxy_SQLite *dp, QWidget *parent)
{
Q_UNUSED(parent);
#ifdef QT_DEBUG
//qDebug() << "StatsGridsOnSatsWidget::StatsGridsOnSatsWidget: ";
#else
#endif
dataProxy = dp;
util = new Utilities(Q_FUNC_INFO);
confirmedOnlyCheckBox = new QCheckBox;
onlyLEOSatCheckBox = new QCheckBox;
numberLabel = new QLabel;
log = -1;
createUI();
//prepareChart();
}
StatsGridsOnSatsWidget::~StatsGridsOnSatsWidget()
{
delete(util);
//delete(dataProxy);
}
void StatsGridsOnSatsWidget::createUI()
{
confirmedOnlyCheckBox->setText(tr("Show confirmed only"));
confirmedOnlyCheckBox->setChecked(false);
onlyLEOSatCheckBox->setText(tr("Only LEO sats", "LEO means Low Earth Orbiting and it is a well known word for hams. Do not translate if not sure."));
onlyLEOSatCheckBox->setChecked(false);
tableWidget = new QTableWidget(this);
tableWidget->setRowCount(0);
tableWidget->setColumnCount(7);
tableWidget->resizeRowsToContents();
//tableWidget->sortByColumn(4, Qt::AscendingOrder);
//void QTableWidget::sortItems(int column, Qt::SortOrder order = Qt::AscendingOrder)
tableWidget->horizontalHeader()->setStretchLastSection(true);
QLabel *textLabel = new QLabel;
textLabel->setText(tr("Number"));
textLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
numberLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
numberLabel->setText(QString::number(0));
QHBoxLayout *labelLayout = new QHBoxLayout;
labelLayout->addWidget(textLabel);
labelLayout->addWidget(numberLabel);
QHBoxLayout *checksLayout = new QHBoxLayout;
checksLayout->addWidget(confirmedOnlyCheckBox);
checksLayout->addWidget(onlyLEOSatCheckBox);
checksLayout->addLayout(labelLayout);
QVBoxLayout *layout = new QVBoxLayout;
layout->addLayout(checksLayout);
layout->addWidget(tableWidget);
setLayout(layout);
connect(confirmedOnlyCheckBox, SIGNAL(clicked()), this, SLOT(slotConfirmedClicked() ) );
connect(onlyLEOSatCheckBox, SIGNAL(clicked()), this, SLOT(slotConfirmedClicked() ) );
}
void StatsGridsOnSatsWidget::prepareChart(const int _log)
{
//qDebug() << Q_FUNC_INFO << "Log = " << QString::number(_log);
while(tableWidget->rowCount()>0)
{
tableWidget->removeRow(tableWidget->rowCount()-1);
}
log = _log;
QList<QSO*> _qsos;
_qsos.clear();
_qsos << dataProxy->getSatGridStats(log);
tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Callsign")));
tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Date")));
tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Band")));
tableWidget->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("Mode")));
tableWidget->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("Grid")));
tableWidget->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Satellite")));
tableWidget->setHorizontalHeaderItem(6, new QTableWidgetItem(tr("Confirmed")));
tableWidget->setStyleSheet("QHeaderView::section { background-color:cornflowerblue }");
//qDebug() << "StatsGridsOnSatsWidget::prepareChart: QSOs: " << QString::number(_qsos.length());
int number = 0;
QStringList grids;
grids.clear();
if (!_qsos.isEmpty())
{
for (int i = 0; i<_qsos.length(); i++)
{
bool confirmed = false;
bool printThisOne = true;
QString satName = _qsos.at(i)->getSatName();
QString qslStatus = QString();
if (_qsos.at(i)->getLoTWQSL_RCVD() == "Y")
{
qslStatus = "LoTW";
confirmed = true;
}
else if (_qsos.at(i)->getQSL_RCVD() == "Y")
{
qslStatus = "QSL";
confirmed = true;
}
else
{
qslStatus = QString(tr("No"));
confirmed = false;
}
if (confirmedOnlyCheckBox->isChecked() && !confirmed)
{
printThisOne = false;
}
if ((onlyLEOSatCheckBox->isChecked()) && (satName == "QO-100") )
{
printThisOne = false;
}
if (grids.contains((_qsos.at(i)->getGridSquare()).left(4)))
{
printThisOne = false;
}
if (printThisOne)
{
grids.append((_qsos.at(i)->getGridSquare()).left(4));
number++;
tableWidget->insertRow(tableWidget->rowCount());
tableWidget->setItem(tableWidget->rowCount()-1, 0, new QTableWidgetItem((_qsos.at(i)->getCall())) );
tableWidget->setItem(tableWidget->rowCount()-1, 1, new QTableWidgetItem( util->getDateSQLiteStringFromDate(_qsos.at(i)->getDate()) ) );
tableWidget->setItem(tableWidget->rowCount()-1, 2, new QTableWidgetItem((_qsos.at(i)->getBand())) );
tableWidget->setItem(tableWidget->rowCount()-1, 3, new QTableWidgetItem((_qsos.at(i)->getMode())) );
tableWidget->setItem(tableWidget->rowCount()-1, 4, new QTableWidgetItem((_qsos.at(i)->getGridSquare()).left(4)) );
tableWidget->setItem(tableWidget->rowCount()-1, 5, new QTableWidgetItem(satName));
tableWidget->setItem(tableWidget->rowCount()-1, 6, new QTableWidgetItem(qslStatus) );
}
}
numberLabel->setText(QString::number(number));
}
tableWidget->sortItems(4, Qt::AscendingOrder);
}
void StatsGridsOnSatsWidget::slotConfirmedClicked()
{
prepareChart(log);
}
|