From e235adde49d24b6d034ef2b74b28ad2a6cea2fee Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Tue, 22 Sep 2009 18:45:40 +0000 Subject: enabled mpc plugin, fixed some bugs git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1250 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Input/mpc/detailsdialog.cpp | 96 --------------------------------- 1 file changed, 96 deletions(-) delete mode 100644 src/plugins/Input/mpc/detailsdialog.cpp (limited to 'src/plugins/Input/mpc/detailsdialog.cpp') diff --git a/src/plugins/Input/mpc/detailsdialog.cpp b/src/plugins/Input/mpc/detailsdialog.cpp deleted file mode 100644 index 80a7fd108..000000000 --- a/src/plugins/Input/mpc/detailsdialog.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Ilya Kotov * - * forkotov02@hotmail.ru * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#include -#include -#include -#include - -#include -#include - -#include "detailsdialog.h" - -#define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) -#define TStringToQString_qt4(s) QString::fromUtf8(s.toCString(TRUE)).trimmed() - -DetailsDialog::DetailsDialog(QWidget *parent, const QString &path) - : AbstractDetailsDialog(parent) -{ - m_path = path; - if (QFile::exists(m_path)) - { - loadMPCInfo(); - loadTags(); - blockSaveButton(!QFileInfo(m_path).isWritable()); - } - else - blockSaveButton(); -} - -DetailsDialog::~DetailsDialog() -{} - -void DetailsDialog::loadMPCInfo() -{ - TagLib::MPC::File f (m_path.toLocal8Bit()); - QMap ap; - QString text = QString("%1").arg(f.audioProperties()->length()/60); - text +=":"+QString("%1").arg(f.audioProperties()->length()%60,2,10,QChar('0')); - ap.insert(tr("Length"), text); - ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(f.audioProperties()->sampleRate())); - ap.insert(tr("Channels"), QString("%1").arg(f.audioProperties()->channels())); - ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(f.audioProperties()->bitrate())); - ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(f.length()/1024)); - setAudioProperties(ap); -} - -void DetailsDialog::loadTags() -{ - TagLib::FileRef f (m_path.toLocal8Bit()); - setMetaData(Qmmp::TITLE, TStringToQString_qt4(f.tag()->title())); - setMetaData(Qmmp::ARTIST, TStringToQString_qt4(f.tag()->artist())); - setMetaData(Qmmp::ALBUM, TStringToQString_qt4(f.tag()->album())); - setMetaData(Qmmp::COMMENT, TStringToQString_qt4(f.tag()->comment())); - setMetaData(Qmmp::GENRE, TStringToQString_qt4(f.tag()->genre())); - setMetaData(Qmmp::YEAR, f.tag()->year()); - setMetaData(Qmmp::TRACK, f.tag()->track()); - setMetaData(Qmmp::URL, m_path); - TagLib::MPC::File *file = dynamic_cast(f.file()); - TagLib::APE::Item fld; - if(file->APETag() && !(fld = file->APETag()->itemListMap()["COMPOSER"]).isEmpty()) - setMetaData(Qmmp::COMPOSER, TStringToQString_qt4(fld.toString())); -} - -void DetailsDialog::writeTags() -{ - TagLib::FileRef f (m_path.toLocal8Bit()); - f.tag()->setTitle(QStringToTString_qt4(strMetaData(Qmmp::TITLE))); - f.tag()->setArtist(QStringToTString_qt4(strMetaData(Qmmp::ARTIST))); - f.tag()->setAlbum(QStringToTString_qt4(strMetaData(Qmmp::ALBUM))); - f.tag()->setComment(QStringToTString_qt4(strMetaData(Qmmp::COMMENT))); - f.tag()->setGenre(QStringToTString_qt4(strMetaData(Qmmp::GENRE))); - f.tag()->setYear(intMetaData(Qmmp::YEAR)); - f.tag()->setTrack(intMetaData(Qmmp::TRACK)); - TagLib::MPC::File *file = dynamic_cast(f.file()); - strMetaData(Qmmp::COMPOSER).isEmpty() ? - file->APETag()->removeItem("COMPOSER"): - file->APETag()->addValue("COMPOSER", QStringToTString_qt4(strMetaData(Qmmp::COMPOSER)), TRUE); - f.save(); -} -- cgit v1.2.3-13-gbd6f