streamdirectoryentry_stream.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008-2010  Lukas Sommer < SommerLuk at gmail dot com >
00003 
00004     This program is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU General Public License as
00006     published by the Free Software Foundation; either version 2 of
00007     the License or (at your option) version 3 or any later version
00008     accepted by the membership of KDE e.V. (or its successor approved
00009     by the membership of KDE e.V.), which shall act as a proxy
00010     defined in Section 14 of version 3 of the license.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #include "streamdirectoryentry_stream.h"
00022 
00023 #include <KLocalizedString>
00024 
00025 streamDirectoryEntry_stream::streamDirectoryEntry_stream()
00026 {
00027   name().clear();
00028   bitrate = 0;
00029   currentlyPlaying = false;
00030   streamType = unknown;
00031 };
00032 
00033 streamDirectoryEntry_stream::~streamDirectoryEntry_stream()
00034 {
00035 }
00036 
00037 QString streamDirectoryEntry_stream::formatedStreamType(const type_of_stream streamType)
00038 {
00039   switch (streamType) {
00040     case unknown:
00041       return i18nc("@info/plain type of the stream: unknown", "unknown");
00042     case mp3:
00043       return i18nc(
00044         "@info/plain type of the stream: codec is MP3 (http://en.wikipedia.org/wiki/MP3)",
00045         "MP3");
00046     case ogg:
00047       return i18nc(
00048         "@info/plain type of the stream: container format is Ogg (http://en.wiki"
00049           "pedia.org/wiki/Ogg)",
00050         "Ogg");
00051     case nsv:
00052       return i18nc(
00053         "@info/plain type of the stream: container format is NSV (http://en.wiki"
00054           "pedia.org/wiki/Nullsoft_Streaming_Video)",
00055         "NSV");
00056     case aac:
00057       return i18nc(
00058         "@info/plain type of the stream: codec is AAC (http://en.wiki"
00059           "pedia.org/wiki/Advanced_Audio_Coding)",
00060         "AAC");
00061     case aac_plus:
00062       return i18nc(
00063         "@info/plain type of the stream: codec is AACplus (http://en.wikipedia.org/wiki/AACplus)",
00064         "AACplus");
00065     default:
00066       return QString();
00067   };
00068 }
00069 
00070 QVariant streamDirectoryEntry_stream::rawData(const int column) const
00071 {
00072   if (column == 2) {
00073     return bitrate;
00074   } else {
00075     return data(column);
00076   };
00077 }
00078 
00079 QVariant streamDirectoryEntry_stream::data(const int column) const
00080 {
00081   switch (column) {
00082     case 0:
00083       return name();
00084     case 1:
00085       return formatedStreamType(streamType);
00086     case 2:
00087       if (bitrate <= 0) {
00088         return QVariant();
00089       } else {
00090         return i18ncp(
00091           "@item This makes a nicly formated string for the bitrate of a stream - %1 is an "
00092             "integer. WARNING: Unit has changed! It is now kbit instead of Kibit. "
00093             "This means 1000 bit (NOT 1024).",
00094           "%1 kbit/s",
00095           "%1 kbit/s",
00096           bitrate);
00097       };
00098     case 3:
00099       if (currentlyPlaying) {
00100         return i18nc("@item:intable Whether the stream provides (in its meta data) information "
00101                        "about the currently played song",
00102                      "yes");
00103       } else {
00104         return i18nc("@item:intable Whether the stream provides (in its meta data) information "
00105                        "about the currently played song",
00106                      "no");
00107       };
00108     case 4:
00109       return value().prettyUrl();
00110     default:
00111       return QVariant();
00112   }
00113 }
00114 
00115 bool streamDirectoryEntry_stream::hasChildren() const
00116 {
00117   return false;
00118 }

doxygen