Add a filter for each type of playlist in the load/save dialogs.

This commit is contained in:
David Sansome 2010-05-22 22:29:52 +00:00
parent b487ec00ef
commit 89bbaeed5f
31 changed files with 215 additions and 104 deletions

View File

@ -236,7 +236,7 @@ void PlaylistContainer::LoadPlaylist() {
QString filename = settings_.value("last_load_playlist").toString();
filename = QFileDialog::getOpenFileName(
this, tr("Load playlist"), filename,
tr("Playlists (%1)").arg(manager_->parser()->filter_text()));
manager_->parser()->filters());
if (filename.isNull())
return;
@ -250,7 +250,7 @@ void PlaylistContainer::SavePlaylist(int id = -1) {
QString filename = settings_.value("last_save_playlist").toString();
filename = QFileDialog::getSaveFileName(
this, tr("Save playlist"), filename,
tr("Playlists (%1)").arg(manager_->parser()->filter_text()));
manager_->parser()->filters());
if (filename.isNull())
return;

View File

@ -29,6 +29,7 @@ class M3UParser : public ParserBase {
public:
M3UParser(QObject* parent = 0);
QString name() const { return "M3U"; }
QStringList file_extensions() const { return QStringList() << "m3u"; }
SongList Load(QIODevice* device, const QDir& dir = QDir()) const;

View File

@ -28,6 +28,7 @@ class ParserBase : public QObject {
public:
ParserBase(QObject *parent = 0);
virtual QString name() const = 0;
virtual QStringList file_extensions() const = 0;
virtual SongList Load(QIODevice* device, const QDir& dir = QDir()) const = 0;

View File

@ -40,11 +40,22 @@ QStringList PlaylistParser::file_extensions() const {
return ret;
}
QString PlaylistParser::filter_text() const {
QStringList extensions;
foreach (const QString& extension, file_extensions())
extensions << "*." + extension;
return extensions.join(" ");
QString PlaylistParser::filters() const {
QStringList filters;
QStringList all_extensions;
foreach (ParserBase* parser, parsers_) {
QStringList extensions;
foreach (const QString& extension, parser->file_extensions())
extensions << "*." + extension;
all_extensions << extensions;
filters << tr("%1 playlists (%2)").arg(parser->name(), extensions.join(" "));
}
filters.prepend(tr("All playlists (%1)").arg(all_extensions.join(" ")));
qDebug() << filters.join(";;");
return filters.join(";;");
}
bool PlaylistParser::can_load(const QString &filename) const {

View File

@ -30,7 +30,7 @@ public:
PlaylistParser(QObject *parent = 0);
QStringList file_extensions() const;
QString filter_text() const;
QString filters() const;
bool can_load(const QString& filename) const;

View File

@ -25,6 +25,7 @@ class PLSParser : public ParserBase {
public:
PLSParser(QObject* parent = 0);
QString name() const { return "PLS"; }
QStringList file_extensions() const { return QStringList() << "pls"; }
SongList Load(QIODevice* device, const QDir& dir = QDir()) const;

View File

@ -27,6 +27,7 @@ class XSPFParser : public ParserBase {
public:
XSPFParser(QObject* parent = 0);
QString name() const { return "XSPF"; }
QStringList file_extensions() const { return QStringList() << "xspf"; }
SongList Load(QIODevice *device, const QDir &dir = QDir()) const;

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -344,10 +344,6 @@ msgstr "Seznam skladeb"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -457,6 +453,14 @@ msgstr "Opakovat"
msgid "Shuffle"
msgstr "Zamíchat"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Ověření selhalo"

View File

@ -346,10 +346,6 @@ msgstr "Spilleliste"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -459,6 +455,14 @@ msgstr "Gentag"
msgid "Shuffle"
msgstr "Bland"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autentificering mislykkedes"

View File

@ -343,10 +343,6 @@ msgstr "Wiedergabeliste"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Wiederholen"
msgid "Shuffle"
msgstr "Zufällige Wiedergabe"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Authentifizierung fehlgeschlagen"

View File

@ -346,10 +346,6 @@ msgstr "Λίστα"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -459,6 +455,14 @@ msgstr "Επανάληψη"
msgid "Shuffle"
msgstr "Ανακάτεμα"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Η πιστοποίηση απέτυχε"

View File

@ -343,10 +343,6 @@ msgstr "Playlist"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Repeat"
msgid "Shuffle"
msgstr "Shuffle"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Authentication failed"

View File

@ -349,10 +349,6 @@ msgstr "Lista de reproducción"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -462,6 +458,14 @@ msgstr "Repetir"
msgid "Shuffle"
msgstr "Aleatorio"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Falló la autenticación"

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -348,10 +348,6 @@ msgstr "Liste de lecture"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -461,6 +457,14 @@ msgstr "Répéter"
msgid "Shuffle"
msgstr "Mélanger"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Échec de l'authentification"

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autenticazón fallida"

View File

@ -346,10 +346,6 @@ msgstr "Scaletta"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -459,6 +455,14 @@ msgstr "Ripeti"
msgid "Shuffle"
msgstr "Mescola"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autenticazione non riuscita"

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -344,10 +344,6 @@ msgstr "Spilleliste"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -457,6 +453,14 @@ msgstr "Repetér"
msgid "Shuffle"
msgstr "Stokk om"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autentiseringen feilet"

View File

@ -343,10 +343,6 @@ msgstr "Lista de lectura"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Repetir"
msgid "Shuffle"
msgstr "Lectura aleatòria"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "L'autentificacion a fracassat"

View File

@ -344,10 +344,6 @@ msgstr "Playlista"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -457,6 +453,14 @@ msgstr "Powtarzaj"
msgid "Shuffle"
msgstr "Losuj"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Błąd uwierzytelniania"

View File

@ -343,10 +343,6 @@ msgstr "Lista de Reprodução"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Repetir"
msgid "Shuffle"
msgstr "Baralhar"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Falha na autenticação"

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -343,10 +343,6 @@ msgstr "Listă de redare"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Repetă"
msgid "Shuffle"
msgstr "Amestecă"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autentificarea a eșuat"

View File

@ -343,10 +343,6 @@ msgstr "Плейлист"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr "Повторить"
msgid "Shuffle"
msgstr "Перемешать"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Ошибка аутентификации"

View File

@ -344,10 +344,6 @@ msgstr "Playlist"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -457,6 +453,14 @@ msgstr "Opakovať"
msgid "Shuffle"
msgstr "Zamiešať"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Autentifikácia zlyhala"

View File

@ -345,10 +345,6 @@ msgstr "Spellista"
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -458,6 +454,14 @@ msgstr "Upprepa"
msgid "Shuffle"
msgstr "Slumpvist"
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr "Behörighetskontroll misslyckades"

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -334,10 +334,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -447,6 +443,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""

View File

@ -343,10 +343,6 @@ msgstr ""
msgid "Load playlist"
msgstr ""
#, qt-format
msgid "Playlists (%1)"
msgstr ""
msgid "Save playlist"
msgstr ""
@ -456,6 +452,14 @@ msgstr ""
msgid "Shuffle"
msgstr ""
#, qt-format
msgid "%1 playlists (%2)"
msgstr ""
#, qt-format
msgid "All playlists (%1)"
msgstr ""
msgid "Authentication failed"
msgstr ""