Implement the reset play counts button

This commit is contained in:
David Sansome 2010-12-25 11:54:21 +00:00
parent e21307e087
commit 8cdce2767b
50 changed files with 189 additions and 3 deletions

View File

@ -67,6 +67,11 @@ void LibraryBackend::IncrementSkipCountAsync(int id, float progress) {
Q_ARG(int, id), Q_ARG(float, progress));
}
void LibraryBackend::ResetStatisticsAsync(int id) {
metaObject()->invokeMethod(this, "ResetStatistics", Qt::QueuedConnection,
Q_ARG(int, id));
}
void LibraryBackend::UpdateSongRatingAsync(int id, float rating) {
metaObject()->invokeMethod(this, "UpdateSongRating", Qt::QueuedConnection,
Q_ARG(int, id), Q_ARG(float, rating));
@ -934,6 +939,26 @@ void LibraryBackend::IncrementSkipCount(int id, float progress) {
emit SongsStatisticsChanged(SongList() << new_song);
}
void LibraryBackend::ResetStatistics(int id) {
if (id == -1)
return;
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
QSqlQuery q(QString(
"UPDATE %1 SET playcount = 0, skipcount = 0,"
" lastplayed = -1, score = 0"
" WHERE ROWID = :id").arg(songs_table_), db);
q.bindValue(":id", id);
q.exec();
if (db_->CheckErrors(q.lastError()))
return;
Song new_song = GetSongById(id, db);
emit SongsStatisticsChanged(SongList() << new_song);
}
void LibraryBackend::UpdateSongRating(int id, float rating) {
if (id == -1)
return;

View File

@ -142,6 +142,7 @@ class LibraryBackend : public LibraryBackendInterface {
void IncrementPlayCountAsync(int id);
void IncrementSkipCountAsync(int id, float progress);
void ResetStatisticsAsync(int id);
void UpdateSongRatingAsync(int id, float rating);
void DeleteAll();
@ -158,6 +159,7 @@ class LibraryBackend : public LibraryBackendInterface {
void ForceCompilation(const QString& artist, const QString& album, bool on);
void IncrementPlayCount(int id);
void IncrementSkipCount(int id, float progress);
void ResetStatistics(int id);
void UpdateSongRating(int id, float rating);
signals:

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "الفنان"

View File

@ -344,6 +344,9 @@ msgstr "Ужыць кампрэсію для прадухілення скажэ
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Вы сапраўды жадаеце выдаліць настройку \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Выканаўца"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Изпълнител"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -353,6 +353,9 @@ msgstr "Afegir compressió per evitar el clipping"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Estas segur de que vols esborrar el \"%1\" preestablert?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -351,6 +351,9 @@ msgstr "Použít zhuštění kvůli zabránění stříhání"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Jste si jistý, že chcete smazat \"%1\" přednastavení?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Umělec"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -342,6 +342,9 @@ msgstr "Påfør kompression for at undgå klipping"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Vil du slettet \"%1\"-forudindstilling?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Kunstner"

View File

@ -353,6 +353,9 @@ msgstr "Komprimieren um Clippingfehler zu vermeiden"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Profil \"%1\" wirklich löschen?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Interpret"

View File

@ -355,6 +355,9 @@ msgstr "Εφαρμογή συμπίεσης για αποφυγή κολλημά
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Είστε σίγουροι πως θέλετε να διαγράψετε τη ρύθμιση \"%1\";"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Καλλιτέχνης"

View File

@ -5,8 +5,7 @@
#
#, fuzzy
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid " ms"
msgstr ""
@ -331,6 +330,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -341,6 +341,9 @@ msgstr "Apply compression to prevent clipping"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Are you sure you want to delete the \"%1\" preset?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artist"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Are you sure you want to delete the \"%1\" preset?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artist"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Verkinto"

View File

@ -355,6 +355,9 @@ msgstr "Aplicar compresión para evitar clipping"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "¿Estás seguro de que quieres eliminar la predefinición \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Esitaja"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Esittäjä"

View File

@ -358,6 +358,9 @@ msgstr "Appliquer une compression pour prévenir les coupures"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Êtes-vous sûr de vouloir supprimer la valeur prédéfinie « %1»"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artiste"

View File

@ -341,6 +341,9 @@ msgstr "Aplicar compresión para evitar clipping"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Está certo que quer apagar o \"%1\" predefinido?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -343,6 +343,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "אמן"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -347,6 +347,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -349,6 +349,9 @@ msgstr "Tömörítés engedélyezése a túlvezérlés elkerülése érdekében"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Biztos benne, hogy törli a \"%1\" beállítást?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Előadó"

View File

@ -356,6 +356,9 @@ msgstr "Applica la compressione per evitare il taglio"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Sei sicuro di voler eliminare la preimpostazione \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -347,6 +347,9 @@ msgstr "圧縮を適用してクリップを禁止する"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "\"%1\" プリセットを削除してもよろしいですか?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "アーティスト"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Орындайтын"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -344,6 +344,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Er du sikker på at du vil slette \"%1\" innstillingen?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artist"

View File

@ -349,6 +349,9 @@ msgstr "Compressie toepassen om vervorming te voorkomen."
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Weet u zeker dat u voorinstelling \"%1\" wilt wissen?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artiest"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -349,6 +349,9 @@ msgstr "Skompresuj, aby zapobiec przesterowaniu"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Czy na pewno chcesz usunąć preset \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Wykonawca"

View File

@ -352,6 +352,9 @@ msgstr "Aplicar compressão para prevenir o corte"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Tem a certeza que quer apagar o pré-ajuste \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -349,6 +349,9 @@ msgstr "Aplicar compressão para prevenir travamento"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Tem certeza que deseja apagar a pré-regulagem \"%1\" ?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artista"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Sigur doriți să ștergeți presetarea \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artist"

View File

@ -348,6 +348,9 @@ msgstr "Применить компрессию для предотвращен
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Вы действительно хотите удалить настройку \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Исполнитель"

View File

@ -349,6 +349,9 @@ msgstr "Použiť kompresiu na zabránenie odrezávania"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Ste si istý, že chcete vymazať predvoľbu \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Interprét"

View File

@ -348,6 +348,9 @@ msgstr "Uporabi stiskanje za preprečitev odrezanja"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Ali resnično želite izbrisati prednastavitev \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Izvajalec"

View File

@ -341,6 +341,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Сигурнисте да желите обрисати претподешавање \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Извођач"

View File

@ -351,6 +351,9 @@ msgstr "Tillämpa komprimering för att förhindra distorsion"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Är du säker på att du vill ta bort förinställningen \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Artist"

View File

@ -348,6 +348,9 @@ msgstr "Kesintiyi engellemek için sıkıştırma uygula"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "\"%1\" ayarını silmek istediğinizden emin misiniz?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Sanatçı"

View File

@ -331,6 +331,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr ""

View File

@ -350,6 +350,9 @@ msgstr "Застосувати стиснення для запобігання
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr "Ви дійсно хочите вилучити задане \"%1\"?"
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "Виконавець"

View File

@ -343,6 +343,9 @@ msgstr ""
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "艺术家"

View File

@ -345,6 +345,9 @@ msgstr "使用壓縮,以防止截波失真"
msgid "Are you sure you want to delete the \"%1\" preset?"
msgstr ""
msgid "Are you sure you want to reset this song's statistics?"
msgstr ""
msgid "Artist"
msgstr "演出者"

View File

@ -32,6 +32,7 @@
#include <QFutureWatcher>
#include <QLabel>
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QShortcut>
#include <QtConcurrentRun>
@ -108,6 +109,7 @@ EditTagDialog::EditTagDialog(QWidget* parent)
SLOT(ButtonClicked(QAbstractButton*)));
connect(ui_->rating, SIGNAL(RatingChanged(float)),
SLOT(SongRated(float)));
connect(ui_->playcount_reset, SIGNAL(clicked()), SLOT(ResetPlayCounts()));
// Set up the album cover menu
cover_menu_ = new QMenu(this);
@ -626,3 +628,25 @@ void EditTagDialog::SongRated(float rating) {
song->set_rating(rating);
backend_->UpdateSongRatingAsync(song->id(), rating);
}
void EditTagDialog::ResetPlayCounts() {
const QModelIndexList sel = ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty())
return;
Song* song = &data_[sel.first().row()].original_;
if (!song->is_valid() || song->id() == -1)
return;
if (QMessageBox::question(this, tr("Reset play counts"),
tr("Are you sure you want to reset this song's statistics?"),
QMessageBox::Reset, QMessageBox::Cancel) != QMessageBox::Reset) {
return;
}
song->set_playcount(0);
song->set_skipcount(0);
song->set_lastplayed(-1);
song->set_score(0);
backend_->ResetStatisticsAsync(song->id());
UpdateStatisticsTab(*song);
}

View File

@ -69,6 +69,7 @@ private slots:
void ResetField();
void ButtonClicked(QAbstractButton* button);
void SongRated(float rating);
void ResetPlayCounts();
void ArtLoaded(quint64 id, const QImage& image);

View File

@ -473,7 +473,7 @@
<widget class="RatingWidget" name="rating" native="true"/>
</item>
<item row="5" column="2" colspan="2">
<widget class="QPushButton" name="pushButton_4">
<widget class="QPushButton" name="playcount_reset">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>