File indexing completed on 2024-05-05 04:48:16

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Maximilian Kossick <maximilian.kossick@googlemail.com>            *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef AMAROK_METAUTILITY_H
0018 #define AMAROK_METAUTILITY_H
0019 
0020 #include "core/amarokcore_export.h"
0021 #include "core/meta/forward_declarations.h"
0022 #include "core/meta/support/MetaConstants.h"
0023 
0024 #include <QMap>
0025 #include <QString>
0026 #include <QVariant>
0027 
0028 namespace Meta
0029 {
0030     class Track;
0031 
0032     namespace Field
0033     {
0034 
0035         //deprecated
0036         AMAROKCORE_EXPORT QVariantMap mapFromTrack( const Meta::TrackPtr &track );
0037         //this method will return a map with keys that are compatible to the fdo MPRIS 1.0 specification
0038         AMAROKCORE_EXPORT QVariantMap mprisMapFromTrack( const Meta::TrackPtr &track );
0039         //this method will return a map with keys that are compatible to the fdo MPRIS 2.0 specification
0040         AMAROKCORE_EXPORT QVariantMap mpris20MapFromTrack( const Meta::TrackPtr &track );
0041         AMAROKCORE_EXPORT void updateTrack( Meta::TrackPtr track, const QVariantMap &metadata );
0042         AMAROKCORE_EXPORT QString xesamPrettyToFullFieldName( const QString &name );
0043         AMAROKCORE_EXPORT QString xesamFullToPrettyFieldName( const QString &name );
0044     }
0045 
0046 
0047     AMAROKCORE_EXPORT QString msToPrettyTime( qint64 ms );
0048 
0049     /** Returns the character representation for the time duration.
0050         This is a pretty short representation looking like this: 3:45.
0051         It is used in the playlist.
0052         It is not useful for times above a 24 hours.
0053     */
0054     AMAROKCORE_EXPORT QString secToPrettyTime( int seconds );
0055 
0056     /** Returns the character representation for the time duration.
0057         This is a longer human friendly representation looking like this: 5 minutes even when
0058         the actual seconds are 307.
0059     */
0060     AMAROKCORE_EXPORT QString secToPrettyTimeLong( int seconds );
0061 
0062     AMAROKCORE_EXPORT QString prettyFilesize( quint64 size );
0063     AMAROKCORE_EXPORT QString prettyBitrate( int bitrate );
0064 
0065 }
0066 
0067 #endif