aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input
ModeNameSize
-rw-r--r--CMakeLists.txt2243logplainblame
-rw-r--r--Input.pro739logplainblame
d---------aac466logplain
d---------cdaudio451logplain
d---------cue605logplain
d---------ffmpeg546logplain
d---------ffmpeg_legacy553logplain
d---------flac571logplain
d---------gme376logplain
d---------mad707logplain
d---------modplug641logplain
d---------mpc390logplain
d---------opus733logplain
d---------sid511logplain
d---------sndfile316logplain
d---------vorbis505logplain
d---------wavpack592logplain
d---------wildmidi546logplain
href='/qmmp/commit/src/listwidget.cpp?id=2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12'>2d622fd9b
21300d971
2d622fd9b



b917024aa
2d465cb9c
ecc137abe
65bc8828a




79fcd1357
be221a1c4
65bc8828a
81ce1a884
2d622fd9b

21300d971
81ce1a884
2d622fd9b
8217d254a
52d3353eb
b917024aa
11b7655bb
65bc8828a
2d622fd9b
7b17a2848
65bc8828a

a0683b8a7
65bc8828a
a7732c0fc
89162c2e2
be221a1c4
79fcd1357
2d622fd9b

2d622fd9b
23865e22e
e747c2b87

23865e22e
2d622fd9b


ae75e5707
fa1e4194b
fa1e4194b
fa1e4194b
d03ac4cab
79fcd1357

75a6773ea
65bc8828a


79fcd1357
7e38f3d30
7b17a2848


b917024aa
7b17a2848
2d622fd9b


013ee07b5
2d622fd9b
79fcd1357
7b17a2848

2d622fd9b

a7ebb6b84

8217d254a
a7ebb6b84

44e1687c8
a7ebb6b84



44e1687c8
a7ebb6b84
21300d971
a7ebb6b84

44e1687c8
a7ebb6b84
44e1687c8
968c05fe1
a7ebb6b84












2d622fd9b

1781ba9f4
67dcf32f9
1781ba9f4

2d622fd9b
968c05fe1

be221a1c4
8217d254a
2d622fd9b
631f5b826
a5cb8d5ff
631f5b826
245d0ac0c
240dee906
245d0ac0c


7491dcbef
21300d971

81ce1a884
21300d971
e258c848d

2d622fd9b
2d622fd9b




21300d971

2d622fd9b
21300d971
465d171ec
2d622fd9b



2d622fd9b

7b17a2848

e18b64773

2d622fd9b
21300d971
2d622fd9b
81ce1a884
764a05b85
4cdf3ee86
21300d971
764a05b85
631f5b826
764a05b85
21300d971
764a05b85
21300d971
70637af74
631f5b826
21300d971
70637af74

4cdf3ee86



21300d971
4cdf3ee86
013ee07b5
4cdf3ee86


bdfdce731
2d622fd9b

631f5b826
81ce1a884
631f5b826
4cdf3ee86

1f28f1893
631f5b826
4cdf3ee86
1f28f1893
21300d971
1f28f1893
4cdf3ee86
1f28f1893
4cdf3ee86
21300d971
1f28f1893
631f5b826
1f28f1893
2d622fd9b






75a6773ea
be221a1c4
7e38f3d30
2d622fd9b




8217d254a
2d622fd9b

8217d254a
2d622fd9b




8217d254a

2d622fd9b
7e38f3d30
2d622fd9b

26da2f9c1

fb1ab38c3
26da2f9c1
bc6a11535


21300d971

bc6a11535




21300d971
013ee07b5
bc6a11535


fb1ab38c3
26da2f9c1


7e38f3d30
2d622fd9b
968c05fe1

be221a1c4



7e38f3d30
a8de6bc53
990f7197d
068ff9837
245d0ac0c
7e38f3d30








9e2333685






7e38f3d30

52d3353eb





7e38f3d30
52d3353eb
7e38f3d30
52d3353eb
7e38f3d30
b917024aa
52d3353eb
068ff9837

7e38f3d30




068ff9837



245d0ac0c
79fcd1357


5ab632502



e985da53d
5ab632502


f461a94af
968c05fe1

89bcbf145
8217d254a
f53bff4a5
245d0ac0c
968c05fe1
f461a94af
631f5b826





7e38f3d30


968c05fe1









9b20171e5
195d573df
cbc6570d3
631f5b826



245d0ac0c

631f5b826
fff010501
245d0ac0c
245d0ac0c


631f5b826
fff010501
245d0ac0c
245d0ac0c
245d0ac0c
240dee906
8217d254a
2d622fd9b


a7732c0fc

81ce1a884
a7732c0fc





8217d254a

81ce1a884

a7732c0fc


240dee906
81ce1a884

a7732c0fc


7e38f3d30




a8de6bc53
c9d299b4a
a8de6bc53




c9d299b4a

90d3aeb64
2d622fd9b
90d3aeb64
228e0f6f9

b917024aa

228e0f6f9
5e38daa8f
90d3aeb64
52d3353eb
b917024aa
228e0f6f9










a8de6bc53
7e38f3d30
e83c06bb9
2d622fd9b

465d171ec
2d622fd9b
8217d254a
2d622fd9b
968c05fe1




2d622fd9b

2d622fd9b

631f5b826
2d622fd9b








2d622fd9b







21300d971




3be88d8c0
2d622fd9b
81ce1a884
7b5e9960a



81ce1a884
7b5e9960a




21300d971


81ce1a884
7b5e9960a
81ce1a884
7b5e9960a

86c836dd2

2d622fd9b

fedd13511



245d0ac0c


fedd13511
aa167f22d

245d0ac0c

fedd13511
245d0ac0c
a0c457d7d
fedd13511
6d1217944
92f1159a1
6d1217944
245d0ac0c
6d1217944

d5fd2706d
fedd13511

be221a1c4















52d3353eb

9e2333685
52d3353eb



9e2333685
52d3353eb

9e2333685

52d3353eb









9e2333685

52d3353eb









2d622fd9b

7b17a2848
2d622fd9b
7b17a2848





2d622fd9b
a7732c0fc







21300d971
2d622fd9b
21300d971
7b17a2848
631f5b826
81ce1a884
a7732c0fc






8217d254a
a7732c0fc

81ce1a884
a7732c0fc
7b17a2848
81ce1a884
7b17a2848
2d622fd9b
bc6a11535

21300d971
aa167f22d
fb1ab38c3
bc6a11535
2d622fd9b



4cdf3ee86
2d622fd9b

81ce1a884

11b7655bb
2d622fd9b
81ce1a884
2d622fd9b
a7732c0fc
2d622fd9b


21300d971
2d622fd9b
79fcd1357
8217d254a
2d622fd9b
c5aca6127
7abb96510
2d622fd9b
21300d971
2d622fd9b

2d622fd9b





a8de6bc53
2d622fd9b
89bcbf145
2d622fd9b
a8de6bc53



2d622fd9b

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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            









                                                                             
                     
                 
                    

                                 
                                  
                                   
                       
                           
                          
                 
                        
                             

                     
                        



                                       
                            
 
                              




                                               
                                        
                                           
                     
                                 

                              
                                   
                                    
                
                    
                
                          
                                
 
                         
                           

                   
                                                               
                                                                                                
                                                            
                                                                              
                                                                       
                                                                          

 
                         
 

                       
 


                               
                                                                 
                                   
                                                                          
                                                                      
 

                                                                             
                                                                   


                 
                                
                                             


                                         
                                    
         


        
                        
     
 

                                                             

 

                                   
                       

 
                                         



                   
                                   
 
                          

 
                                          
 
                           
                                         












                                  

                                          
                           
                                                         

                                                        
 

                                                                         
 
                                            
     
                                                     
 
                                                   
         
                                                             


                     
                                                     

                    
                                     
     

                                                                              
     




                                                       

                               
     
                                   
                             



                 

                                                

                              

                                
 
                                                           
     
                                
                                          
         
                                           
             
                                                 
                                          
                                                  
             
                                                                              
             
                                                 
                                                             

                                                      



                                        
                                                                             
         
                                       


                                        
 

                                                 
                                                   
                                             
                                                                           

                                     
         
                                             
                                                       
             
                                                                         
             
                                           
             
                                          
                                                  
             
 
         






                                             
                                                                   
                                                            
                                         




                                            
                                        

                                           
                                                                            




                                                              

                                                 
 
                                         

 

                                  
                     
     


                                                     

                                                     




                                            
                                                                                  
                        


                                           
     


                             
                                      
 

                                                                      



                                          
                                      
                                            
 
                                
 








                                                                          






                                                                             

                                                   





                                                                          
            
         
                                                                          
         
 
                                                                            
                                   

                                                   




                                                                



                                                   
 


                                        



                                                                           
                                                                  


                                                         
                                                        

                                                             
 
                                          
     
                                       
                                                          
                                                 





                                                                               


                                             









                                                                                                                                        
                                                  
                                       
                                               



                                                                                         

                               
                                               
                             
                                


            
                                                
                                                        
                                                      
                                                           
         
                                                 
     


             

                             
                                                                 





                                                                                                

                                                                          

                                                


                                                     
                  

                                                     


     




                                                                  
                                    
 




                                             

 
                                                                           
 
                

                                                        

                                                                                 
     
                          
                       
                               
                          










                                                                      
                                                                         
                                                                       
                                                                                                              

 
                                        
 
                                        
               




                                             

 

                             
                          








                                                       







                                                          




                                                                  
                                          
     
                                 



                                                  
                                 




                                                     


                                                              
                             
     
                             

                 

                                                      

 



                                               


                                             
 

                                                                    

                                 
     
                                                
                                                           
     
 
                                                                          
                              
                                        

                              
                                                       

 















                                                      

                                      
                                                                           



                                           
                                                 

                 

                                                                                









                                               

                                                             









                                               

                                               
                                      
     





                                      
 







                                           
                                    
 
                                   
         
                                   
                                                                         






                                                                  
                                                                                                 

                           
                                                      
 
                              
                                    
         
     

                          
                                    
                                                                                                          
                                        
     



                                                  
                            

                                  

                                                   
                                    
     
                                    
                              
                    


                                  
                                    
 
                                                        
                                                                           
     
                                                                                   
                               
     
                         

 





                                                            
                                      
 
                    
     



                                                                                  

     
/***************************************************************************
 *   Copyright (C) 2006-2019 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 <QPixmap>
#include <QResizeEvent>
#include <QPainter>
#include <QFont>
#include <QFontMetrics>
#include <QSettings>
#include <QMenu>
#include <QUrl>
#include <QApplication>
#include <QHelpEvent>
#include <QTimer>
#include <QMimeData>
#include <qmmpui/playlistitem.h>
#include <qmmpui/playlistmodel.h>
#include <qmmpui/qmmpuisettings.h>
#include <qmmpui/playlistmanager.h>
#include "listwidget.h"
#include "playlistheader.h"
#include "actionmanager.h"
#include "skin.h"
#include "popupwidget.h"
#include "horizontalslider.h"
#include "playlist.h"

#define INVALID_INDEX -1

ListWidget::ListWidget(QWidget *parent)
        : QWidget(parent)
{
    m_popupWidget = nullptr;

    m_skin = Skin::instance();
    m_ui_settings = QmmpUiSettings::instance();
    m_menu = new QMenu(this);
    m_timer = new QTimer(this);
    m_timer->setInterval(50);

    m_header = new PlayListHeader(this);
    m_hslider = new HorizontalSlider(this);
    m_update = false;
    m_drop_index = INVALID_INDEX;
    m_scroll_direction = NONE;
    m_prev_y = 0;
    m_anchor_index = INVALID_INDEX;
    m_pressed_index = INVALID_INDEX;
    m_first = 0;
    m_row_count = 0;
    m_count = 0;
    m_firstItem = nullptr;
    m_select_on_release = false;

    setAcceptDrops(true);
    setMouseTracking(true);

    readSettings();
    connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin()));
    connect(m_ui_settings, SIGNAL(repeatableTrackChanged(bool)), SLOT(updateRepeatIndicator()));
    connect(m_timer, SIGNAL(timeout()), SLOT(autoscroll()));
    connect(m_hslider, SIGNAL(sliderMoved(int)), m_header, SLOT(scroll(int)));
    connect(m_hslider, SIGNAL(sliderMoved(int)), this, SLOT(update()));
    SET_ACTION(ActionManager::PL_SHOW_HEADER, this, SLOT(readSettings()));
}

ListWidget::~ListWidget()
{
    qDeleteAll(m_rows);
    m_rows.clear();
}

void ListWidget::readSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    m_show_protocol = settings.value ("pl_show_protocol", false).toBool();
    bool show_popup = settings.value("pl_show_popup", false).toBool();

    m_header->readSettings();
    m_header->setVisible(ACTION(ActionManager::PL_SHOW_HEADER)->isChecked());
    m_header->setGeometry(0,0,width(), m_header->requiredHeight());

    if (m_update)
    {
        m_drawer.readSettings();
        updateList(PlayListModel::STRUCTURE);
        if(m_popupWidget)
        {
            m_popupWidget->deleteLater();
            m_popupWidget = nullptr;
        }
    }
    else
    {
        m_update = true;
    }

    if(show_popup)
        m_popupWidget = new PlayListPopup::PopupWidget(this);
}

int ListWidget::visibleRows() const
{
    return m_row_count;
}

int ListWidget::firstVisibleIndex() const
{
    return m_first;
}

int ListWidget::anchorIndex() const
{
    return m_anchor_index;
}

void ListWidget::setAnchorIndex(int index)
{
    m_anchor_index = index;
    updateList(PlayListModel::SELECTION);
}

QMenu *ListWidget::menu()
{
    return m_menu;
}

PlayListModel *ListWidget::model()
{
    Q_ASSERT(m_model);
    return m_model;
}

void ListWidget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    m_drawer.fillBackground(&painter, width(), height());
    painter.setLayoutDirection(Qt::LayoutDirectionAuto);
    bool rtl = (layoutDirection() == Qt::RightToLeft);

    painter.setClipRect(5,0,width() - 9, height());
    painter.translate(rtl ? m_header->offset() : -m_header->offset(), 0);

    for (int i = 0; i < m_rows.size(); ++i )
    {
        m_drawer.drawBackground(&painter, m_rows[i]);

        if(m_rows[i]->flags & ListWidgetRow::GROUP)
        {
            m_drawer.drawSeparator(&painter, m_rows[i], rtl);
            continue;
        }

        m_drawer.drawTrack(&painter, m_rows[i], rtl);
    }
    //draw drop line
    if(m_drop_index != INVALID_INDEX)
    {
        m_drawer.drawDropLine(&painter, m_drop_index - m_first, width(),
                              m_header->isVisible() ? m_header->height() : 0);
    }
}

void ListWidget::mouseDoubleClickEvent (QMouseEvent *e)
{
    int y = e->y();
    int index = indexAt(y);
    if (INVALID_INDEX != index)
    {
        m_model->setCurrent(index);
        emit doubleClicked();
        update();
    }
}

void ListWidget::mousePressEvent(QMouseEvent *e)
{
    if(m_popupWidget)
        m_popupWidget->hide();

    int index = indexAt(e->y());

    if (INVALID_INDEX != index && m_model->count() > index)
    {
        m_pressed_index = index;
        if(e->button() == Qt::RightButton)
        {
            if(!m_model->isSelected(index))
            {
                m_anchor_index = m_pressed_index;
                m_model->clearSelection();
                m_model->setSelected(index, true);
            }
            if(m_model->isGroup(index) && m_model->selectedTracks().isEmpty())
            {
                m_anchor_index = m_pressed_index;
                PlayListGroup *group = m_model->group(index);
                m_model->setSelected(group->tracks());
            }
            QWidget::mousePressEvent(e);
            return;
        }

        if (m_model->isSelected(index) && (e->modifiers() == Qt::NoModifier))
        {
            m_select_on_release = true;
            QWidget::mousePressEvent(e);
            return;
        }

        if ((Qt::ShiftModifier & e->modifiers()))
        {
            int prev_anchor_index = m_anchor_index;
            m_anchor_index = m_pressed_index;
            m_model->setSelected(m_pressed_index, prev_anchor_index, true);
        }
        else //ShiftModifier released
        {
            m_anchor_index = m_pressed_index;
            if ((Qt::ControlModifier & e->modifiers()))
            {
                m_model->setSelected(index, !m_model->isSelected(index));
            }
            else //ControlModifier released
            {
                m_model->clearSelection();
                m_model->setSelected(index, true);
            }

        }
        update();
    }
    QWidget::mousePressEvent(e);
}

void ListWidget::resizeEvent(QResizeEvent *e)
{
    m_header->setGeometry(0,0,width(), m_header->requiredHeight());
    m_hslider->setGeometry(5,height() - 7, width() - 10, 7);
    updateList(PlayListModel::STRUCTURE);
    QWidget::resizeEvent(e);
}

void ListWidget::wheelEvent (QWheelEvent *e)
{
    if (m_model->count() <= m_row_count)
        return;
    if ((m_first == 0 && e->delta() > 0) ||
            ((m_first == m_model->count() - m_row_count) && e->delta() < 0))
        return;
    m_first -= e->delta()/40;  //40*3 TODO: add step to config
    if (m_first < 0)
        m_first = 0;

    if (m_first > m_model->count() - m_row_count)
        m_first = m_model->count() - m_row_count;

    updateList(PlayListModel::STRUCTURE);
}

bool ListWidget::event (QEvent *e)
{
    if(m_popupWidget)
    {
        if(e->type() == QEvent::ToolTip)
        {
            QHelpEvent *helpEvent = (QHelpEvent *) e;
            int index = indexAt(helpEvent->y());
            if(index < 0 || !m_model->isTrack(index))
            {
                m_popupWidget->deactivate();
                return QWidget::event(e);
            }
            e->accept();