OSDN Git Service

Detect and show audio bitrate + added an option to copy a file's meta info to the...
authorlordmulder <mulder2@gmx.de>
Tue, 31 May 2011 17:04:45 +0000 (19:04 +0200)
committerlordmulder <mulder2@gmx.de>
Tue, 31 May 2011 17:04:45 +0000 (19:04 +0200)
20 files changed:
etc/Translation/Blank.ts
etc/Translation/LameXP_DE.ts
etc/Translation/LameXP_ES.ts
etc/Translation/LameXP_FR.ts
etc/Translation/LameXP_IT.ts
etc/Translation/LameXP_KR.ts
etc/Translation/LameXP_RU.ts
etc/Translation/LameXP_UK.ts
gui/MetaInfo.ui
res/Icons.qrc
res/localization/LameXP_DE.qm
src/Config.h
src/Dialog_MainWindow.cpp
src/Dialog_MetaInfo.cpp
src/Dialog_MetaInfo.h
src/Model_AudioFile.cpp
src/Model_AudioFile.h
src/Model_MetaInfo.cpp
src/Model_MetaInfo.h
src/Thread_FileAnalyzer.cpp

index eab0e32..47fd1e5 100644 (file)
         <source>Version</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
 <context>
     <name>MetaInfoDialog</name>
     <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
         <source>Load Artwork From File</source>
         <translation type="unfinished"></translation>
     </message>
index 78b6a37..a2ed7c5 100644 (file)
         <source>Version</source>
         <translation>Version</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation>Bitrate</translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation>konstant</translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation>variabel</translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation>Artwork konnte nicht aus der Ausgewählten Datei geladen werden!</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation>Diese Information bearbeiten</translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation>Alles in den Metadaten-Tab kopieren</translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation>Metainformationen löschen</translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index d877c86..7903f1b 100644 (file)
         <source>Version</source>
         <translation>Versión</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation>¡Lo sentimos, ha habido un error al cargar la carátula desde el archivo seleccionado!</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index 12fa1cc..9dceef4 100644 (file)
         <source>Version</source>
         <translation>Version</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
@@ -1641,6 +1653,18 @@ Ouvrir le dossier récursivement...</translation>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation>Impossible de charger l&apos;oeuvre depuis le fichier sélectionné !</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index f467325..7327dbd 100644 (file)
         <source>Version</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation type="unfinished"></translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index d481399..017b4c7 100644 (file)
         <source>Version</source>
         <translation type="unfinished">버전</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation type="unfinished">죄송하지만, 선택한 파일로부터 아트워크 불러기가 실패되었습니다!</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index 8bf9c45..0d0fc72 100644 (file)
         <source>Version</source>
         <translation>Версия</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation type="unfinished">Извините, немогу загрузит картинку из выделенного файла!</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index 482608d..98d54dd 100644 (file)
         <source>Version</source>
         <translation>Версія</translation>
     </message>
+    <message>
+        <source>Bitrate</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Constant</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Variable</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>CueImportDialog</name>
         <source>Sorry, failed to load artwork from selected file!</source>
         <translation>Вибачте, але неможливо завантажити обкладинку з вибраного файла!</translation>
     </message>
+    <message>
+        <source>Edit this Information</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Copy everything to Meta Info tab</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <source>Clear all Meta Info</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>MetaInfoModel</name>
index 017373f..97bdb02 100644 (file)
        </property>
        <item>
         <widget class="QTableView" name="tableView">
+         <property name="contextMenuPolicy">
+          <enum>Qt::CustomContextMenu</enum>
+         </property>
          <property name="selectionMode">
           <enum>QAbstractItemView::SingleSelection</enum>
          </property>
   <include location="../res/Images.qrc"/>
   <include location="../res/Images.qrc"/>
   <include location="../res/Images.qrc"/>
+  <include location="../res/Images.qrc"/>
  </resources>
  <connections>
   <connection>
