Make DAAP browsing pretty
This commit is contained in:
parent
7fbbfdb7bd
commit
f6baf9cb12
2 changed files with 30 additions and 5 deletions
|
@ -7,6 +7,16 @@
|
|||
#include <QWidget>
|
||||
|
||||
|
||||
bool
|
||||
BrowseModelItem::itemCompare (BrowseModelItem *s1, BrowseModelItem *s2)
|
||||
{
|
||||
if (QString::localeAwareCompare (s1->m_vals["name"].toLower (),
|
||||
s2->m_vals["name"].toLower ()) < 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BrowseModel::BrowseModel (QWidget *parent) : QAbstractTableModel ()
|
||||
{
|
||||
m_columns.append ("Name");
|
||||
|
@ -85,9 +95,20 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
|
|||
if (d.contains ("name")) {
|
||||
name = QString::fromStdString (d.get<std::string> ("name"));
|
||||
} else {
|
||||
if (d.contains ("title") && d.contains ("artist")) {
|
||||
name += QString::fromStdString (d.get<std::string> ("artist"));
|
||||
name += " - ";
|
||||
if (d.contains ("title")) {
|
||||
if (d.contains ("artist")) {
|
||||
name += QString::fromStdString (d.get<std::string> ("artist"));
|
||||
name += " - ";
|
||||
}
|
||||
if (d.contains ("album")) {
|
||||
name += QString::fromStdString (d.get<std::string> ("album"));
|
||||
name += " - ";
|
||||
}
|
||||
if (d.contains ("tracknr")) {
|
||||
name += QString::number (d.get<uint32_t>
|
||||
("tracknr")).rightJustified(2, '0');
|
||||
name += " - ";
|
||||
}
|
||||
name += QString::fromStdString (d.get<std::string> ("title"));
|
||||
} else {
|
||||
const char *tmp;
|
||||
|
@ -107,12 +128,14 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
|
|||
m_list.append (new BrowseModelItem (path, name, isdir));
|
||||
}
|
||||
|
||||
qSort (m_list.begin (), m_list.end (), BrowseModelItem::itemCompare);
|
||||
|
||||
qDebug ("%s", qPrintable(m_list.at(0)->data("name")));
|
||||
|
||||
reset ();
|
||||
|
||||
emit dirChanged (m_current_dir);
|
||||
|
||||
qDebug ("done");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ class BrowseModelItem
|
|||
bool isDir () {
|
||||
return m_isdir;
|
||||
};
|
||||
|
||||
static bool itemCompare (BrowseModelItem *s1, BrowseModelItem *s2);
|
||||
|
||||
protected:
|
||||
QHash<QString, QString> m_vals;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue