Improve DbQueryWidget
This commit is contained in:
parent
c1269c7945
commit
b3a79940b7
|
@ -35,7 +35,8 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
|||
m_ui(new Ui::DbQueryWidget),
|
||||
m_tagEditorWidget(tagEditorWidget),
|
||||
m_model(nullptr),
|
||||
m_coverIndex(-1)
|
||||
m_coverIndex(-1),
|
||||
m_menu(new QMenu(parent))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
#ifdef Q_OS_WIN32
|
||||
|
@ -61,6 +62,16 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
|||
// restore settings
|
||||
m_ui->overrideCheckBox->setChecked(Settings::dbQueryOverride());
|
||||
|
||||
// setup menu
|
||||
m_insertPresentDataAction = m_menu->addAction(tr("Insert present data"));
|
||||
m_insertPresentDataAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
|
||||
m_insertPresentDataAction->setEnabled(m_tagEditorWidget->activeTagEdit());
|
||||
connect(m_insertPresentDataAction, &QAction::triggered, this, &DbQueryWidget::insertSearchTermsFromActiveTagEdit);
|
||||
QAction *clearSearchCriteria = m_menu->addAction(tr("Clear search criteria"));
|
||||
clearSearchCriteria->setIcon(QIcon::fromTheme(QStringLiteral("edit-clear")));
|
||||
connect(clearSearchCriteria, &QAction::triggered, this, &DbQueryWidget::clearSearchCriteria);
|
||||
m_ui->menuPushButton->setMenu(m_menu);
|
||||
|
||||
// connect signals and slots
|
||||
connect(m_ui->abortPushButton, &QPushButton::clicked, this, &DbQueryWidget::abortSearch);
|
||||
connect(m_ui->startPushButton, &QPushButton::clicked, this, &DbQueryWidget::startSearch);
|
||||
|
@ -194,7 +205,8 @@ void DbQueryWidget::setStatus(bool aborted)
|
|||
void DbQueryWidget::fileStatusChanged(bool, bool hasTags)
|
||||
{
|
||||
m_ui->applyPushButton->setEnabled(hasTags && m_ui->resultsTreeView->selectionModel() && m_ui->resultsTreeView->selectionModel()->hasSelection());
|
||||
insertSearchTermsFromTagEdit(m_tagEditorWidget->activeTagEdit());
|
||||
insertSearchTermsFromActiveTagEdit();
|
||||
m_insertPresentDataAction->setEnabled(hasTags);
|
||||
}
|
||||
|
||||
void DbQueryWidget::applyResults()
|
||||
|
@ -248,6 +260,11 @@ void DbQueryWidget::applyResults()
|
|||
}
|
||||
}
|
||||
|
||||
void DbQueryWidget::insertSearchTermsFromActiveTagEdit()
|
||||
{
|
||||
insertSearchTermsFromTagEdit(m_tagEditorWidget->activeTagEdit());
|
||||
}
|
||||
|
||||
void DbQueryWidget::showResultsContextMenu()
|
||||
{
|
||||
if(const QItemSelectionModel *selectionModel = m_ui->resultsTreeView->selectionModel()) {
|
||||
|
@ -322,6 +339,14 @@ void DbQueryWidget::showCoverFromIndex(const QModelIndex &index)
|
|||
}
|
||||
}
|
||||
|
||||
void DbQueryWidget::clearSearchCriteria()
|
||||
{
|
||||
m_ui->titleLineEdit->clear();
|
||||
m_ui->albumLineEdit->clear();
|
||||
m_ui->artistLineEdit->clear();
|
||||
m_ui->trackSpinBox->setValue(0);
|
||||
}
|
||||
|
||||
bool DbQueryWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if(obj == m_ui->searchGroupBox) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <memory>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QItemSelection)
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace Settings {
|
||||
class KnownFieldModel;
|
||||
|
@ -34,12 +36,14 @@ public:
|
|||
public slots:
|
||||
void startSearch();
|
||||
void abortSearch();
|
||||
void applyResults();
|
||||
void insertSearchTermsFromActiveTagEdit();
|
||||
void clearSearchCriteria();
|
||||
|
||||
private slots:
|
||||
void showResults();
|
||||
void setStatus(bool aborted);
|
||||
void fileStatusChanged(bool opened, bool hasTags);
|
||||
void applyResults();
|
||||
void showResultsContextMenu();
|
||||
void fetchAndShowCoverForSelection();
|
||||
void showCover(const QByteArray &data);
|
||||
|
@ -53,6 +57,8 @@ private:
|
|||
TagEditorWidget *m_tagEditorWidget;
|
||||
QueryResultsModel *m_model;
|
||||
int m_coverIndex;
|
||||
QMenu *m_menu;
|
||||
QAction *m_insertPresentDataAction;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<item>
|
||||
<widget class="QGroupBox" name="searchGroupBox">
|
||||
<property name="title">
|
||||
<string>Search criteria</string>
|
||||
<string>Search &criteria</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="searchFormLayout">
|
||||
<property name="horizontalSpacing">
|
||||
|
@ -71,14 +71,14 @@
|
|||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="songLabel">
|
||||
<property name="text">
|
||||
<string>Song</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="songLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
|
@ -105,28 +105,28 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="albumLabel">
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="albumLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="artistLabel">
|
||||
<property name="text">
|
||||
<string>Artist</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="Widgets::ClearLineEdit" name="artistLineEdit">
|
||||
<property name="placeholderText">
|
||||
<string>?</string>
|
||||
|
@ -258,6 +258,22 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="menuPushButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>23</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="abortPushButton">
|
||||
<property name="text">
|
||||
|
@ -281,6 +297,9 @@
|
|||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Inserts the selected result into the current tag (doesn't save anything)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply results</string>
|
||||
</property>
|
||||
|
|
|
@ -646,7 +646,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="53"/>
|
||||
<source>Search criteria</source>
|
||||
<source>Search &criteria</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
@ -683,47 +683,62 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="264"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="280"/>
|
||||
<source>Abort</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="271"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="287"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="285"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="301"/>
|
||||
<source>Inserts the selected result into the current tag (doesn't save anything)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="304"/>
|
||||
<source>Apply results</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="47"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="48"/>
|
||||
<source>Search hasn't been started.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="114"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="66"/>
|
||||
<source>Insert present data</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="70"/>
|
||||
<source>Clear search criteria</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="125"/>
|
||||
<source>Insufficient search criteria supplied</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="124"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="135"/>
|
||||
<source>Retrieving meta data ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="154"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="165"/>
|
||||
<source>Aborted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="166"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="177"/>
|
||||
<source>No results available</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../gui/dbquerywidget.cpp" line="168"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="179"/>
|
||||
<source>%1 result(s) available</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
|
@ -731,22 +746,22 @@
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="229"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="241"/>
|
||||
<source>Retrieving cover art to be applied ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="261"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="278"/>
|
||||
<source>Show cover</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="290"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="307"/>
|
||||
<source>Retrieving cover art ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="304"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="321"/>
|
||||
<source>Cover - %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -646,7 +646,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="53"/>
|
||||
<source>Search criteria</source>
|
||||
<source>Search &criteria</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
|
@ -683,47 +683,62 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="264"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="280"/>
|
||||
<source>Abort</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="271"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="287"/>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="285"/>
|
||||
<location filename="../gui/dbquerywidget.ui" line="301"/>
|
||||
<source>Inserts the selected result into the current tag (doesn't save anything)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.ui" line="304"/>
|
||||
<source>Apply results</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="47"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="48"/>
|
||||
<source>Search hasn't been started.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="114"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="66"/>
|
||||
<source>Insert present data</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="70"/>
|
||||
<source>Clear search criteria</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="125"/>
|
||||
<source>Insufficient search criteria supplied</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="124"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="135"/>
|
||||
<source>Retrieving meta data ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="154"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="165"/>
|
||||
<source>Aborted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="166"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="177"/>
|
||||
<source>No results available</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../gui/dbquerywidget.cpp" line="168"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="179"/>
|
||||
<source>%1 result(s) available</source>
|
||||
<translation type="unfinished">
|
||||
<numerusform></numerusform>
|
||||
|
@ -731,22 +746,22 @@
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="229"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="241"/>
|
||||
<source>Retrieving cover art to be applied ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="261"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="278"/>
|
||||
<source>Show cover</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="290"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="307"/>
|
||||
<source>Retrieving cover art ...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="304"/>
|
||||
<location filename="../gui/dbquerywidget.cpp" line="321"/>
|
||||
<source>Cover - %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in New Issue