Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nate Graham
Kid3
Commits
8c1f1658
Commit
8c1f1658
authored
Dec 28, 2008
by
Urs Fleisch
Browse files
option to store ID3v2 genre as text instead of numeric string
parent
bf404e3a
Changes
6
Hide whitespace changes
Inline
Side-by-side
kid3/kid3/configdialog.cpp
View file @
8c1f1658
...
...
@@ -221,6 +221,7 @@ ConfigDialog::ConfigDialog(QWidget* parent, QString& caption) :
m_totalNumTracksCheckBox
=
new
QCheckBox
(
i18n
(
"Use &track/total number of tracks format"
),
v2GroupBox
);
v2GroupBoxLayout
->
addWidget
(
m_totalNumTracksCheckBox
,
0
,
0
,
1
,
2
);
#if defined HAVE_ID3LIB || defined HAVE_TAGLIB
m_genreNotNumericCheckBox
=
new
QCheckBox
(
i18n
(
"&Genre as text instead of numeric string"
),
v2GroupBox
);
QLabel
*
textEncodingLabel
=
new
QLabel
(
i18n
(
"Text &encoding:"
),
v2GroupBox
);
m_textEncodingComboBox
=
new
QComboBox
(
v2GroupBox
);
#endif
...
...
@@ -234,6 +235,8 @@ ConfigDialog::ConfigDialog(QWidget* parent, QString& caption) :
m_totalNumTracksCheckBox
=
new
QCheckBox
(
i18n
(
"Use &track/total number of tracks format"
),
v2GroupBox
);
v2GroupBox
->
addSpace
(
0
);
#if defined HAVE_ID3LIB || defined HAVE_TAGLIB
m_genreNotNumericCheckBox
=
new
QCheckBox
(
i18n
(
"&Genre as text instead of numeric string"
),
v2GroupBox
);
v2GroupBox
->
addSpace
(
0
);
QLabel
*
textEncodingLabel
=
new
QLabel
(
i18n
(
"Text &encoding:"
),
v2GroupBox
);
m_textEncodingComboBox
=
new
QComboBox
(
v2GroupBox
);
#endif
...
...
@@ -250,8 +253,9 @@ ConfigDialog::ConfigDialog(QWidget* parent, QString& caption) :
m_textEncodingComboBox
->
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
));
textEncodingLabel
->
setBuddy
(
m_textEncodingComboBox
);
#if QT_VERSION >= 0x040000
v2GroupBoxLayout
->
addWidget
(
textEncodingLabel
,
1
,
0
);
v2GroupBoxLayout
->
addWidget
(
m_textEncodingComboBox
,
1
,
1
);
v2GroupBoxLayout
->
addWidget
(
m_genreNotNumericCheckBox
,
1
,
0
,
1
,
2
);
v2GroupBoxLayout
->
addWidget
(
textEncodingLabel
,
2
,
0
);
v2GroupBoxLayout
->
addWidget
(
m_textEncodingComboBox
,
2
,
1
);
#endif
}
#endif
...
...
@@ -262,8 +266,8 @@ ConfigDialog::ConfigDialog(QWidget* parent, QString& caption) :
m_id3v2VersionComboBox
->
setSizePolicy
(
QSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
));
id3v2VersionLabel
->
setBuddy
(
m_id3v2VersionComboBox
);
#if QT_VERSION >= 0x040000
v2GroupBoxLayout
->
addWidget
(
id3v2VersionLabel
,
2
,
0
);
v2GroupBoxLayout
->
addWidget
(
m_id3v2VersionComboBox
,
2
,
1
);
v2GroupBoxLayout
->
addWidget
(
id3v2VersionLabel
,
3
,
0
);
v2GroupBoxLayout
->
addWidget
(
m_id3v2VersionComboBox
,
3
,
1
);
#endif
}
#endif
...
...
@@ -563,6 +567,7 @@ void ConfigDialog::setConfig(const FormatConfig* fnCfg,
#endif
#endif
#if defined HAVE_ID3LIB || defined HAVE_TAGLIB
m_genreNotNumericCheckBox
->
setChecked
(
miscCfg
->
m_genreNotNumeric
);
int
textEncodingV1Index
=
TextEncodingV1Latin1Index
;
int
index
=
0
;
for
(
QStringList
::
const_iterator
it
=
m_textEncodingV1List
.
begin
();
...
...
@@ -635,6 +640,7 @@ void ConfigDialog::getConfig(FormatConfig* fnCfg,
miscCfg
->
m_commentName
=
m_commentNameComboBox
->
currentText
();
#endif
#if defined HAVE_ID3LIB || defined HAVE_TAGLIB
miscCfg
->
m_genreNotNumeric
=
m_genreNotNumericCheckBox
->
isChecked
();
miscCfg
->
m_textEncodingV1
=
getTextEncodingV1CodecName
(
m_textEncodingV1ComboBox
->
currentText
());
miscCfg
->
m_textEncoding
=
m_textEncodingComboBox
->
QCM_currentIndex
();
...
...
kid3/kid3/configdialog.h
View file @
8c1f1658
...
...
@@ -143,8 +143,12 @@ private:
QCheckBox
*
m_totalNumTracksCheckBox
;
/** Comment field name combo box */
QComboBox
*
m_commentNameComboBox
;
#if defined HAVE_ID3LIB || defined HAVE_TAGLIB
/** Genre as text instead of numeric string checkbox */
QCheckBox
*
m_genreNotNumericCheckBox
;
/** ID3v2 text encoding combo box */
QComboBox
*
m_textEncodingComboBox
;
#endif
#if defined HAVE_ID3LIB && defined HAVE_TAGLIB
/** ID3v2 version combo box */
QComboBox
*
m_id3v2VersionComboBox
;
...
...
kid3/kid3/miscconfig.cpp
View file @
8c1f1658
...
...
@@ -99,6 +99,7 @@ MiscConfig::MiscConfig(const QString& group) :
GeneralConfig
(
group
),
m_markTruncations
(
true
),
m_enableTotalNumberOfTracks
(
false
),
m_genreNotNumeric
(
false
),
m_preserveTime
(
false
),
m_markChanges
(
true
),
m_commentName
(
s_defaultCommentName
),
...
...
@@ -149,6 +150,7 @@ void MiscConfig::writeToConfig(
cfg
.
writeEntry
(
"RenameDirectorySource"
,
m_renDirSrc
);
cfg
.
writeEntry
(
"MarkTruncations"
,
m_markTruncations
);
cfg
.
writeEntry
(
"EnableTotalNumberOfTracks"
,
m_enableTotalNumberOfTracks
);
cfg
.
writeEntry
(
"GenreNotNumeric"
,
m_genreNotNumeric
);
cfg
.
writeEntry
(
"PreserveTime"
,
m_preserveTime
);
cfg
.
writeEntry
(
"MarkChanges"
,
m_markChanges
);
cfg
.
writeEntry
(
"CommentName"
,
m_commentName
);
...
...
@@ -192,6 +194,7 @@ void MiscConfig::writeToConfig(
config
->
QCM_writeEntry
(
"/RenameDirectorySource"
,
m_renDirSrc
);
config
->
QCM_writeEntry
(
"/MarkTruncations"
,
m_markTruncations
);
config
->
QCM_writeEntry
(
"/EnableTotalNumberOfTracks"
,
m_enableTotalNumberOfTracks
);
config
->
QCM_writeEntry
(
"/GenreNotNumeric"
,
m_genreNotNumeric
);
config
->
QCM_writeEntry
(
"/PreserveTime"
,
m_preserveTime
);
config
->
QCM_writeEntry
(
"/MarkChanges"
,
m_markChanges
);
config
->
QCM_writeEntry
(
"/CommentName"
,
m_commentName
);
...
...
@@ -275,6 +278,7 @@ void MiscConfig::readFromConfig(
m_renDirSrc
=
cfg
.
KCM_readBoolEntry
(
"RenameDirectorySource"
,
m_renDirSrc
);
m_markTruncations
=
cfg
.
KCM_readBoolEntry
(
"MarkTruncations"
,
m_markTruncations
);
m_enableTotalNumberOfTracks
=
cfg
.
KCM_readBoolEntry
(
"EnableTotalNumberOfTracks"
,
m_enableTotalNumberOfTracks
);
m_genreNotNumeric
=
cfg
.
KCM_readBoolEntry
(
"GenreNotNumeric"
,
m_genreNotNumeric
);
m_preserveTime
=
cfg
.
KCM_readBoolEntry
(
"PreserveTime"
,
m_preserveTime
);
m_markChanges
=
cfg
.
KCM_readBoolEntry
(
"MarkChanges"
,
m_markChanges
);
m_commentName
=
cfg
.
readEntry
(
"CommentName"
,
s_defaultCommentName
);
...
...
@@ -317,6 +321,7 @@ void MiscConfig::readFromConfig(
m_renDirSrc
=
config
->
QCM_readBoolEntry
(
"/RenameDirectorySource"
,
m_renDirSrc
);
m_markTruncations
=
config
->
QCM_readBoolEntry
(
"/MarkTruncations"
,
m_markTruncations
);
m_enableTotalNumberOfTracks
=
config
->
QCM_readBoolEntry
(
"/EnableTotalNumberOfTracks"
,
m_enableTotalNumberOfTracks
);
m_genreNotNumeric
=
config
->
QCM_readBoolEntry
(
"/GenreNotNumeric"
,
m_genreNotNumeric
);
m_preserveTime
=
config
->
QCM_readBoolEntry
(
"/PreserveTime"
,
m_preserveTime
);
m_markChanges
=
config
->
QCM_readBoolEntry
(
"/MarkChanges"
,
m_markChanges
);
m_commentName
=
config
->
QCM_readEntry
(
"/CommentName"
,
s_defaultCommentName
);
...
...
kid3/kid3/miscconfig.h
View file @
8c1f1658
...
...
@@ -160,6 +160,8 @@ public:
bool
m_markTruncations
;
/** true to write total number of tracks into track fields */
bool
m_enableTotalNumberOfTracks
;
/** true to write genres as text instead of numeric string */
bool
m_genreNotNumeric
;
/** true to preserve file time stamps */
bool
m_preserveTime
;
/** true to mark changed fields */
...
...
kid3/kid3/mp3file.cpp
View file @
8c1f1658
...
...
@@ -1039,7 +1039,10 @@ void Mp3File::setTrackNumV2(int num)
void
Mp3File
::
setGenreV2
(
const
QString
&
str
)
{
if
(
!
str
.
isNull
())
{
int
num
=
Genres
::
getNumber
(
str
);
int
num
=
0xff
;
if
(
!
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
)
{
num
=
Genres
::
getNumber
(
str
);
}
if
(
num
>=
0
&&
num
!=
0xff
)
{
if
(
getGenreNum
(
m_tagV2
)
!=
num
&&
setGenreNum
(
m_tagV2
,
num
))
{
...
...
@@ -1540,7 +1543,9 @@ void Mp3File::setId3v2Frame(ID3_Frame* id3Frame, const Frame& frame) const
}
QString
value
(
fld
.
m_value
.
toString
());
if
(
id3Id
==
ID3FID_CONTENTTYPE
)
{
value
=
Genres
::
getNumberString
(
value
,
true
);
if
(
!
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
)
{
value
=
Genres
::
getNumberString
(
value
,
true
);
}
}
else
if
(
id3Id
==
ID3FID_TRACKNUM
)
{
addTotalNumberOfTracksIfEnabled
(
value
);
}
...
...
@@ -1590,7 +1595,9 @@ bool Mp3File::setFrameV2(const Frame& frame)
if
((
fld
=
id3Frame
->
GetField
(
ID3FN_TEXT
))
!=
0
||
(
fld
=
id3Frame
->
GetField
(
ID3FN_DESCRIPTION
))
!=
0
)
{
if
(
id3Frame
->
GetID
()
==
ID3FID_CONTENTTYPE
)
{
value
=
Genres
::
getNumberString
(
value
,
true
);
if
(
!
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
)
{
value
=
Genres
::
getNumberString
(
value
,
true
);
}
}
else
if
(
id3Frame
->
GetID
()
==
ID3FID_TRACKNUM
)
{
addTotalNumberOfTracksIfEnabled
(
value
);
}
...
...
kid3/kid3/taglibfile.cpp
View file @
8c1f1658
...
...
@@ -1162,7 +1162,27 @@ void TagLibFile::setGenreV2(const QString& str)
TagLib
::
String
::
null
:
QSTRING_TO_TSTRING
(
str
);
if
(
!
(
tstr
==
m_tagV2
->
genre
()))
{
if
(
!
setId3v2Unicode
(
m_tagV2
,
str
,
tstr
,
"TCON"
))
{
m_tagV2
->
setGenre
(
tstr
);
TagLib
::
ID3v2
::
TextIdentificationFrame
*
frame
;
TagLib
::
ID3v2
::
Tag
*
id3v2Tag
=
dynamic_cast
<
TagLib
::
ID3v2
::
Tag
*>
(
m_tagV2
);
if
(
id3v2Tag
&&
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
&&
(
frame
=
new
TagLib
::
ID3v2
::
TextIdentificationFrame
(
"TCON"
,
getDefaultTextEncoding
()))
!=
0
)
{
frame
->
setText
(
tstr
);
id3v2Tag
->
removeFrames
(
"TCON"
);
#ifdef WIN32
// freed in Windows DLL => must be allocated in the same DLL
TagLib
::
ID3v2
::
Frame
*
dllAllocatedFrame
=
TagLib
::
ID3v2
::
FrameFactory
::
instance
()
->
createFrame
(
frame
->
render
());
if
(
dllAllocatedFrame
)
{
id3v2Tag
->
addFrame
(
dllAllocatedFrame
);
}
delete
frame
;
#else
id3v2Tag
->
addFrame
(
frame
);
#endif
}
else
{
m_tagV2
->
setGenre
(
tstr
);
}
}
markTag2Changed
(
Frame
::
FT_Genre
);
}
...
...
@@ -2234,7 +2254,9 @@ void setTagLibFrame(const TagLibFile* self, T* tFrame, const Frame& frame)
if
(
frame
.
isValueChanged
()
||
frame
.
getFieldList
().
empty
())
{
QString
text
(
frame
.
getValue
());
if
(
frame
.
getType
()
==
Frame
::
FT_Genre
)
{
text
=
Genres
::
getNumberString
(
text
,
false
);
if
(
!
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
)
{
text
=
Genres
::
getNumberString
(
text
,
false
);
}
}
else
if
(
frame
.
getType
()
==
Frame
::
FT_Track
)
{
self
->
addTotalNumberOfTracksIfEnabled
(
text
);
}
...
...
@@ -2250,7 +2272,9 @@ void setTagLibFrame(const TagLibFile* self, T* tFrame, const Frame& frame)
{
QString
value
(
fld
.
m_value
.
toString
());
if
(
frame
.
getType
()
==
Frame
::
FT_Genre
)
{
value
=
Genres
::
getNumberString
(
value
,
false
);
if
(
!
Kid3App
::
s_miscCfg
.
m_genreNotNumeric
)
{
value
=
Genres
::
getNumberString
(
value
,
false
);
}
}
else
if
(
frame
.
getType
()
==
Frame
::
FT_Track
)
{
self
->
addTotalNumberOfTracksIfEnabled
(
value
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment