diff --git a/data/Data.cpp b/data/Data.cpp index 4617c9be..d1158ff0 100644 --- a/data/Data.cpp +++ b/data/Data.cpp @@ -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)) diff --git a/data/Data.h b/data/Data.h index 627b70d6..89a22d50 100644 --- a/data/Data.h +++ b/data/Data.h @@ -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);} diff --git a/ui/NewContactWidget.cpp b/ui/NewContactWidget.cpp index 14ca953f..665c2921 100644 --- a/ui/NewContactWidget.cpp +++ b/ui/NewContactWidget.cpp @@ -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 */ /**************/ @@ -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); @@ -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()); @@ -2764,6 +2772,19 @@ void NewContactWidget::refreshSIGCompleter() sigCompleter->setModel(model); } +void NewContactWidget::refreshContestCompleter() +{ + FCT_IDENTIFICATION; + + QStringListModel *model = static_cast(contestCompleter->model()); + + if( !model ) + model = new QStringListModel(); + + model->setStringList(Data::instance()->contestList()); + contestCompleter->setModel(model); +} + QString NewContactWidget::getCallsign() const { FCT_IDENTIFICATION; diff --git a/ui/NewContactWidget.h b/ui/NewContactWidget.h index e20b6545..f3a06151 100644 --- a/ui/NewContactWidget.h +++ b/ui/NewContactWidget.h @@ -273,6 +273,7 @@ private slots: void antProfileComboChanged(const QString&); void webLookup(); void refreshSIGCompleter(); + void refreshContestCompleter(); private: void useFieldsFromPrevQSO(const QString &callsign, @@ -341,6 +342,7 @@ private slots: MultiselectCompleter *potaCompleter; QCompleter *wwffCompleter; QCompleter *sigCompleter; + QCompleter *contestCompleter; QTimeZone partnerTimeZone; double QSOFreq; qint32 bandwidthFilter;