Show number of matched tracks at bottom of search page
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "stdactions.h"
|
||||
#include "utils.h"
|
||||
#include "icon.h"
|
||||
#include "qtplural.h"
|
||||
|
||||
SearchPage::SearchPage(QWidget *p)
|
||||
: QWidget(p)
|
||||
@@ -54,6 +55,7 @@ SearchPage::SearchPage(QWidget *p)
|
||||
connect(this, SIGNAL(addSongsToPlaylist(const QString &, const QStringList &)), MPDConnection::self(), SLOT(addToPlaylist(const QString &, const QStringList &)));
|
||||
connect(&model, SIGNAL(searching()), view, SLOT(showSpinner()));
|
||||
connect(&model, SIGNAL(searched()), view, SLOT(hideSpinner()));
|
||||
connect(&model, SIGNAL(statsUpdated(int, quint32)), this, SLOT(statsUpdated(int, quint32)));
|
||||
connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
|
||||
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
|
||||
connect(view, SIGNAL(searchItems()), this, SLOT(searchItems()));
|
||||
@@ -205,3 +207,17 @@ void SearchPage::setSearchCategories()
|
||||
<< QPair<QString, QString>(i18n("Any:"), QLatin1String("any"));
|
||||
view->setSearchCategories(categories);
|
||||
}
|
||||
|
||||
void SearchPage::statsUpdated(int songs, quint32 time)
|
||||
{
|
||||
if (0==time) {
|
||||
statsLabel->setText(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KDE_SUPPORT
|
||||
statsLabel->setText(i18np("1 Track (%2)", "%1 Tracks (%2)", songs, Utils::formatDuration(time)));
|
||||
#else
|
||||
statsLabel->setText(QTP_TRACKS_DURATION_STR(songs, Utils::formatDuration(time)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public Q_SLOTS:
|
||||
void itemDoubleClicked(const QModelIndex &);
|
||||
void controlActions();
|
||||
void setSearchCategories();
|
||||
void statsUpdated(int songs, quint32 time);
|
||||
|
||||
private:
|
||||
enum State
|
||||
|
||||
@@ -47,17 +47,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>191</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="SqueezedTextLabel" name="statsLabel"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SizeWidget" name="sizeWidget"/>
|
||||
@@ -73,6 +63,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SqueezedTextLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>squeezedtextlabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ItemView</class>
|
||||
<extends>QTreeView</extends>
|
||||
|
||||
@@ -183,6 +183,7 @@ void SearchModel::clear()
|
||||
}
|
||||
currentKey=currentValue=QString();
|
||||
currentId++;
|
||||
emit statsUpdated(0, 0);
|
||||
}
|
||||
|
||||
void SearchModel::search(const QString &key, const QString &value)
|
||||
@@ -190,6 +191,7 @@ void SearchModel::search(const QString &key, const QString &value)
|
||||
if (key==currentKey && value==currentValue) {
|
||||
return;
|
||||
}
|
||||
emit searching();
|
||||
clear();
|
||||
currentKey=key;
|
||||
currentValue=value;
|
||||
@@ -207,4 +209,11 @@ void SearchModel::searchFinished(int id, const QList<Song> &result)
|
||||
songList.clear();
|
||||
songList=result;
|
||||
endResetModel();
|
||||
quint32 time=0;
|
||||
foreach (const Song &s, songList) {
|
||||
time+=s.time;
|
||||
}
|
||||
|
||||
emit statsUpdated(songList.size(), time);
|
||||
emit searched();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ public:
|
||||
Q_SIGNALS:
|
||||
void searching();
|
||||
void searched();
|
||||
|
||||
void statsUpdated(int songs, quint32 time);
|
||||
|
||||
void search(const QString &field, const QString &value, int id);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
Reference in New Issue
Block a user