Git commit fd69b4558c9cf55f5a9bfdeba2c96000a5d6894e by Shantanu Tushar. Committed on 20/07/2012 at 14:58. Pushed by shantanu into branch 'master'. Cleanup mediacenter utility M +0 -62 libs/mediacenter/mediacenter.cpp M +0 -70 libs/mediacenter/mediacenter.h http://commits.kde.org/plasma-mediacenter/fd69b4558c9cf55f5a9bfdeba2c96000a= 5d6894e diff --git a/libs/mediacenter/mediacenter.cpp b/libs/mediacenter/mediacente= r.cpp index 510bba6..0a3fdc4 100644 --- a/libs/mediacenter/mediacenter.cpp +++ b/libs/mediacenter/mediacenter.cpp @@ -30,68 +30,6 @@ = namespace MediaCenter { = -MediaType getType(const QString &media) -{ - QFileInfo info(media); - if (info.exists()) { - KMimeType::Ptr mime =3D KMimeType::findByPath(media); - if (mime->name().startsWith(QLatin1String("image/"))) { - return Picture; - } else if (mime->name().startsWith(QLatin1String("video/"))) { - return Video; - } else if (mime->name().startsWith(QLatin1String("audio/"))) { - return Audio; - } else { - return Invalid; - } - } else { // it is not a file - Solid::Device genericDevice(media); - if (!genericDevice.isValid()) { - return Invalid; - } - Solid::OpticalDisc *opticalDisc =3D genericDevice.as(); - if (!opticalDisc) { - return Invalid; - } - - return OpticalDisc; - } -} - -Media mediaFromMediaSource(const Phonon::MediaSource &source) -{ - if (source.url().isValid()) { - Media media; - media.second =3D KUrl(source.url()).path(); - media.first =3D getType(media.second); - if (media.first =3D=3D MediaCenter::Invalid) { - media.second =3D ""; - return media; - } - return media; - } - - if (!source.fileName().isEmpty()) { - Media media; - media.second =3D source.fileName(); - media.first =3D getType(media.second); - if (media.first =3D=3D MediaCenter::Invalid) { - media.second =3D ""; - return media; - } - return media; - } - - if (!source.deviceName().isEmpty()) { - Media media; - media.second =3D source.deviceName(); - media.first =3D MediaCenter::OpticalDisc; - return media; - } - - return Media(); -} - QHash appendAdditionalMediaRoles (const QHash &roles) { QHash newRoles(roles); diff --git a/libs/mediacenter/mediacenter.h b/libs/mediacenter/mediacenter.h index 8bb48c3..c9d073f 100644 --- a/libs/mediacenter/mediacenter.h +++ b/libs/mediacenter/mediacenter.h @@ -40,77 +40,7 @@ enum AdditionalMediaRoles { ResourceIdRole }; = -enum MediaType { - Invalid =3D 0x0, - Picture =3D 0x1, - Video =3D 0x2, - Audio =3D 0x4, - OpticalDisc =3D 0x8 -}; -Q_DECLARE_FLAGS(MediaTypes, MediaType) - -enum UIComponent { - UIControlBar, - UIInfoBar, - UIBrowser, - UIPlayer, - UIPlaylist, - UIHomeScreen -}; - -enum InfoDisplayMode { - InfoDisplayFloating, - InfoDisplayBottom -}; - -enum PlaybackState { - PlayingState, - StoppedState, - PausedState, - SinglePictureState -}; - -/** - * Each applet needs to be able to accept widgets into - * different zones. The states that send the widgets to the applets, also = send - * this zone information along - */ - -enum LayoutZone { - LeftZone, - MiddleZone, - RightZone, -}; - MEDIACENTER_EXPORT QHash appendAdditionalMediaRoles (cons= t QHash &roles); - -/** - * @typedef Media defines a QPair of MediaCenter::MediaType and QString. - * The first argument is the type of the media while the second is a QStri= ng - * defining the media. It might be both an udi string pointing to the devi= ce - * hosting the media or the path to a media file. - */ -typedef QPair Media; - -/** - * Returns the correct type identifying the source represented - * by the given string. - * - * @param media: the string representing the media. It could be - * either the udi of the device hosting the media - * or the path of the local file. - */ -MEDIACENTER_EXPORT MediaType getType(const QString &media); - -/** - * @return a MediaCenter::Media from the given Phonon::MediaSource or - * an invalid MediaCenter::Media if an error occurrs. - * @note an invalid MediaCenter::Media has MediaType Invalid and empty QSt= ring. - */ -MEDIACENTER_EXPORT Media mediaFromMediaSource(const Phonon::MediaSource &); - -Q_DECLARE_OPERATORS_FOR_FLAGS(MediaCenter::MediaTypes) - } // namespace MediaCenter = #endif // MEDIACENTER_H