aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/archive/archivemetadatamodel.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-09-17 18:57:40 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-09-17 18:57:40 +0000
commit477788d7dd83ecac5485f3d7c927229a9885ec27 (patch)
tree583f16900e2c1afa6fd60f9212c7a97e980721a0 /src/plugins/Input/archive/archivemetadatamodel.cpp
parentb7b22bfdf2fbc820f0d07a74c4bc0929fe990848 (diff)
downloadqmmp-477788d7dd83ecac5485f3d7c927229a9885ec27.tar.gz
qmmp-477788d7dd83ecac5485f3d7c927229a9885ec27.tar.bz2
qmmp-477788d7dd83ecac5485f3d7c927229a9885ec27.zip
archive plugin: added metadata model
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6731 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/archive/archivemetadatamodel.cpp')
-rw-r--r--src/plugins/Input/archive/archivemetadatamodel.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/plugins/Input/archive/archivemetadatamodel.cpp b/src/plugins/Input/archive/archivemetadatamodel.cpp
new file mode 100644
index 000000000..02ee77770
--- /dev/null
+++ b/src/plugins/Input/archive/archivemetadatamodel.cpp
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2016 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "archiveinputdevice.h"
+#include "archivetagreader.h"
+#include "archivemetadatamodel.h"
+
+ArchiveMetaDataModel::ArchiveMetaDataModel(const QString &url, QObject *parent) :
+ MetaDataModel(parent)
+{
+ m_reader = 0;
+ m_input = 0;
+ m_input = new ArchiveInputDevice(url);
+ if(m_input->isOpen())
+ m_reader = new ArchiveTagReader(m_input, url);
+}
+
+ArchiveMetaDataModel::~ArchiveMetaDataModel()
+{
+ if(m_reader)
+ delete m_reader;
+ if(m_input)
+ delete m_input;
+}
+
+QHash<QString, QString> ArchiveMetaDataModel::audioProperties()
+{
+ QHash <QString, QString> ap;
+ if(m_reader && m_reader->audioProperties())
+ {
+ TagLib::AudioProperties *p = m_reader->audioProperties();
+ ap.insert(tr("Length"), QString("%1:%2").arg(p->length()/60).arg(p->length()%60, 2, 10, QChar('0')));
+ ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(p->sampleRate()));
+ ap.insert(tr("Channels"), QString("%1").arg(p->channels()));
+ ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(p->bitrate()));
+ ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(m_input->size()/1024));
+ }
+ return ap;
+}