Skip to content

Commit

Permalink
Fixed #345 - Contest Support: Completer for ContestID and added INTL-…
Browse files Browse the repository at this point in the history
…removal
  • Loading branch information
foldynl committed Nov 5, 2024
1 parent b65f33a commit ac1121d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
14 changes: 14 additions & 0 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ DxccStatus Data::dxccStatus(int dxcc, const QString &band, const QString &mode)
}
#undef RETCODE

QStringList Data::contestList()
{
FCT_IDENTIFICATION;

QStringList contestLOV;

QSqlQuery query(QLatin1String("SELECT DISTINCT contest_id FROM contacts ORDER BY 1 COLLATE LOCALEAWARE ASC"));

while ( query.next() )
contestLOV << query.value(0).toString();

return contestLOV + contests.keys();
}

#define RETURNCODE(a) \
qCDebug(runtime) << "new DXCC Status: " << (a); \
return ((a))
Expand Down
2 changes: 1 addition & 1 deletion data/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Data : public QObject
const QString &mode);

DxccStatus dxccStatus(int dxcc, const QString &band, const QString &mode);
QStringList contestList() { return contests.values(); }
QStringList contestList();
QStringList propagationModesList() { return propagationModes.values(); }
QStringList propagationModesIDList() { return propagationModes.keys(); }
QString propagationModeTextToID(const QString &propagationText) { return propagationModes.key(propagationText);}
Expand Down
21 changes: 21 additions & 0 deletions ui/NewContactWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ NewContactWidget::NewContactWidget(QWidget *parent) :
sigCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
uiDynamic->sigEdit->setCompleter(sigCompleter);

contestCompleter = new QCompleter(uiDynamic->contestIDEdit);
contestCompleter->setCaseSensitivity(Qt::CaseInsensitive);
contestCompleter->setFilterMode(Qt::MatchStartsWith);
uiDynamic->contestIDEdit->setCompleter(contestCompleter);

/**************/
/* CONNECTs */
/**************/
Expand Down Expand Up @@ -212,6 +217,7 @@ NewContactWidget::NewContactWidget(QWidget *parent) :
connect(uiDynamic->wwffEdit, &QLineEdit::textChanged, this, &NewContactWidget::wwffChanged);
connect(uiDynamic->satNameEdit, &QLineEdit::textChanged, this, &NewContactWidget::satNameChanged);
connect(uiDynamic->sigEdit, &NewContactEditLine::focusIn, this, &NewContactWidget::refreshSIGCompleter);
connect(uiDynamic->contestIDEdit, &NewContactEditLine::focusIn, this, &NewContactWidget::refreshContestCompleter);

ui->rstSentEdit->installEventFilter(this);
ui->rstRcvdEdit->installEventFilter(this);
Expand Down Expand Up @@ -1261,6 +1267,8 @@ void NewContactWidget::addAddlFields(QSqlRecord &record, const StationProfile &p
if ( uiDynamic->contestIDEdit->isVisible()
&& !uiDynamic->contestIDEdit->text().isEmpty() )
{
uiDynamic->contestIDEdit->setText(Data::removeAccents(uiDynamic->contestIDEdit->text()));

if ( shouldStartContest() )
startContest(record.value("start_time").toDateTime());

Expand Down Expand Up @@ -2764,6 +2772,19 @@ void NewContactWidget::refreshSIGCompleter()
sigCompleter->setModel(model);
}

void NewContactWidget::refreshContestCompleter()
{
FCT_IDENTIFICATION;

QStringListModel *model = static_cast<QStringListModel*>(contestCompleter->model());

if( !model )
model = new QStringListModel();

model->setStringList(Data::instance()->contestList());
contestCompleter->setModel(model);
}

QString NewContactWidget::getCallsign() const
{
FCT_IDENTIFICATION;
Expand Down
2 changes: 2 additions & 0 deletions ui/NewContactWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private slots:
void antProfileComboChanged(const QString&);
void webLookup();
void refreshSIGCompleter();
void refreshContestCompleter();

private:
void useFieldsFromPrevQSO(const QString &callsign,
Expand Down Expand Up @@ -341,6 +342,7 @@ private slots:
MultiselectCompleter *potaCompleter;
QCompleter *wwffCompleter;
QCompleter *sigCompleter;
QCompleter *contestCompleter;
QTimeZone partnerTimeZone;
double QSOFreq;
qint32 bandwidthFilter;
Expand Down

0 comments on commit ac1121d

Please sign in to comment.