Skip to content

Commit af4f278

Browse files
committed
Closes ea4k#641, ea4k#690
1 parent d6e8453 commit af4f278

File tree

7 files changed

+123
-45
lines changed

7 files changed

+123
-45
lines changed

src/Changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
WIP: Order of Logview columns
2+
BUG: Setup logview fields are added to the setup creating an infinite list
13
WIP: QSOs are not shown for LOTW upload
24
TODO: Colors when darkMode
35
AI: add sub-issues in github one per class that is not working properly
@@ -21,6 +23,7 @@ TODO: Reuse the bool World::insertPrefixes to read QSOs from a file so we can in
2123
TODO: After update, it is needed to restart KLog to be able to use the primary subdivisions
2224
TODO-Bug: Review void tst_MainWindowInputQSO::test_GridLineEdit()
2325

26+
2427
WIP: Try to optimize bool DataProxy_SQLite::fillEmptyDXCCInTheLog()
2528
WIP: - Bugfix: DB in alternative locations was not always found. (WIP #706)
2629

@@ -43,6 +46,8 @@ Close: #396, #507, #508
4346

4447

4548
TBD - 2.4
49+
- Enhancement: Button without text label in message box. (Closes #641)
50+
- Enhancement: Refactor DataProxy_SQLite::addSatellite (Closes #690)
4651
- Enhancement: New DXCluster UI
4752
- Enhancement: Ported from Qt5 to Qt6.
4853
- Enhancement: Refactoring of several classes.

src/dataproxy_sqlite.cpp

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,32 +4232,38 @@ bool DataProxy_SQLite::clearSatList()
42324232

42334233
bool DataProxy_SQLite::addSatellite(const QString &_arrlId, const QString &_name, const QString &_downLink, const QString &_upLink, const QString &_mode, int id)
42344234
{
4235-
//qDebug() <<Q_FUNC_INFO << " - " << QString::number(id) ;
42364235
QSqlQuery query;
42374236
QString queryString;
42384237

4239-
if (id>0)
4238+
if (id > 0)
42404239
{
4241-
queryString = QString("UPDATE satellites set satarrlid = '%1', satname = '%2', uplink = '%3', downlink = '%4', satmode = '%5' WHERE id = '%6'").arg(_arrlId).arg(_name).arg(_upLink).arg(_downLink).arg(_mode).arg(id);
4240+
queryString = QString(
4241+
"UPDATE satellites SET satarrlid = :arrlId, satname = :name, uplink = :upLink, downlink = :downLink, satmode = :mode WHERE id = :id"
4242+
);
4243+
query.prepare(queryString);
4244+
query.bindValue(":id", id);
42424245
}
42434246
else
42444247
{
4245-
queryString = QString("INSERT INTO satellites (satarrlid, satname, uplink, downlink, satmode) VALUES ('%1', '%2', '%3', '%4', '%5')").arg(_arrlId).arg(_name).arg(_upLink).arg(_downLink).arg(_mode);
4248+
queryString = QString(
4249+
"INSERT INTO satellites (satarrlid, satname, uplink, downlink, satmode) VALUES (:arrlId, :name, :upLink, :downLink, :mode)"
4250+
);
4251+
query.prepare(queryString);
42464252
}
42474253

4248-
bool sqlOK = query.exec(queryString);
4249-
//qDebug() << Q_FUNC_INFO << " - - query: " << query.lastQuery();
4254+
query.bindValue(":arrlId", _arrlId);
4255+
query.bindValue(":name", _name);
4256+
query.bindValue(":upLink", _upLink);
4257+
query.bindValue(":downLink", _downLink);
4258+
query.bindValue(":mode", _mode);
42504259

4251-
if (sqlOK)
4260+
if (query.exec())
42524261
{
4253-
//qDebug() << Q_FUNC_INFO << " - - TRUE" ;
4254-
//qDebug() << Q_FUNC_INFO << " - - TRUE - ERROR: " << QString::number(query.lastError().text());
42554262
query.finish();
42564263
return true;
42574264
}
42584265
else
42594266
{
4260-
//qDebug() << Q_FUNC_INFO << " - - FALSE" ;
42614267
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
42624268
query.finish();
42634269
return false;
@@ -4266,34 +4272,30 @@ bool DataProxy_SQLite::addSatellite(const QString &_arrlId, const QString &_name
42664272

42674273
int DataProxy_SQLite::getDBSatId(const QString &_arrlId)
42684274
{
4269-
//qDebug() << Q_FUNC_INFO << " - " << _arrlId;
42704275
int aux = -1;
4271-
QString queryString = QString("SELECT id FROM satellites WHERE satarrlid='%1'").arg(_arrlId);
4272-
QSqlQuery query;
4276+
QSqlQuery query;
4277+
QString queryString = "SELECT id FROM satellites WHERE satarrlid=:arrlId";
42734278

4274-
bool sqlOK = query.exec(queryString);
4279+
query.prepare(queryString);
4280+
query.bindValue(":arrlId", _arrlId);
42754281

4276-
if (sqlOK)
4277-
{
4278-
query.next();
4279-
if (query.isValid())
4280-
{
4281-
aux = query.value(0).toInt();
4282-
}
4283-
else
4284-
{
4285-
//qDebug() << Q_FUNC_INFO << " - query not valid" ;
4286-
query.finish();
4287-
}
4288-
}
4289-
else
4290-
{
4291-
//qDebug() << Q_FUNC_INFO << ": query failed: " << query.lastQuery() ;
4292-
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
4293-
query.finish();
4294-
}
4282+
if (query.exec())
4283+
{
4284+
if (query.next())
4285+
{
4286+
aux = query.value(0).toInt();
4287+
}
4288+
else
4289+
{
4290+
query.finish();
4291+
}
4292+
}
4293+
else
4294+
{
4295+
emit queryError(Q_FUNC_INFO, query.lastError().databaseText(), query.lastError().text(), query.lastQuery());
4296+
query.finish();
4297+
}
42954298

4296-
//qDebug() << ":: final: " << aux ;
42974299
query.finish();
42984300
return aux;
42994301
}

src/inputwidgets/mainwindowinputothers.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ MainWindowInputOthers::MainWindowInputOthers(DataProxy_SQLite *dp, QWidget *pare
5656
// TODO: I should find the way to connect the SAT tabwidget's signal to set the propmode in this widget
5757
// Now it is done though the mainwindow but I should avoid depending on that class for that, if possible
5858
//connect(satTabWidget, SIGNAL(setPropModeSat(QString)), this, SLOT(slotSetPropMode(QString)) ) ;
59+
connect(entityNameComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEntityNameComboBoxChanged() ) ) ;
5960
connect(propModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotPropModeComboBoxChanged() ) ) ;
6061
connect(userDefinedADIFComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUSerDefinedADIFComboBoxChanged() ) ) ;
6162
connect(userDefinedADIFValueLineEdit, SIGNAL(textChanged(QString)), this, SLOT(slotSetCurrentUserData() ) );
@@ -792,7 +793,7 @@ void MainWindowInputOthers::setEntity(const int _entity)
792793

793794
void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString &_qrz)
794795
{
795-
//qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_entity) << "/" << _qrz;
796+
//qDebug() << Q_FUNC_INFO << " - Start: " << QString::number(_entity) << "/" << _qrz;
796797
if (_entity<=0)
797798
{
798799
//qDebug() << Q_FUNC_INFO << " - 10";
@@ -831,7 +832,7 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString
831832
if ((hostFullPrefix.isEmpty()) && (hostPrefix.isEmpty()))
832833
return;
833834

834-
//qDebug() << Q_FUNC_INFO << " - 40";
835+
//qDebug() << Q_FUNC_INFO << " - 40";
835836
QList<PrimarySubdivision> primarySubdivisions;
836837
primarySubdivisions.clear();
837838

@@ -864,7 +865,11 @@ void MainWindowInputOthers::setEntityAndPrefix(const int _entity, const QString
864865
//qDebug() << Q_FUNC_INFO << " - 60";
865866
//qDebug() << Q_FUNC_INFO << " - count: " << QString::number(primarySubdivisions.count());
866867
if (primarySubdivisions.isEmpty())
868+
{
869+
entityPrimDivComboBox->clear();
867870
return;
871+
}
872+
868873
//qDebug() << Q_FUNC_INFO << " - 70 ";
869874
updatePrimarySubdivisionsComboBox(primarySubdivisions);
870875
//qDebug() << Q_FUNC_INFO << " - END";
@@ -1082,6 +1087,16 @@ void MainWindowInputOthers::slotShowAllCheckBoxChanged()
10821087
setEntityAndPrefix(currentInt, currentPref);
10831088
}
10841089

1090+
void MainWindowInputOthers::slotEntityNameComboBoxChanged()
1091+
{
1092+
//qDebug() << Q_FUNC_INFO << entityNameComboBox->currentText();
1093+
QString prefix = ((entityNameComboBox->currentText()).split("-")).at(0);
1094+
//qDebug() << Q_FUNC_INFO << " - " << prefix;
1095+
int entity = world->getQRZARRLId(prefix);
1096+
setEntityAndPrefix(entity, prefix);
1097+
//entityPrimDivComboBox->clear();
1098+
entityPrimDivComboBox->addItem("00-" + tr("None Identified") + " (000)");
1099+
}
10851100

10861101

10871102
bool MainWindowInputOthers::getDarkMode()

src/inputwidgets/mainwindowinputothers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ private slots:
108108
void slotSetCurrentUserData();
109109
void slotPrimarySubdivisionsComboBoxChanged();
110110
void slotShowAllCheckBoxChanged();
111+
void slotEntityNameComboBoxChanged();
111112

112113

113114
private:

src/logwindow.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,28 @@ void LogWindow::createUI()
8989
logView->horizontalHeader ()->setSectionsMovable (true);
9090
//logView->setDragDropMode (QAbstractItemView::InternalMove);
9191
//logView->setDropIndicatorShown (true);
92+
//retoreColumsOrder();
9293

9394
QVBoxLayout *layout = new QVBoxLayout;
9495
layout->addWidget(logView);
9596
setLayout(layout);
9697
}
9798

99+
void LogWindow::retoreColumsOrder()
100+
{
101+
// Restore the column order from the settings
102+
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
103+
settings.beginGroup("LogWindow");
104+
QList<int> columnOrder = settings.value("columnOrder").value<QList<int>>();
105+
settings.endGroup();
106+
107+
if (!columnOrder.isEmpty()) {
108+
for (int i = 0; i < columnOrder.size(); ++i) {
109+
logView->horizontalHeader()->moveSection(logView->horizontalHeader()->visualIndex(columnOrder[i]), i);
110+
}
111+
}
112+
}
113+
98114
void LogWindow::setDefaultData()
99115
{
100116
//qDebug() << Q_FUNC_INFO << " - Start";
@@ -226,6 +242,8 @@ void LogWindow::createActionsCommon()
226242
//LOG VIEW
227243
connect(logView, SIGNAL(customContextMenuRequested( const QPoint& ) ), this, SLOT(slotRighButtonFromLog( const QPoint& ) ) );
228244
connect(logView, SIGNAL(doubleClicked ( const QModelIndex& ) ), this, SLOT(slotDoubleClickLog( const QModelIndex& ) ) );
245+
connect(logView->horizontalHeader(), &QHeaderView::sectionMoved, this, &LogWindow::slotOnSectionMoved);
246+
229247
//qDebug() << Q_FUNC_INFO << " - END";
230248
}
231249

@@ -751,3 +769,22 @@ void LogWindow::slotCheckDXHeatCom()
751769
//qDebug() << Q_FUNC_INFO << " - END";
752770
}
753771

772+
void LogWindow::slotOnSectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex)
773+
{
774+
Q_UNUSED(logicalIndex);
775+
Q_UNUSED(oldVisualIndex);
776+
Q_UNUSED(newVisualIndex);
777+
778+
// Get the current column order
779+
QList<int> columnOrder;
780+
for (int i = 0; i < logView->model()->columnCount(); ++i) {
781+
columnOrder << logView->horizontalHeader()->visualIndex(i);
782+
}
783+
784+
785+
QSettings settings(util->getCfgFile (), QSettings::IniFormat);
786+
settings.beginGroup("LogWindow");
787+
settings.setValue("ColumnOrder", QVariant::fromValue(columnOrder));
788+
settings.endGroup();
789+
}
790+

src/logwindow.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ private slots:
107107
void slotMultipleQSLRecViaBureauFromLog();
108108
void slotMultipleQSLRecViaDirectFromLog();
109109
void slotQSOsQRZUploadFromLog();
110+
void slotOnSectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
110111

111112
private:
112113
void createUI();
113114
void createActionsCommon();
114115
void createActions();
115-
116+
void retoreColumsOrder();
116117
void deleteQSO(const int _qsoID);
117118
void rightButtonFromLogMenu(const int trow);
118119
void rightButtonMultipleFromLogMenu();

src/mainwindow.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,24 +1172,41 @@ int MainWindow::checkDXCCBeforeAddingToLog(const int dxcc_Call, const int dxcc_q
11721172
{
11731173
if (dxcc_Call!=dxcc_qso)
11741174
{
1175-
QString dxcc1_name = world->getEntityName(dxcc_Call);
1176-
dxcc1_name = dxcc1_name + " - " + world->getEntityMainPrefix(dxcc_Call);
1175+
QString dxcc1_name = world->getEntityName(dxcc_Call);
1176+
QString dxcc1_prefix = world->getEntityMainPrefix(dxcc_Call);
11771177

1178-
QString dxcc_qso_name = world->getEntityName(dxcc_qso);
1179-
dxcc_qso_name = dxcc_qso_name + " - " + world->getEntityMainPrefix(dxcc_qso);
1178+
QString dxcc2_name = world->getEntityName(dxcc_qso);
1179+
QString dxcc2_prefix = world->getEntityMainPrefix(dxcc_qso);
1180+
1181+
QString message = QString(tr("The entity that is selected is different from the one proposed by KLog:") + "\n\n");
1182+
1183+
QString message_dxcc_qso = dxcc1_prefix + " - " + dxcc1_name + "\n\n";
1184+
if (dxcc1_prefix.length()<1)
1185+
{
1186+
dxcc1_prefix = tr ("Unknown", "Keep it short, its a button text");
1187+
message_dxcc_qso = QString(tr("- There is no selected DXCC.") + "\n\n");
1188+
}
1189+
1190+
QString message_dxcc_klog = dxcc2_prefix + " - " + dxcc2_name;
1191+
if (dxcc2_prefix.length()<1)
1192+
{
1193+
dxcc2_prefix = tr ("Unknown", "Keep it short, its a button text");
1194+
message_dxcc_klog = QString (tr("- KLog couldn't find a DXCC") + "\n\n");
1195+
}
1196+
1197+
message = message + message_dxcc_qso + message_dxcc_klog + "\n\n" + tr("Please select the one you want to keep for this QSO.");
11801198

11811199
QPushButton *button2 = new QPushButton(this);
11821200
QPushButton *button1 = new QPushButton(this);
11831201

1184-
button1->setText(world->getEntityMainPrefix(dxcc_Call));
1185-
button2->setText(world->getEntityMainPrefix(dxcc_qso));
1202+
button1->setText(dxcc1_prefix);
1203+
button2->setText(dxcc2_prefix);
11861204

11871205
int ret;
11881206

11891207
QMessageBox msgBox;
11901208
msgBox.setWindowTitle(tr("KLog - Select correct entity"));
1191-
msgBox.setText( tr("You have selected an entity:") + "\n\n"+"- "+dxcc_qso_name+"\n\n"+tr("that is different from the KLog proposed entity:") + "\n\n"+ "- "+dxcc1_name+"\n\n"
1192-
+tr("Click on the prefix of the correct entity or Cancel to edit the QSO again."));
1209+
msgBox.setText(message);
11931210

11941211
msgBox.addButton(button2, QMessageBox::AcceptRole);
11951212
msgBox.addButton(button1, QMessageBox::ActionRole);

0 commit comments

Comments
 (0)