Fix/improve code for DB query widget
This commit is contained in:
parent
64aabf6de3
commit
63f0ab96a4
|
@ -130,19 +130,18 @@ DbQueryWidget::~DbQueryWidget()
|
||||||
values().dbQuery.override = m_ui->overrideCheckBox->isChecked();
|
values().dbQuery.override = m_ui->overrideCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbQueryWidget::insertSearchTermsFromTagEdit(TagEdit *tagEdit, bool songSpecific)
|
void DbQueryWidget::insertSearchTermsFromTagEdit(TagEdit *tagEdit)
|
||||||
{
|
{
|
||||||
if (!tagEdit) {
|
if (!tagEdit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool somethingChanged = false;
|
auto somethingChanged = false;
|
||||||
|
auto lyricsCentricProvider
|
||||||
// be always song-specific when querying makeitpersonal
|
= (m_lastSearchAction == m_searchTekstowoAction) || (m_searchMakeItPersonalAction && m_lastSearchAction == m_searchMakeItPersonalAction);
|
||||||
songSpecific = m_lastSearchAction == m_searchMakeItPersonalAction;
|
|
||||||
|
|
||||||
// set album and artist
|
// set album and artist
|
||||||
if (m_lastSearchAction != m_searchMakeItPersonalAction) {
|
if (!lyricsCentricProvider) {
|
||||||
const auto newAlbum = tagValueToQString(tagEdit->value(KnownField::Album));
|
const auto newAlbum = tagValueToQString(tagEdit->value(KnownField::Album));
|
||||||
if (m_ui->albumLineEdit->text() != newAlbum) {
|
if (m_ui->albumLineEdit->text() != newAlbum) {
|
||||||
m_ui->albumLineEdit->setText(newAlbum);
|
m_ui->albumLineEdit->setText(newAlbum);
|
||||||
|
@ -155,20 +154,10 @@ void DbQueryWidget::insertSearchTermsFromTagEdit(TagEdit *tagEdit, bool songSpec
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!songSpecific) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set title and track number
|
// set title and track number
|
||||||
const auto newTitle = tagValueToQString(tagEdit->value(KnownField::Title));
|
if (lyricsCentricProvider) {
|
||||||
if (m_ui->titleLineEdit->text() != newTitle) {
|
if (const auto newTitle = tagValueToQString(tagEdit->value(KnownField::Title)); m_ui->titleLineEdit->text() != newTitle) {
|
||||||
m_ui->titleLineEdit->setText(newTitle);
|
m_ui->titleLineEdit->setText(newTitle);
|
||||||
somethingChanged = true;
|
|
||||||
}
|
|
||||||
if (m_lastSearchAction != m_searchTekstowoAction && m_lastSearchAction != m_searchMakeItPersonalAction) {
|
|
||||||
const auto newTrackNumber = tagEdit->trackNumber();
|
|
||||||
if (m_ui->trackSpinBox->value() != newTrackNumber) {
|
|
||||||
m_ui->trackSpinBox->setValue(newTrackNumber);
|
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +252,7 @@ void DbQueryWidget::searchMakeItPersonal()
|
||||||
|
|
||||||
void DbQueryWidget::searchTekstowo()
|
void DbQueryWidget::searchTekstowo()
|
||||||
{
|
{
|
||||||
m_lastSearchAction = m_searchMakeItPersonalAction;
|
m_lastSearchAction = m_searchTekstowoAction;
|
||||||
|
|
||||||
// check whether enough search terms are supplied
|
// check whether enough search terms are supplied
|
||||||
if (m_ui->artistLineEdit->text().isEmpty() || m_ui->titleLineEdit->text().isEmpty()) {
|
if (m_ui->artistLineEdit->text().isEmpty() || m_ui->titleLineEdit->text().isEmpty()) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
explicit DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent = nullptr);
|
explicit DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent = nullptr);
|
||||||
~DbQueryWidget() override;
|
~DbQueryWidget() override;
|
||||||
|
|
||||||
void insertSearchTermsFromTagEdit(TagEdit *tagEdit, bool songSpecific = false);
|
void insertSearchTermsFromTagEdit(TagEdit *tagEdit);
|
||||||
SongDescription currentSongDescription() const;
|
SongDescription currentSongDescription() const;
|
||||||
void applyResults(TagEdit *tagEdit, const QModelIndex &resultIndex);
|
void applyResults(TagEdit *tagEdit, const QModelIndex &resultIndex);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue