aboutsummaryrefslogblamecommitdiff
path: root/src/plugins/Input/flac
Blame is not available for folders.
d'>245d0ac0c
71548194d
41c8a60a2
245d0ac0c















908de607e
ed298a00c
908de607e
245d0ac0c
195d573df
245d0ac0c

aa167f22d
245d0ac0c
3423cc362
195d573df
245d0ac0c

aa167f22d
ebd7f9bc6
245d0ac0c
3423cc362
195d573df
ebd7f9bc6
9a26d9b1c
e7dd6e5af
3423cc362
9a26d9b1c
e7dd6e5af
245d0ac0c
245d0ac0c


e3503e5ba
ebd7f9bc6
245d0ac0c
3423cc362
195d573df
245d0ac0c


ebd7f9bc6



245d0ac0c
b3d32cd12

aa167f22d
b3d32cd12





b3d32cd12
3c37f7453
b3d32cd12

943cc5a2a
b2576ddc1
aa167f22d
414c5245e




aa167f22d
b2576ddc1




91bec81b8
245d0ac0c
2a2be446f
d4e1f1b86
245d0ac0c
9bdd208bb
b2576ddc1
245d0ac0c
f54c4c2c6
245d0ac0c

30142bc1a
245d0ac0c
e7dd6e5af





245d0ac0c






bcf7e323d









ebd7f9bc6
























30142bc1a
245d0ac0c
195d573df
3423cc362
195d573df
9a26d9b1c

195d573df
9a26d9b1c

195d573df
9a26d9b1c

195d573df
9a26d9b1c








195d573df
9a26d9b1c
195d573df
9a26d9b1c
3423cc362
9a26d9b1c
245d0ac0c

30142bc1a
9b20171e5
195d573df
9b20171e5
195d573df
9b20171e5

195d573df
9b20171e5

195d573df
9b20171e5

195d573df
9b20171e5


195d573df
9b20171e5
33317ad58


9b20171e5
195d573df
9b20171e5






30142bc1a
245d0ac0c
aa167f22d


3423cc362
245d0ac0c


9a26d9b1c
245d0ac0c
195d573df
aad25a609


9bdd208bb
aad25a609
9bdd208bb
aad25a609
3423cc362
9a26d9b1c
3423cc362
9a26d9b1c
245d0ac0c
e7dd6e5af


aa167f22d
78015dd4f



195d573df
e7dd6e5af
ed298a00c
e7dd6e5af




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
                                                                            
                                                                            
                                                                            















                                                                             
 
                       
                                 
                           
                             

                          
                                                            
 
                                            
                                          

 
                                                                            
                  
 
                                            
                                          
 
                                                
                            
                                                
                                          
                                        
                                    


                                                
                                                                       
                  
 
                                            
                                          


                               



                                                       
 

                                                                   
                                 





                                                
                                                
                 

 
                                                         
 
                                




                                                 
                          




                              
                                    
 
                                                                                  
                                                                                                          
     
                                       
                             
     
                     

 
                                         
 





                                                                       






                                   









                                                  
























                                                 
                                                 
 
                                                            
     
                                                                  

                                         
                                                                  

                                                
                                                               

                                      
                                                               








                                                                 
                                                                                                                    
     
                                                                             
                            
     
                                     

 
                                            
 
                                                            
     
                                                                  

                                         
                                                                  

                                                
                                                               

                                      
                                                               


                                             
                                                                   
     


                                                                                        
         
                                                                                 






                                
                                        
 


                                                                          
                                  


                             
                                           
 
                                                                               


                                                
                                                               
                                                
                                               
     
                                        
                                                    
                                    
                                                      
 


                                 
                                                 



                                                              
                                                       
                          
                                                                  




                                        
/***************************************************************************
 *   Copyright (C) 2008-2021 by Ilya Kotov                                 *
 *   forkotov02@ya.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 <QApplication>
#include <qmmp/metadatamanager.h>
#include "qmmpuisettings.h"
#include "metadatahelper_p.h"
#include "playlisttrack.h"

PlayListTrack::PlayListTrack() : TrackInfo(), PlayListItem()
{
    m_settings = QmmpUiSettings::instance();
    m_helper = MetaDataHelper::instance();
}

PlayListTrack::PlayListTrack(const PlayListTrack &other) : TrackInfo(other),
    PlayListItem()
{
    m_settings = QmmpUiSettings::instance();
    m_helper = MetaDataHelper::instance();

    m_formattedTitles = other.m_formattedTitles;
    m_group = other.m_group;
    m_formattedLength = other.m_formattedLength;
    m_titleFormats = other.m_titleFormats;
    m_groupFormat = other.m_groupFormat;
    setSelected(other.isSelected());
    m_formattedLength = other.m_formattedLength;
}

PlayListTrack::PlayListTrack(const TrackInfo *info) : TrackInfo(*info),
    PlayListItem()
{
    m_settings = QmmpUiSettings::instance();
    m_helper = MetaDataHelper::instance();
}

PlayListTrack::~PlayListTrack()
{
    if(m_refCount != 0)
        qWarning("PlayListTrack: deleting busy track");
}

PlayListTrack &PlayListTrack::operator=(const PlayListTrack &other)
{
    TrackInfo::operator =(other);
    m_formattedTitles = other.m_formattedTitles;
    m_group = other.m_group;
    m_formattedLength = other.m_formattedLength;
    m_titleFormats = other.m_titleFormats;
    m_groupFormat = other.m_groupFormat;
    setSelected(other.isSelected());
    m_formattedLength = other.m_formattedLength;
    return *this;
}

void PlayListTrack::updateMetaData(const TrackInfo *info)
{
    setValues(info->metaData());
    if(info->parts() & TrackInfo::Properties)
        setValues(info->properties());
    if(info->parts() & TrackInfo::ReplayGainInfo)
        setValues(info->replayGainInfo());
    setDuration(info->duration());
    setPath(info->path());
    m_formattedTitles.clear();
    m_formattedLength.clear();
    formatGroup();
}

void PlayListTrack::updateMetaData()
{
    QList<TrackInfo *> list = MetaDataManager::instance()->createPlayList(path());
    if(list.count() == 1 && list.first()->path() == path() && list.first()->parts() != TrackInfo::Parts())
    {
        TrackInfo *info = list.first();
        updateMetaData(info);
    }
    qDeleteAll(list);
}

const QString &PlayListTrack::groupName()
{
    if(m_group.isEmpty() || m_groupFormat != m_settings->groupFormat())
    {
        m_groupFormat = m_settings->groupFormat();
        formatGroup();
    }
    return m_group;
}

bool PlayListTrack::isGroup() const
{
    return false;
}

void PlayListTrack::setTrackIndex(int track_index)
{
    m_track_index = track_index;
}

int PlayListTrack::trackIndex() const
{
    return m_track_index;
}

void PlayListTrack::beginUsage()
{
    m_refCount++;
}

void PlayListTrack::endUsage()
{
    m_refCount--;
}

void PlayListTrack::deleteLater()
{
    m_sheduledForDeletion = true;
}

bool PlayListTrack::isSheduledForDeletion() const
{
    return m_sheduledForDeletion;
}

bool PlayListTrack::isUsed() const
{
    return (m_refCount != 0);
}

QString PlayListTrack::formattedTitle(int column)
{
    if(m_formattedTitles.count() != m_helper->columnCount())
    {
        while(m_formattedTitles.count() > m_helper->columnCount())
            m_formattedTitles.takeLast();

        while(m_formattedTitles.count() < m_helper->columnCount())
            m_formattedTitles.append(QString());

        while(m_titleFormats.count() > m_helper->columnCount())
            m_titleFormats.takeLast();

        while(m_titleFormats.count() < m_helper->columnCount())
            m_titleFormats.append(QString());
    }

    if(column < 0 || column >= m_formattedTitles.size())
    {
        qWarning("PlayListTrack: column number is out of range");
        return QString();
    }

    if(m_formattedTitles[column].isEmpty() || m_titleFormats[column] != m_helper->titleFormatter(column)->pattern())
    {
        m_titleFormats[column] = m_helper->titleFormatter(column)->pattern();
        formatTitle(column);
    }
    return m_formattedTitles[column];
}

QStringList PlayListTrack::formattedTitles()
{
    if(m_formattedTitles.count() != m_helper->columnCount())
    {
        while(m_formattedTitles.count() > m_helper->columnCount())
            m_formattedTitles.takeLast();

        while(m_formattedTitles.count() < m_helper->columnCount())
            m_formattedTitles.append(QString());

        while(m_titleFormats.count() > m_helper->columnCount())
            m_titleFormats.takeLast();

        while(m_titleFormats.count() < m_helper->columnCount())
            m_titleFormats.append(QString());
    }

    for(int column = 0; column < m_helper->columnCount(); column++)
    {
        if(m_formattedTitles[column].isEmpty() ||
                m_titleFormats[column] != m_helper->titleFormatter(column)->pattern() ||
                m_titleFormats[column].contains("%I"))
        {
            m_titleFormats[column] = m_helper->titleFormatter(column)->pattern();
            formatTitle(column);
        }
    }

    return m_formattedTitles;
}

QString PlayListTrack::formattedLength()
{
    if(duration() > 0 && m_formattedLength.isEmpty())
        m_formattedLength = MetaDataFormatter::formatDuration(duration());
    else if(duration() <= 0 && !m_formattedLength.isEmpty())
        m_formattedLength.clear();
    return m_formattedLength;
}

void PlayListTrack::formatTitle(int column)
{
    m_formattedTitles[column] = m_helper->titleFormatter(column)->format(this);
    if(m_formattedTitles.count() == 1)
    {
        if (m_formattedTitles[column].isEmpty())
            m_formattedTitles[column] = path().section('/',-1);
        if (m_formattedTitles[column].isEmpty())
            m_formattedTitles[column] = path();
    }
    if (m_settings->convertUnderscore())
        m_formattedTitles[column].replace("_", " ");
    if (m_settings->convertTwenty())
        m_formattedTitles[column].replace("%20", " ");
}

void PlayListTrack::formatGroup()
{
    if(duration() <= 0 && path().contains("://"))
    {
        m_group = qApp->translate("PlayListTrack", "Streams");
        return;
    }
    m_group = m_helper->groupFormatter()->format(this);
    if (m_group.isEmpty())
        m_group = qApp->translate("PlayListTrack", "Empty group");
    if (m_settings->convertUnderscore())
        m_group.replace("_", " ");
    if (m_settings->convertTwenty())
        m_group.replace("%20", " ");
}