index 703a9a4..51cf126 100644 (file)
@@ -64,6 +64,7 @@
     <file>icons/page_white_cplusplus.png</file>
     <file>icons/page_white_add.png</file>
     <file>icons/page_white_cd.png</file>
+    <file>icons/page_white_copy.png</file>
     <file>icons/paste_plain.png</file>
     <file>icons/photo.png</file>
     <file>icons/play.png</file>
index ece2cac..15c1a1c 100644 (file)
Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ
index 56b45da..8a09bbd 100644 (file)
@@ -29,8 +29,8 @@
 #define VER_LAMEXP_MINOR_HI                                    0
 #define VER_LAMEXP_MINOR_LO                                    2
 #define VER_LAMEXP_TYPE                                                Beta
-#define VER_LAMEXP_PATCH                                       5
-#define VER_LAMEXP_BUILD                                       554
+#define VER_LAMEXP_PATCH                                       6
+#define VER_LAMEXP_BUILD                                       558
 
 ///////////////////////////////////////////////////////////////////////////////
 // Tools versions
index 9979cbe..2b48066 100644 (file)
@@ -648,7 +648,11 @@ void MainWindow::showEvent(QShowEvent *event)
        m_accepted = false;
        m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
        sourceModelChanged();
-       tabWidget->setCurrentIndex(0);
+       
+       if(!event->spontaneous())
+       {
+               tabWidget->setCurrentIndex(0);
+       }
 
        if(m_firstTimeShown)
        {
@@ -1760,6 +1764,13 @@ void MainWindow::showDetailsButtonClicked(void)
                (
                        iResult = metaInfoDialog->exec(file, index.row() > 0, index.row() < m_fileListModel->rowCount() - 1);
                )
+               
+               if(iResult == INT_MAX)
+               {
+                       m_metaInfoModel->assignInfoFrom(file);
+                       tabWidget->setCurrentIndex(tabWidget->indexOf(tabMetaData));
+                       break;
+               }
 
                if(!iResult) break;
        }
