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>
|
#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 ()
|
BrowseModel::BrowseModel (QWidget *parent) : QAbstractTableModel ()
|
||||||
{
|
{
|
||||||
m_columns.append ("Name");
|
m_columns.append ("Name");
|
||||||
|
@ -85,9 +95,20 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
|
||||||
if (d.contains ("name")) {
|
if (d.contains ("name")) {
|
||||||
name = QString::fromStdString (d.get<std::string> ("name"));
|
name = QString::fromStdString (d.get<std::string> ("name"));
|
||||||
} else {
|
} else {
|
||||||
if (d.contains ("title") && d.contains ("artist")) {
|
if (d.contains ("title")) {
|
||||||
name += QString::fromStdString (d.get<std::string> ("artist"));
|
if (d.contains ("artist")) {
|
||||||
name += " - ";
|
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"));
|
name += QString::fromStdString (d.get<std::string> ("title"));
|
||||||
} else {
|
} else {
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
@ -107,12 +128,14 @@ BrowseModel::list_cb (const Xmms::List< Xmms::Dict > &res)
|
||||||
m_list.append (new BrowseModelItem (path, name, isdir));
|
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 ();
|
reset ();
|
||||||
|
|
||||||
emit dirChanged (m_current_dir);
|
emit dirChanged (m_current_dir);
|
||||||
|
|
||||||
qDebug ("done");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ class BrowseModelItem
|
||||||
return m_isdir;
|
return m_isdir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool itemCompare (BrowseModelItem *s1, BrowseModelItem *s2);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QHash<QString, QString> m_vals;
|
QHash<QString, QString> m_vals;
|
||||||
bool m_isdir;
|
bool m_isdir;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue