2010-11-06 23:04:47 +01:00
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
2013-02-08 23:50:51 +01:00
// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
2010-11-06 23:04:47 +01:00
//
// 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.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
# include "Model_MetaInfo.h"
# include "Genres.h"
# include <QMessageBox>
# include <QInputDialog>
2010-11-20 19:16:04 +01:00
# include <QFileInfo>
2010-11-06 23:04:47 +01:00
2010-11-10 19:44:51 +01:00
# define MODEL_ROW_COUNT 12
2011-01-14 19:45:14 +01:00
# define CHECK1(STR) (STR.isEmpty() ? (m_offset ? m_textNotSpecified : m_textUnknown) : STR)
# define CHECK2(VAL) ((VAL > 0) ? QString::number(VAL) : (m_offset ? m_textNotSpecified : m_textUnknown))
2010-11-06 23:04:47 +01:00
# define CHECK3(STR) (STR.isEmpty() ? Qt::darkGray : QVariant())
# define CHECK4(VAL) ((VAL == 0) ? Qt::darkGray : QVariant())
2010-12-10 22:57:48 +01:00
# define EXPAND(STR) QString(STR).leftJustified(96, ' ')
2010-11-06 23:04:47 +01:00
////////////////////////////////////////////////////////////
// Constructor & Destructor
////////////////////////////////////////////////////////////
2010-11-10 19:44:51 +01:00
MetaInfoModel : : MetaInfoModel ( AudioFileModel * file , unsigned int offset )
2010-11-06 23:04:47 +01:00
{
2010-11-10 19:44:51 +01:00
if ( offset > = MODEL_ROW_COUNT )
{
throw " Offset is out of range! " ;
}
2011-01-14 19:45:14 +01:00
m_textUnknown = QString ( " (%1) " ) . arg ( tr ( " Unknown " ) ) ;
m_textNotSpecified = QString ( " (%1) " ) . arg ( tr ( " Not Specified " ) ) ;
2010-11-06 23:04:47 +01:00
m_audioFile = file ;
2010-11-10 19:44:51 +01:00
m_offset = offset ;
2010-11-06 23:04:47 +01:00
}
MetaInfoModel : : ~ MetaInfoModel ( void )
{
}
////////////////////////////////////////////////////////////
// Public Functions
////////////////////////////////////////////////////////////
int MetaInfoModel : : columnCount ( const QModelIndex & parent ) const
{
return 2 ;
}
int MetaInfoModel : : rowCount ( const QModelIndex & parent ) const
{
2010-11-10 19:44:51 +01:00
return MODEL_ROW_COUNT - m_offset ;
2010-11-06 23:04:47 +01:00
}
QVariant MetaInfoModel : : data ( const QModelIndex & index , int role ) const
{
if ( role = = Qt : : DisplayRole )
{
2010-11-10 19:44:51 +01:00
switch ( index . row ( ) + m_offset )
2010-11-06 23:04:47 +01:00
{
case 0 :
2011-01-01 19:28:19 +01:00
return ( ! index . column ( ) ) ? tr ( " Full Path " ) : CHECK1 ( m_audioFile - > filePath ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 1 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Format " ) : CHECK1 ( m_audioFile - > audioBaseInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 2 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Container " ) : CHECK1 ( m_audioFile - > containerInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 3 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Compression " ) : CHECK1 ( m_audioFile - > audioCompressInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 4 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Duration " ) : CHECK1 ( m_audioFile - > durationInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 5 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Title " ) : CHECK1 ( m_audioFile - > metaInfo ( ) . title ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 6 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Artist " ) : CHECK1 ( m_audioFile - > metaInfo ( ) . artist ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 7 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Album " ) : CHECK1 ( m_audioFile - > metaInfo ( ) . album ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 8 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Genre " ) : CHECK1 ( m_audioFile - > metaInfo ( ) . genre ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 9 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Year " ) : CHECK2 ( m_audioFile - > metaInfo ( ) . year ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 10 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Position " ) : ( ( m_audioFile - > metaInfo ( ) . position ( ) = = UINT_MAX ) ? tr ( " Generate from list position " ) : CHECK2 ( m_audioFile - > metaInfo ( ) . position ( ) ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 11 :
2013-10-12 22:55:41 +02:00
return ( ! index . column ( ) ) ? tr ( " Comment " ) : CHECK1 ( m_audioFile - > metaInfo ( ) . comment ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
default :
return QVariant ( ) ;
break ;
}
}
else if ( role = = Qt : : DecorationRole & & index . column ( ) = = 0 )
{
2010-11-10 19:44:51 +01:00
switch ( index . row ( ) + m_offset )
2010-11-06 23:04:47 +01:00
{
case 0 :
return QIcon ( " :/icons/folder_page.png " ) ;
break ;
case 1 :
return QIcon ( " :/icons/sound.png " ) ;
break ;
case 2 :
return QIcon ( " :/icons/package.png " ) ;
break ;
case 3 :
return QIcon ( " :/icons/compress.png " ) ;
break ;
case 4 :
return QIcon ( " :/icons/clock_play.png " ) ;
break ;
case 5 :
return QIcon ( " :/icons/music.png " ) ;
break ;
case 6 :
return QIcon ( " :/icons/user.png " ) ;
break ;
case 7 :
return QIcon ( " :/icons/cd.png " ) ;
break ;
case 8 :
return QIcon ( " :/icons/star.png " ) ;
break ;
case 9 :
return QIcon ( " :/icons/date.png " ) ;
break ;
case 10 :
return QIcon ( " :/icons/timeline_marker.png " ) ;
break ;
case 11 :
return QIcon ( " :/icons/comment.png " ) ;
break ;
default :
return QVariant ( ) ;
break ;
}
}
else if ( role = = Qt : : TextColorRole & & index . column ( ) = = 1 )
{
2010-11-10 19:44:51 +01:00
switch ( index . row ( ) + m_offset )
2010-11-06 23:04:47 +01:00
{
case 0 :
return CHECK3 ( m_audioFile - > filePath ( ) ) ;
break ;
case 1 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > audioBaseInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 2 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > containerInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 3 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > audioCompressInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 4 :
2013-10-12 22:55:41 +02:00
return CHECK4 ( m_audioFile - > durationInfo ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 5 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > metaInfo ( ) . title ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 6 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > metaInfo ( ) . artist ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 7 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > metaInfo ( ) . album ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 8 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > metaInfo ( ) . genre ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 9 :
2013-10-12 22:55:41 +02:00
return CHECK4 ( m_audioFile - > metaInfo ( ) . year ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 10 :
2013-10-12 22:55:41 +02:00
return CHECK4 ( m_audioFile - > metaInfo ( ) . position ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 11 :
2013-10-12 22:55:41 +02:00
return CHECK3 ( m_audioFile - > metaInfo ( ) . comment ( ) ) ;
2010-11-06 23:04:47 +01:00
break ;
default :
return QVariant ( ) ;
break ;
}
}
else
{
return QVariant ( ) ;
}
}
QVariant MetaInfoModel : : headerData ( int section , Qt : : Orientation orientation , int role ) const
{
if ( role = = Qt : : DisplayRole )
{
if ( orientation = = Qt : : Horizontal )
{
switch ( section )
{
case 0 :
2011-01-01 19:28:19 +01:00
return QVariant ( tr ( " Property " ) ) ;
2010-11-06 23:04:47 +01:00
break ;
case 1 :
2011-01-01 19:28:19 +01:00
return QVariant ( tr ( " Value " ) ) ;
2010-11-06 23:04:47 +01:00
break ;
default :
return QVariant ( ) ;
break ;
}
}
else
{
return QVariant ( ) ;
}
}
else
{
return QVariant ( ) ;
}
}
2011-02-10 16:08:03 +01:00
bool MetaInfoModel : : setData ( const QModelIndex & index , const QVariant & value , int role )
{
if ( ( role ! = Qt : : EditRole ) | | ( index . column ( ) ! = 1 ) | | ! value . isValid ( ) )
{
return false ;
}
switch ( index . row ( ) + m_offset )
{
case 0 :
m_audioFile - > setFilePath ( value . toString ( ) ) ;
break ;
case 1 :
case 2 :
case 3 :
return false ;
break ;
case 4 :
2013-10-12 22:55:41 +02:00
m_audioFile - > techInfo ( ) . setDuration ( value . toUInt ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 5 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setTitle ( value . toString ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 6 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setArtist ( value . toString ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 7 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setAlbum ( value . toString ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 8 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setGenre ( value . toString ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 9 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setYear ( value . toUInt ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 10 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setPosition ( value . toUInt ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
case 11 :
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setComment ( value . toString ( ) ) ;
2011-02-10 16:08:03 +01:00
break ;
default :
return false ;
break ;
}
emit dataChanged ( index , index ) ;
return true ;
}
2010-11-06 23:04:47 +01:00
void MetaInfoModel : : editItem ( const QModelIndex & index , QWidget * parent )
{
bool ok = false ;
int val = - 1 ;
2011-01-01 19:28:19 +01:00
QStringList generes ( QString ( " (%1) " ).arg(tr( " Unspecified " ))) ;
2010-11-06 23:04:47 +01:00
QString temp ;
2011-01-14 19:45:14 +01:00
QInputDialog input ( parent ) ;
input . setOkButtonText ( tr ( " OK " ) ) ;
input . setCancelButtonText ( tr ( " Cancel " ) ) ;
input . setTextEchoMode ( QLineEdit : : Normal ) ;
2010-11-10 19:44:51 +01:00
switch ( index . row ( ) + m_offset )
2010-11-06 23:04:47 +01:00
{
case 5 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Title " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the title for this file: " ) ) ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( m_audioFile - > metaInfo ( ) . title ( ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-20 19:16:04 +01:00
if ( temp . isEmpty ( ) )
{
2011-01-01 19:28:19 +01:00
QMessageBox : : warning ( parent , tr ( " Edit Title " ) , tr ( " The title must not be empty. Generating title from file name! " ) ) ;
2010-11-20 19:16:04 +01:00
temp = QFileInfo ( m_audioFile - > filePath ( ) ) . completeBaseName ( ) . replace ( " _ " , " " ) . simplified ( ) ;
int index = temp . lastIndexOf ( " - " ) ;
if ( index > = 0 ) temp = temp . mid ( index + 3 ) . trimmed ( ) ;
}
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setTitle ( temp . isEmpty ( ) ? QString ( ) : temp ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
case 6 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Artist " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the artist for this file: " ) ) ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( m_audioFile - > metaInfo ( ) . artist ( ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setArtist ( temp . isEmpty ( ) ? QString ( ) : temp ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
case 7 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Album " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the album for this file: " ) ) ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( m_audioFile - > metaInfo ( ) . album ( ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setAlbum ( temp . isEmpty ( ) ? QString ( ) : temp ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
case 8 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Genre " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the genre for this file: " ) ) ) ;
2010-11-06 23:04:47 +01:00
for ( int i = 0 ; g_lamexp_generes [ i ] ; i + + ) generes < < g_lamexp_generes [ i ] ;
2011-01-14 19:45:14 +01:00
input . setComboBoxItems ( generes ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( m_audioFile - > metaInfo ( ) . genre ( ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setGenre ( ( temp . isEmpty ( ) | | ! temp . compare ( generes . at ( 0 ) , Qt : : CaseInsensitive ) ) ? QString ( ) : temp ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
case 9 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Year " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the year for this file: " ) ) ) ;
input . setIntRange ( 0 , 2100 ) ;
2013-10-12 22:55:41 +02:00
input . setIntValue ( ( m_audioFile - > metaInfo ( ) . year ( ) ? m_audioFile - > metaInfo ( ) . year ( ) : 1900 ) ) ;
2011-01-14 19:45:14 +01:00
input . setIntStep ( 1 ) ;
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
val = input . intValue ( ) ;
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setYear ( val ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
case 10 :
2010-11-10 19:44:51 +01:00
if ( ! m_offset )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Position " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the position (track no.) for this file: " ) ) ) ;
input . setIntRange ( 0 , 99 ) ;
2013-10-12 22:55:41 +02:00
input . setIntValue ( ( m_audioFile - > metaInfo ( ) . position ( ) ? m_audioFile - > metaInfo ( ) . position ( ) : 1 ) ) ;
2011-01-14 19:45:14 +01:00
input . setIntStep ( 1 ) ;
if ( input . exec ( ) ! = 0 )
2010-11-10 19:44:51 +01:00
{
2011-01-14 19:45:14 +01:00
val = input . intValue ( ) ;
2010-11-10 19:44:51 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setPosition ( val ) ;
2010-11-10 19:44:51 +01:00
endResetModel ( ) ;
}
}
else
{
QStringList options ;
2011-01-01 19:28:19 +01:00
options < < tr ( " Unspecified (copy from source file) " ) < < tr ( " Generate from list position " ) ;
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Position " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the position (track no.) for this file: " ) ) ) ;
input . setComboBoxItems ( options ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( options . value ( ( m_audioFile - > metaInfo ( ) . position ( ) = = UINT_MAX ) ? 1 : 0 ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-10 19:44:51 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-10 19:44:51 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setPosition ( ( options . indexOf ( temp ) = = 1 ) ? UINT_MAX : 0 ) ;
2010-11-10 19:44:51 +01:00
endResetModel ( ) ;
}
2010-11-06 23:04:47 +01:00
}
break ;
case 11 :
2011-01-14 19:45:14 +01:00
input . setWindowTitle ( tr ( " Edit Comment " ) ) ;
input . setLabelText ( EXPAND ( tr ( " Please enter the comment for this file: " ) ) ) ;
2013-10-12 22:55:41 +02:00
input . setTextValue ( ( m_audioFile - > metaInfo ( ) . comment ( ) . isEmpty ( ) ? tr ( " Encoded with LameXP " ) : m_audioFile - > metaInfo ( ) . comment ( ) ) ) ;
2011-01-14 19:45:14 +01:00
if ( input . exec ( ) ! = 0 )
2010-11-06 23:04:47 +01:00
{
2011-01-14 19:45:14 +01:00
temp = input . textValue ( ) . simplified ( ) ;
2010-11-06 23:04:47 +01:00
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setComment ( temp . isEmpty ( ) ? QString ( ) : temp ) ;
2010-11-06 23:04:47 +01:00
endResetModel ( ) ;
}
break ;
default :
2011-01-01 19:28:19 +01:00
QMessageBox : : warning ( parent , tr ( " Not editable " ) , tr ( " Sorry, this property of the source file cannot be edited! " ) ) ;
2010-11-06 23:04:47 +01:00
break ;
}
}
2011-03-22 17:33:03 +01:00
void MetaInfoModel : : editArtwork ( const QString & imagePath )
{
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setCover ( imagePath , false ) ;
2011-03-22 17:33:03 +01:00
}
2011-05-31 19:04:45 +02:00
void MetaInfoModel : : clearData ( bool clearMetaOnly )
2010-11-10 19:44:51 +01:00
{
beginResetModel ( ) ;
2011-01-14 19:45:14 +01:00
m_textUnknown = QString ( " (%1) " ) . arg ( tr ( " Unknown " ) ) ;
m_textNotSpecified = QString ( " (%1) " ) . arg ( tr ( " Not Specified " ) ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . reset ( ) ;
m_audioFile - > metaInfo ( ) . setComment ( tr ( " Encoded with LameXP " ) ) ;
m_audioFile - > metaInfo ( ) . setPosition ( m_offset ? UINT_MAX : 0 ) ;
//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(m_offset ? UINT_MAX : 0);
2011-05-31 19:04:45 +02:00
if ( ! clearMetaOnly )
{
2013-10-12 22:55:41 +02:00
m_audioFile - > techInfo ( ) . reset ( ) ;
//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);
2011-05-31 19:04:45 +02:00
}
else
{
QString temp = QFileInfo ( m_audioFile - > filePath ( ) ) . baseName ( ) ;
temp = temp . split ( " - " , QString : : SkipEmptyParts ) . last ( ) . trimmed ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . setTitle ( temp ) ;
2011-05-31 19:04:45 +02:00
}
2010-11-10 19:44:51 +01:00
endResetModel ( ) ;
}
2010-11-06 23:04:47 +01:00
Qt : : ItemFlags MetaInfoModel : : flags ( const QModelIndex & index ) const
{
return QAbstractTableModel : : flags ( index ) ;
2011-05-31 19:04:45 +02:00
}
2013-10-12 22:55:41 +02:00
void MetaInfoModel : : assignInfoFrom ( const AudioFileModel & file )
2011-05-31 19:04:45 +02:00
{
beginResetModel ( ) ;
2013-10-12 22:55:41 +02:00
m_audioFile - > metaInfo ( ) . update ( file . metaInfo ( ) ) ;
2011-05-31 19:04:45 +02:00
endResetModel ( ) ;
}