index 45af622..ed05a38 100644 (file)
@@ -62,12 +62,21 @@ MetaInfoDialog::MetaInfoDialog(QWidget *parent)
        connect(editButton, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
 
        //Create context menu
-       m_contextMenu = new QMenu();
-       QAction *loadArtworkAction = m_contextMenu->addAction(QIcon(":/icons/folder_image.png"), tr("Load Artwork From File"));
-       QAction *clearArtworkAction = m_contextMenu->addAction(QIcon(":/icons/bin.png"), tr("Clear Artwork"));
+       m_contextMenuInfo = new QMenu();
+       m_contextMenuArtwork = new QMenu();
+       QAction *editMetaInfoAction = m_contextMenuInfo->addAction(QIcon(":/icons/table_edit.png"), tr("Edit this Information"));
+       QAction *copyMetaInfoAction = m_contextMenuInfo->addAction(QIcon(":/icons/page_white_copy.png"), tr("Copy everything to Meta Info tab"));
+       QAction *clearMetaInfoAction = m_contextMenuInfo->addAction(QIcon(":/icons/bin.png"), tr("Clear all Meta Info"));
+       QAction *loadArtworkAction = m_contextMenuArtwork->addAction(QIcon(":/icons/folder_image.png"), tr("Load Artwork From File"));
+       QAction *clearArtworkAction = m_contextMenuArtwork->addAction(QIcon(":/icons/bin.png"), tr("Clear Artwork"));
+       SET_FONT_BOLD(editMetaInfoAction, true);
        SET_FONT_BOLD(loadArtworkAction, true);
-       connect(labelArtwork, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
-       connect(frameArtwork, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
+       connect(tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(infoContextMenuRequested(QPoint)));
+       connect(labelArtwork, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(artworkContextMenuRequested(QPoint)));
+       connect(frameArtwork, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(artworkContextMenuRequested(QPoint)));
+       connect(editMetaInfoAction, SIGNAL(triggered(bool)), this, SLOT(editButtonClicked()));
+       connect(copyMetaInfoAction, SIGNAL(triggered(bool)), this, SLOT(copyMetaInfoActionTriggered()));
+       connect(clearMetaInfoAction, SIGNAL(triggered(bool)), this, SLOT(clearMetaInfoActionTriggered()));
        connect(loadArtworkAction, SIGNAL(triggered(bool)), this, SLOT(editButtonClicked()));
        connect(clearArtworkAction, SIGNAL(triggered(bool)), this, SLOT(clearArtworkActionTriggered()));
 
@@ -77,7 +86,8 @@ MetaInfoDialog::MetaInfoDialog(QWidget *parent)
 
 MetaInfoDialog::~MetaInfoDialog(void)
 {
-       LAMEXP_DELETE(m_contextMenu);
+       LAMEXP_DELETE(m_contextMenuInfo);
+       LAMEXP_DELETE(m_contextMenuArtwork);
 }
 
 ////////////////////////////////////////////////////////////
@@ -165,8 +175,21 @@ void MetaInfoDialog::editButtonClicked(void)
        }
 }
 
+void MetaInfoDialog::infoContextMenuRequested(const QPoint &pos)
+{
+       QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
+       QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
 
-void MetaInfoDialog::contextMenuRequested(const QPoint &pos)
+       if(sender)
+       {
+               if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
+               {
+                       m_contextMenuInfo->popup(sender->mapToGlobal(pos));
+               }
+       }
+}
+
+void MetaInfoDialog::artworkContextMenuRequested(const QPoint &pos)
 {
        QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
        QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
@@ -175,11 +198,24 @@ void MetaInfoDialog::contextMenuRequested(const QPoint &pos)
        {
                if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
                {
-                       m_contextMenu->popup(sender->mapToGlobal(pos));
+                       m_contextMenuArtwork->popup(sender->mapToGlobal(pos));
                }
        }
 }
 
+void MetaInfoDialog::copyMetaInfoActionTriggered(void)
+{
+       done(INT_MAX);
+}
+
+void MetaInfoDialog::clearMetaInfoActionTriggered(void)
+{
+       if(MetaInfoModel *model = dynamic_cast<MetaInfoModel*>(tableView->model()))
+       {
+               model->clearData(true);
+       }
+}
+
 void MetaInfoDialog::clearArtworkActionTriggered(void)
 {
        labelArtwork->setPixmap(QPixmap::fromImage(QImage(":/images/CD.png")));
index fcca527..ff700ac 100644 (file)
@@ -40,9 +40,13 @@ private slots:
        void upButtonClicked(void);
        void downButtonClicked(void);
        void editButtonClicked(void);
-       void contextMenuRequested(const QPoint &pos);
+       void infoContextMenuRequested(const QPoint &pos);
+       void artworkContextMenuRequested(const QPoint &pos);
+       void copyMetaInfoActionTriggered(void);
+       void clearMetaInfoActionTriggered(void);
        void clearArtworkActionTriggered(void);
 
 private:
-       QMenu *m_contextMenu;
+       QMenu *m_contextMenuInfo;
+       QMenu *m_contextMenuArtwork;
 };
index a6a2f2d..4a57dfa 100644 (file)
@@ -1,4 +1,4 @@
-///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
 //
@@ -26,6 +26,8 @@
 #include <QMutexLocker>
 #include <QFile>
 
+#define U16Str(X) QString::fromUtf16(reinterpret_cast<const unsigned short*>(L##X))
+
 ////////////////////////////////////////////////////////////
 // Constructor & Destructor
 ////////////////////////////////////////////////////////////
@@ -51,6 +53,8 @@ AudioFileModel::AudioFileModel(const AudioFileModel &model, bool copyMetaInfo)
        setFormatAudioSamplerate(model.m_formatAudioSamplerate);
        setFormatAudioChannels(model.m_formatAudioChannels);
        setFormatAudioBitdepth(model.m_formatAudioBitdepth);
+       setFormatAudioBitrate(model.m_formatAudioBitrate);
+       setFormatAudioBitrateMode(model.m_formatAudioBitrateMode);
        setFileDuration(model.m_fileDuration);
 
        if(copyMetaInfo)
@@ -87,6 +91,8 @@ AudioFileModel &AudioFileModel::operator=(const AudioFileModel &model)
        setFormatAudioSamplerate(model.m_formatAudioSamplerate);
        setFormatAudioChannels(model.m_formatAudioChannels);
        setFormatAudioBitdepth(model.m_formatAudioBitdepth);
+       setFormatAudioBitrate(model.m_formatAudioBitrate);
+       setFormatAudioBitrateMode(model.m_formatAudioBitrateMode);
 
        return (*this);
 }
@@ -122,6 +128,8 @@ void AudioFileModel::resetAll(void)
        m_formatAudioSamplerate = 0;
        m_formatAudioChannels = 0;
        m_formatAudioBitdepth = 0;
+       m_formatAudioBitrate = 0;
+       m_formatAudioBitrateMode = BitrateModeUndefined;
 }
 
 ////////////////////////////////////////////////////////////
@@ -222,6 +230,16 @@ unsigned int AudioFileModel::formatAudioBitdepth(void) const
        return m_formatAudioBitdepth;
 }
 
+unsigned int AudioFileModel::formatAudioBitrate(void) const
+{
+       return m_formatAudioBitrate;
+}
+
+unsigned int  AudioFileModel::formatAudioBitrateMode(void) const
+{
+       return m_formatAudioBitrateMode;
+}
+
 const QString AudioFileModel::fileDurationInfo(void) const
 {
        if(m_fileDuration)
@@ -295,6 +313,21 @@ const QString AudioFileModel::formatAudioCompressInfo(void) const
                {
                        info.append(QString(", %1: %2").arg(tr("Version"), m_formatAudioVersion));
                }
+               if(m_formatAudioBitrate > 0)
+               {
+                       switch(m_formatAudioBitrateMode)
+                       {
+                       case BitrateModeConstant:
+                               info.append(U16Str(", %1: %2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate), tr("Constant")));
+                               break;
+                       case BitrateModeVariable:
+                               info.append(U16Str(", %1: \u2248%2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate), tr("Variable")));
+                               break;
+                       default:
+                               info.append(U16Str(", %1: %2 kbps").arg(tr("Bitrate"), QString::number(m_formatAudioBitrate)));
+                               break;
+                       }
+               }
                return info;
        }
        else
@@ -402,6 +435,16 @@ void AudioFileModel::setFormatAudioBitdepth(unsigned int bitdepth)
        m_formatAudioBitdepth = bitdepth;
 }
 
+void AudioFileModel::setFormatAudioBitrate(unsigned int bitrate)
+{
+       m_formatAudioBitrate = bitrate;
+}
+
+void AudioFileModel::setFormatAudioBitrateMode(unsigned int bitrateMode)
+{
+       m_formatAudioBitrateMode = bitrateMode;
+}
+
 void AudioFileModel::updateMetaInfo(const AudioFileModel &model)
 {
        if(!model.fileArtist().isEmpty()) setFileArtist(model.fileArtist());
index 25031b4..ef6347b 100644 (file)
@@ -38,6 +38,13 @@ public:
        AudioFileModel &operator=(const AudioFileModel &model);
        ~AudioFileModel(void);
 
+       enum BitrateMode
+       {
+               BitrateModeUndefined = 0,
+               BitrateModeConstant = 1,
+               BitrateModeVariable = 2,
+       };
+
        //-----------------------
        //Getters
        //-----------------------
@@ -61,7 +68,9 @@ public:
        unsigned int formatAudioSamplerate(void) const;
        unsigned int formatAudioChannels(void) const;
        unsigned int formatAudioBitdepth(void) const;
-
+       unsigned int formatAudioBitrate(void) const;
+       unsigned int formatAudioBitrateMode(void) const;
+       
        const QString fileDurationInfo(void) const;
        const QString formatContainerInfo(void) const;
        const QString formatAudioBaseInfo(void) const;
@@ -91,6 +100,8 @@ public:
        void setFormatAudioSamplerate(unsigned int samplerate);
        void setFormatAudioChannels(unsigned int channels);
        void setFormatAudioBitdepth(unsigned int bitdepth);
+       void setFormatAudioBitrate(unsigned int bitrate);
+       void setFormatAudioBitrateMode(unsigned int bitrateMode);
 
        void updateMetaInfo(const AudioFileModel &model);
 
@@ -114,6 +125,8 @@ private:
        unsigned int m_formatAudioSamplerate;
        unsigned int m_formatAudioChannels;
        unsigned int m_formatAudioBitdepth;
+       unsigned int m_formatAudioBitrate;
+       unsigned int m_formatAudioBitrateMode;
 
        void resetAll(void);
 };
index df0ca9d..a1d7bc4 100644 (file)
@@ -435,31 +435,41 @@ void MetaInfoModel::editArtwork(const QString &imagePath)
        m_audioFile->setFileCover(imagePath, false);
 }
 
-void MetaInfoModel::clearData(void)
+void MetaInfoModel::clearData(bool clearMetaOnly)
 {
        beginResetModel();
 
        m_textUnknown = QString("(%1)").arg(tr("Unknown"));
        m_textNotSpecified = QString("(%1)").arg(tr("Not Specified"));
 
-       m_audioFile->setFilePath(QString());
-       m_audioFile->setFileName(QString());
        m_audioFile->setFileArtist(QString());
        m_audioFile->setFileAlbum(QString());
        m_audioFile->setFileGenre(QString());
        m_audioFile->setFileComment(tr("Encoded with LameXP"));
        m_audioFile->setFileCover(QString(), false);
        m_audioFile->setFileYear(0);
-       m_audioFile->setFilePosition(UINT_MAX);
-       m_audioFile->setFileDuration(0);
-       m_audioFile->setFormatContainerType(QString());
-       m_audioFile->setFormatContainerProfile(QString());
-       m_audioFile->setFormatAudioType(QString());
-       m_audioFile->setFormatAudioProfile(QString());
-       m_audioFile->setFormatAudioVersion(QString());
-       m_audioFile->setFormatAudioSamplerate(0);
-       m_audioFile->setFormatAudioChannels(0);
-       m_audioFile->setFormatAudioBitdepth(0);
+       m_audioFile->setFilePosition(m_offset ? UINT_MAX : 0);
+
+       if(!clearMetaOnly)
+       {
+               m_audioFile->setFilePath(QString());
+               m_audioFile->setFileName(QString());
+               m_audioFile->setFileDuration(0);
+               m_audioFile->setFormatContainerType(QString());
+               m_audioFile->setFormatContainerProfile(QString());
+               m_audioFile->setFormatAudioType(QString());
+               m_audioFile->setFormatAudioProfile(QString());
+               m_audioFile->setFormatAudioVersion(QString());
+               m_audioFile->setFormatAudioSamplerate(0);
+               m_audioFile->setFormatAudioChannels(0);
+               m_audioFile->setFormatAudioBitdepth(0);
+       }
+       else
+       {
+               QString temp = QFileInfo(m_audioFile->filePath()).baseName();
+               temp = temp.split("-", QString::SkipEmptyParts).last().trimmed();
+               m_audioFile->setFileName(temp);
+       }
 
        endResetModel();
 }
@@ -467,4 +477,11 @@ void MetaInfoModel::clearData(void)
 Qt::ItemFlags MetaInfoModel::flags(const QModelIndex &index) const
 {
        return QAbstractTableModel::flags(index);
-}
\ No newline at end of file
+}
+
+void MetaInfoModel::assignInfoFrom(AudioFileModel &file)
+{
+       beginResetModel();
+       m_audioFile->updateMetaInfo(file);
+       endResetModel();
+}
index 855fa46..0c82174 100644 (file)
@@ -43,7 +43,8 @@ public:
        Qt::ItemFlags flags(const QModelIndex &index) const;
        void editItem(const QModelIndex &index, QWidget *parent);
        void editArtwork(const QString &imagePath);
-       void clearData(void);
+       void assignInfoFrom(AudioFileModel &file);
+       void clearData(bool clearMetaOnly = false);
 
 private:
        AudioFileModel* m_audioFile;
index 58f5682..0bd0fcf 100644 (file)
@@ -380,20 +380,50 @@ void FileAnalyzer::updateInfo(AudioFileModel &audioFile, const QString &key, con
                }
                else if(!key.compare("Channel(s)", Qt::CaseInsensitive))
                {
-                       if(!audioFile.formatAudioChannels()) audioFile.setFormatAudioChannels(value.split(" ", QString::SkipEmptyParts).first().toInt());
+                       if(!audioFile.formatAudioChannels()) audioFile.setFormatAudioChannels(value.split(" ", QString::SkipEmptyParts).first().toUInt());
                }
                else if(!key.compare("Sampling rate", Qt::CaseInsensitive))
                {
-                       if(!audioFile.formatAudioSamplerate()) audioFile.setFormatAudioSamplerate(ceil(value.split(" ", QString::SkipEmptyParts).first().toFloat() * 1000.0f));
+                       if(!audioFile.formatAudioSamplerate())
+                       {
+                               bool ok = false;
+                               float fTemp = abs(value.split(" ", QString::SkipEmptyParts).first().toFloat(&ok));
+                               if(ok) audioFile.setFormatAudioSamplerate(static_cast<unsigned int>(floor(fTemp * 1000.0f + 0.5f)));
+                       }
                }
                else if(!key.compare("Bit depth", Qt::CaseInsensitive))
                {
-                       if(!audioFile.formatAudioBitdepth()) audioFile.setFormatAudioBitdepth(value.split(" ", QString::SkipEmptyParts).first().toInt());
+                       if(!audioFile.formatAudioBitdepth()) audioFile.setFormatAudioBitdepth(value.split(" ", QString::SkipEmptyParts).first().toUInt());
                }
                else if(!key.compare("Duration", Qt::CaseInsensitive))
                {
                        if(!audioFile.fileDuration()) audioFile.setFileDuration(parseDuration(value));
                }
+               else if(!key.compare("Bit rate", Qt::CaseInsensitive))
+               {
+                       if(!audioFile.formatAudioBitrate())
+                       {
+                               bool ok = false;
+                               unsigned int uiTemp = value.split(" ", QString::SkipEmptyParts).first().toUInt(&ok);
+                               if(ok)
+                               {
+                                       audioFile.setFormatAudioBitrate(uiTemp);
+                               }
+                               else
+                               {
+                                       float fTemp = abs(value.split(" ", QString::SkipEmptyParts).first().toFloat(&ok));
+                                       if(ok) audioFile.setFormatAudioBitrate(static_cast<unsigned int>(floor(fTemp + 0.5f)));
+                               }
+                       }
+               }
+               else if(!key.compare("Bit rate mode", Qt::CaseInsensitive))
+               {
+                       if(audioFile.formatAudioBitrateMode() == AudioFileModel::BitrateModeUndefined)
+                       {
+                               if(!value.compare("Constant", Qt::CaseInsensitive)) audioFile.setFormatAudioBitrateMode(AudioFileModel::BitrateModeConstant);
+                               if(!value.compare("Variable", Qt::CaseInsensitive)) audioFile.setFormatAudioBitrateMode(AudioFileModel::BitrateModeVariable);
+                       }
+               }
                break;
        }
 }