[UI] Better handle duration >1h in the track view
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/date_time.hpp>
|
||||
|
||||
#include <Wt/WItemDelegate>
|
||||
#include <Wt/WBreak>
|
||||
|
||||
@@ -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<boost::posix_time::time_duration>(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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user