diff --git a/TODO b/TODO
index 06ae97ec..23a4d25c 100644
--- a/TODO
+++ b/TODO
@@ -48,7 +48,6 @@
[Audio]
- Style eveything nicely...
- MediaPlayer: move the slider using js (http://redmine.webtoolkit.eu/boards/2/topics/7924?r=8478, http://redmine.emweb.be/boards/2/topics/10994)
- - TrackView: handle durations > 1 hour
- TrackView: Reselect the current selected item when displaying the updated search results
- Add covers in the release filter?
- Add a download button to get the current playlist in a streamed zip file
diff --git a/src/ui/audio/desktop/TrackView.cpp b/src/ui/audio/desktop/TrackView.cpp
index 828f47de..a7115557 100644
--- a/src/ui/audio/desktop/TrackView.cpp
+++ b/src/ui/audio/desktop/TrackView.cpp
@@ -17,6 +17,8 @@
* along with LMS. If not, see .
*/
+#include
+
#include
#include
@@ -30,6 +32,30 @@ namespace Desktop {
using namespace Database;
+class DurationItemDelegate : public Wt::WItemDelegate
+{
+ public:
+ DurationItemDelegate(Wt::WObject *parent = 0) : Wt::WItemDelegate(parent) {}
+
+ Wt::WWidget* update(Wt::WWidget *widget, const Wt::WModelIndex &index, Wt::WFlags< Wt::ViewItemRenderFlag > flags)
+ {
+ boost::posix_time::time_duration duration = boost::any_cast(index.data(Wt::DisplayRole));
+
+ boost::posix_time::time_facet* facet = new boost::posix_time::time_facet();
+
+ if (duration.total_seconds() < 3600)
+ facet->time_duration_format("%M:%S");
+ else
+ facet->time_duration_format("%H:%M:%S");
+
+ std::ostringstream oss;
+ oss.imbue(std::locale(oss.getloc(), facet));
+ oss << duration;
+
+ return new Wt::WText(oss.str(), Wt::PlainText);
+ }
+};
+
TrackView::TrackView(Wt::WContainerWidget* parent)
: Wt::WTableView( parent )
{
@@ -74,8 +100,7 @@ TrackView::TrackView(Wt::WContainerWidget* parent)
// Duration display
{
// TODO better handle 1 hour+ files!
- Wt::WItemDelegate *delegate = new Wt::WItemDelegate(this);
- delegate->setTextFormat("mm:ss");
+ DurationItemDelegate *delegate = new DurationItemDelegate(this);
this->setItemDelegateForColumn(5, delegate);
}