some more progress ...
[musique.git] / common.cpp
blob79e5eaad47b3f6be6458e6848475accfebf167de
1 //
2 // C++ Implementation: common
3 //
4 // Author: Oliver Groß <z.o.gross@gmx.de>, (C) 2008
5 //
6 // Copyright: See COPYING file that comes with this distribution
7 //
8 #include <QString>
9 #include "common.h"
11 QString toStringFormated(xmms_playback_status_t state) {
12 switch (state) {
13 case XMMS_PLAYBACK_STATUS_PLAY:
14 return "[PLAYING] %1";
15 case XMMS_PLAYBACK_STATUS_STOP:
16 return "[STOPPED] %!";
17 case XMMS_PLAYBACK_STATUS_PAUSE:
18 return "[PAUSED] %1";
19 default
20 return "%1";
24 QString formatedTime(quint32 milliseconds) {
25 quint8 seconds = milliseconds / 1000;
26 quint8 minutes = seconds / 60;
27 quint8 hours = minutes / 60;
29 QString result;
31 if (hours) {
32 if (hours < 10)
33 result += '0';
34 result += QString::number(hours);
35 result += ':';
38 if (minutes < 10)
39 result += '0';
40 result += QString::number(minutes);
41 result += ':';
43 if (seconds < 10)
44 result += '0';
45 result += QString::number(seconds);
46 result += ':';
48 return result;