aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Visual/projectm/translations/projectm_plugin_lt.ts
Commit message (Collapse)AuthorAgeFilesLines
* changed contact informationtrialuser022017-10-071-2/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7514 90c681e8-e032-0410-971d-27865f9a5e38
* updated .ts filestrialuser022017-02-231-18/+18
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7045 90c681e8-e032-0410-971d-27865f9a5e38
* updated .ts filestrialuser022016-06-191-6/+6
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6477 90c681e8-e032-0410-971d-27865f9a5e38
* fixed typo (thanks to Sérgio Marques)trialuser022014-09-191-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4502 90c681e8-e032-0410-971d-27865f9a5e38
* updated Lithuanian translation (Algirdas Butkus)trialuser022014-05-141-10/+10
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4282 90c681e8-e032-0410-971d-27865f9a5e38
* updated .ts filestrialuser022014-03-261-18/+18
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4209 90c681e8-e032-0410-971d-27865f9a5e38
* updated linguist files and Russian translationtrialuser022014-02-171-11/+21
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4099 90c681e8-e032-0410-971d-27865f9a5e38
* added translationstrialuser022014-02-141-16/+16
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4090 90c681e8-e032-0410-971d-27865f9a5e38
* updated linguist filestrialuser022013-09-121-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3710 90c681e8-e032-0410-971d-27865f9a5e38
* fixed typostrialuser022011-03-031-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2091 90c681e8-e032-0410-971d-27865f9a5e38
* updated Lithuanian translation (author: Algirdas Butkus)trialuser022009-12-121-2/+2
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1439 90c681e8-e032-0410-971d-27865f9a5e38
* prepare for ladspa supporttrialuser022009-12-051-16/+16
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1421 90c681e8-e032-0410-971d-27865f9a5e38
* fixed typotrialuser022009-10-041-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1285 90c681e8-e032-0410-971d-27865f9a5e38
* updated *.ts filestrialuser022009-09-291-24/+24
| | | | git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1273 90c681e8-e032-0410-971d-27865f9a5e38
* added Lithuanian translation (author: Algirdas Butkus)trialuser022009-07-271-0/+128
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1076 90c681e8-e032-0410-971d-27865f9a5e38
0000 skinned: added column alignment option' href='/qmmp/commit/src/plugins/Ui/skinned/playlistheader.cpp?id=cbc6570d34bff784b0dec5b0b2e646c2da511af1'>cbc6570d3
7e5d6a594
01a720fd3

f461a94af



cbc6570d3

6b239a0bf


cbc6570d3

1e31fe896
cbc6570d3




7e5d6a594
01a720fd3
03afd18b5
a3ab27c22
968c05fe1
e985da53d
a3ab27c22
05bacc09f






b917024aa
86078e309
05bacc09f




b0600c50c
e00ce793a
b0600c50c
05bacc09f


b917024aa
05bacc09f
dea812e69
7491dcbef
64a0861bc
555165e35
75a6773ea

64a0861bc
75a6773ea
cd4ebe882
9305a6b6e


cbc6570d3
86078e309
f461a94af
9305a6b6e

b8332b635
cbc6570d3
7ef8d11ba
b8332b635
9305a6b6e
b8332b635
cbc6570d3

9305a6b6e
968c05fe1
b8332b635
968c05fe1

f461a94af

9305a6b6e
9305a6b6e

f90557b42






















b0600c50c
9305a6b6e
dea812e69
b0600c50c

a0683b8a7
b0600c50c
e985da53d
b0600c50c
a0683b8a7
e985da53d

b0600c50c
b0600c50c

dea812e69
b0600c50c
194e4f6eb
a0683b8a7
ea927e2c6
e985da53d
0232f6c6c
b0600c50c
e985da53d


b8332b635

094440846

b8332b635

094440846


b8332b635

094440846
a0683b8a7


0232f6c6c
a0683b8a7
b8332b635
18033cfd3
194e4f6eb
b8332b635
194e4f6eb
b8332b635
e83c06bb9

b8332b635

e83c06bb9


b8332b635

e83c06bb9
a0683b8a7
18033cfd3
b0600c50c
b0600c50c
05bacc09f

75a6773ea




195d573df

9305a6b6e
b8332b635

9305a6b6e
195d573df

cbc6570d3







f461a94af











968c05fe1
be221a1c4



7ef8d11ba

968c05fe1
be221a1c4






968c05fe1




be221a1c4


be221a1c4


e83c06bb9


















1bc5d8506

a3ab27c22
b8332b635










1bc5d8506



a3ab27c22
1bc5d8506



0232f6c6c


8e25905b2
1bc5d8506



0232f6c6c





968c05fe1
0232f6c6c



968c05fe1


9305a6b6e
b8332b635

9305a6b6e

968c05fe1



9094f60e0
968c05fe1



1bc5d8506

968c05fe1
f461a94af



968c05fe1
f461a94af




968c05fe1
01df53f1f
f461a94af

cbc6570d3








968c05fe1
6c13864b0
968c05fe1
cbc6570d3

6e77f148b



9305a6b6e
a3ab27c22

968c05fe1
a3ab27c22
968c05fe1
6e77f148b



a3ab27c22
6c13864b0

a0683b8a7
05bacc09f
194e4f6eb

03afd18b5
a0683b8a7
7e5d6a594

a0683b8a7
7e5d6a594

968c05fe1

7e5d6a594
194e4f6eb
a0683b8a7
64a0861bc
194e4f6eb
b8332b635
194e4f6eb



968c05fe1
194e4f6eb

7e5d6a594


64a0861bc
194e4f6eb
b8332b635
194e4f6eb



968c05fe1
194e4f6eb

a0683b8a7
a0683b8a7
194e4f6eb




03afd18b5
a0683b8a7
0452a8e81
03afd18b5
a0683b8a7
4bfe51345
4bfe51345
c3652c78d
03afd18b5

a0683b8a7
b0600c50c
a0683b8a7

194e4f6eb

4bfe51345



e83c06bb9
968c05fe1

0232f6c6c
a0683b8a7
968c05fe1
98df400e1
968c05fe1

















a3ab27c22
01df53f1f
03afd18b5



968c05fe1
03afd18b5

b8332b635
03afd18b5
b8332b635


03afd18b5

194e4f6eb

b8332b635

194e4f6eb





03afd18b5
b8332b635

194e4f6eb



03afd18b5







0232f6c6c
03afd18b5

a0683b8a7
f4186e0c2
cbc436a9d

b8332b635
968c05fe1
194e4f6eb
968c05fe1

64a0861bc
968c05fe1



194e4f6eb
968c05fe1
64a0861bc
968c05fe1



194e4f6eb
cbc436a9d
194e4f6eb
968c05fe1
194e4f6eb
cbc436a9d
a0683b8a7
b0600c50c
87ddc7354
dea812e69
9305a6b6e
87ddc7354
dea812e69
87ddc7354


968c05fe1
194e4f6eb
49651e636

968c05fe1

98df400e1



968c05fe1
98df400e1
968c05fe1
49651e636
87ddc7354
49651e636
87ddc7354
49651e636
76f1c9273
76f1c9273
194e4f6eb
a3ab27c22
dea812e69

7e5d6a594


9305a6b6e
0232f6c6c

f461a94af

f4186e0c2
cbc6570d3
1e31fe896
cbc6570d3







f4186e0c2
1e31fe896
f4186e0c2

2cf6844c1
f4186e0c2




e5e2a1a4c
0232f6c6c


1e31fe896
e5e2a1a4c
2cf6844c1


e5e2a1a4c

0232f6c6c
9305a6b6e
7e5d6a594

a0683b8a7

968c05fe1
a0683b8a7
0452a8e81


50954bf5c
ab0ecb548
968c05fe1
03afd18b5
b0600c50c
b49213987

194e4f6eb
dea812e69
b8332b635
03afd18b5
03a24ab21




64a0861bc
ab0ecb548
194e4f6eb

b8332b635
194e4f6eb



03afd18b5

b8332b635
194e4f6eb
b8332b635

194e4f6eb



ab0ecb548
194e4f6eb



dea812e69
64a0861bc
ab0ecb548
dea812e69
ab0ecb548
194e4f6eb


b8332b635
194e4f6eb





e83c06bb9
194e4f6eb

b8332b635
194e4f6eb


b8332b635
64a0861bc
b8332b635
b49213987
05bacc09f
194e4f6eb
03afd18b5
b8332b635
194e4f6eb
e985da53d




ab0ecb548
194e4f6eb

b8332b635
194e4f6eb





b8332b635
194e4f6eb
b8332b635

194e4f6eb



ab0ecb548
194e4f6eb




ab0ecb548
194e4f6eb
968c05fe1

194e4f6eb


b8332b635
194e4f6eb








b8332b635
194e4f6eb


b8332b635
194e4f6eb
03afd18b5
05bacc09f

968c05fe1


























7e5d6a594

968c05fe1
b8332b635
7e5d6a594
b8332b635
7e5d6a594



86078e309
b8332b635









ab0ecb548




86078e309




cbc6570d3
86078e309
f461a94af
b8332b635
86078e309
b8332b635
cbc6570d3
b8332b635
86078e309
f461a94af

86078e309

cbc6570d3
86078e309
f461a94af
86078e309

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
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
                                                                            
                                                                            
                                                                            

















                                                                             
                  




                       
                            


                       
                
                
                       
                    
                      
                                   
                                       

                           
                             
 



                                           
                       
                     
                   
 





















                                                      


                                                 
                           
                                                         

           
                             

                                                                                                  



                                                                                                        

                                                       


                                                                                                

                                                                                        
                                                




                                     
                           
                                                                                                        
 
                                                                         
                                                                          
                                                                          
                                                                        






                                 
                        
                    




                                                                 
                                   
                                                                                            
 


                         
                            
     
 
                                         
                                                    
 

                                                                                      
                                                                  
 
                                    


                                                                           
                                                                                   
                                                                                  
                                                                                   

                                                 
                                                   
                                                                                   
                                                                                         
 
                                 
                                                               

                                                                        
                                     
             
                                                       

                                     

                                                      
         

     






















                                                                                                     
                        
 
                    

 
                                              
 
                               
     
                               

                                 
     

 
                                    
 
                                                      
 
               
 
                             
     


                                                    

                                                                                                                            

                                 

                                                                                                                    


            

                                                                                             
         


               
                                             
     
                                                  
 
               
                                                                                     
            
                                                                    

                                 

                                                                                                            


            

                                                                                             
         
 
                   
     
             

 




                                          

                                        
                        

                                                        
                    

 







                                                                  











                                                  
                                          



                             

                                                                           
                                             






                                  




                                                


                                       


             


















                                                                 

                                
                                           










                                                                            



                  
                                



                                 


                            
                                        



                                   





                                      
                                           



                           


                      
    

                                                   

    



                                                       
                    



                                                                     

 
                                            



                            
          




                                                    
                                                        
                                                                      

 








                                                                          
                                             
 
                                               

                                                                                 



                                         
                    

 
                                      
 
                                            



                                         
                    

 
                                                    
 

                                                    
                                     
     

                                                
         

                                     

                                           
 
                   
             
                                                                                                                              
                 
                                                        



                                    
                                                                                                            

                                  


                
                                                                                                                                  
                 
                                                        



                                    
                                                                                                            

                                  
             
         




                             
     
 
 
                                                     
 
                      
                                                                                        
 

                     
 
 

                                                   

                                                    



                      
 

                                    
                                                
     
                                       
 

















                                                                              
                        
                                                                          



                               
                                     

                      
                                                 
         


                                                         

                         

                   

                                                                           





                             
             

                                                                           



                             







                                                  
                                              

                                
     
                                                                

                                          
 
                                                           
         

                   
                                                                                                                   



                                                
                
             
                                                                                                                       



                                                
         
            
         
                                       
         
     
 
 
                                                 
 
                             
     
                        


               
                                   
 

                                               

                                                    



                        
                                   
     
                                    
                        
               
     
 
                                                                                           
     
                        
               
     

 


                                                           
                                            

                             

                                                                                              
 
                                                                           
                                                         







                                                   
                             
                                                

                                                 
                                                                   




                                                                             
 


        
                                                
         


                                                                   

                                          
     
                                 

 

                                              
                                                      
                           


                               
                            
                                                        
                                                     
                                
 

                                                 
           
     
                                 
         




                                                                          
                                                                                              
                                                  

                                     
                                                



                                                                

         
                                                 
         

                                                   



                                                       
                                                                          



                                            
 
                                                                                              
                                                           
 
                                                                          


                                     
                                                





                                                                           
         

                                                                 
                                                                                               


                                                               
                                                                                                 
                                                                                                            
                                                                                                    
         
     
        
     
                                 
         




                                                                  
                                                                                 

                                     
                                                                         





                                                                
                                                 
         

                                                   



                                                       
                                                                          




                                            
                                                                                 
 

                                                                                    


                                     
                                                                         








                                                                           
                                                                                               


                                                                          
                                                                                                    
         
     

 


























                                                     

                                          
                         
                                             
     
                                                        



                     
 









                                                 




                                                   




                                                                 
                                     
                              
                              
                                             
     
                                               
                                                        
                                                 
                                

                                                 

                                                
                                                        
                                                                
                                                                 

                        
/***************************************************************************
 *   Copyright (C) 2015-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 <QPainter>
#include <QBitmap>
#include <QFont>
#include <QFontMetrics>
#include <QSettings>
#include <QApplication>
#include <QMouseEvent>
#include <QContextMenuEvent>
#include <QMenu>
#include <QLineEdit>
#include <QInputDialog>
#include <QIcon>
#include <QHash>
#include <QActionGroup>
#include <algorithm>
#include <qmmp/qmmp.h>
#include <qmmpui/playlistmanager.h>
#include <qmmpui/playlistheadermodel.h>
#include "skin.h"
#include "playlistheader.h"
#include "listwidgetdrawer.h"

#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define horizontalAdvance width
#endif

#define INITAL_SIZE 150
#define MAX_COLUMNS 7
#define MIN_SIZE 30

static const char * const skinned_arrow_down_xpm[] = {
    "11 6 2 1",
    " 	c None",
    "x	c #000000",
    "           ",
    " xxxxxxxxx ",
    "  xxxxxxx  ",
    "   xxxxx   ",
    "    xxx    ",
    "     x     "};

static const char * const skinned_arrow_up_xpm[] = {
    "11 6 2 1",
    " 	c None",
    "x	c #000000",
    "     x     ",
    "    xxx    ",
    "   xxxxx   ",
    "  xxxxxxx  ",
    " xxxxxxxxx ",
    "           "};

PlayListHeader::PlayListHeader(QWidget *parent) :
    QWidget(parent)
{
    setMouseTracking(true);
    m_model = PlayListManager::instance()->headerModel();

    //menus
    m_menu = new QMenu(this);
    m_menu->addAction(QIcon::fromTheme("list-add"), tr("Add Column"), this, SLOT(addColumn()));
    m_menu->addAction(QIcon::fromTheme("configure"), tr("Edit Column"), this, SLOT(editColumn()));
    m_trackStateAction = m_menu->addAction(tr("Show Queue/Protocol"), this, SLOT(showTrackState(bool)));
    m_trackStateAction->setCheckable(true);
    m_autoResizeAction = m_menu->addAction(tr("Auto-resize"), this, SLOT(setAutoResize(bool)));
    m_autoResizeAction->setCheckable(true);

    m_alignmentMenu = m_menu->addMenu(tr("Alignment"));
    m_alignmentMenu->addAction(tr("Left", "alignment"))->setData(ListWidgetRow::ALIGN_LEFT);
    m_alignmentMenu->addAction(tr("Right", "alignment"))->setData(ListWidgetRow::ALIGN_RIGHT);
    m_alignmentMenu->addAction(tr("Center", "alignment"))->setData(ListWidgetRow::ALIGN_CENTER);
    connect(m_alignmentMenu, SIGNAL(triggered(QAction*)), SLOT(setAlignment(QAction*)));
    QActionGroup *alignmentGroup = new QActionGroup(this);
    for(QAction *a : m_alignmentMenu->actions())
    {
        a->setCheckable(true);
        alignmentGroup->addAction(a);
    }

    m_menu->addSeparator();
    m_menu->addAction(QIcon::fromTheme("list-remove"), tr("Remove Column"), this, SLOT(removeColumn()));

    connect(m_model, SIGNAL(columnAdded(int)), SLOT(onColumnAdded(int)));
    connect(m_model, SIGNAL(columnRemoved(int)), SLOT(onColumnRemoved()));
    connect(m_model, SIGNAL(columnMoved(int,int)), SLOT(updateColumns()));
    connect(m_model, SIGNAL(columnChanged(int)), SLOT(updateColumns()));
    readSettings();
}

PlayListHeader::~PlayListHeader()
{
    if (m_metrics)
        delete m_metrics;
    m_metrics = nullptr;
    writeSettings();
}

void PlayListHeader::readSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    m_font.fromString(settings.value("pl_header_font", qApp->font().toString()).toString());

    if (m_metrics)
    {
        delete m_metrics;
        m_metrics = nullptr;
    }

    m_metrics = new QFontMetrics(m_font);
    m_padding = m_metrics->horizontalAdvance("9")/2;

    QFont pl_font;
    pl_font.fromString(settings.value("pl_font", qApp->font().toString()).toString());
    m_pl_padding = QFontMetrics(pl_font).horizontalAdvance("9")/2;

    if(!m_model->isSettingsLoaded())
    {
        m_model->restoreSettings(&settings);
        QList<QVariant> sizes = settings.value("pl_column_sizes").toList();
        QList<QVariant> alignment = settings.value("pl_column_alignment").toList();
        int autoResizeColumn = settings.value("pl_autoresize_column", -1).toInt();
        int trackStateColumn = settings.value("pl_track_state_column", -1).toInt();
        for(int i = 0; i < m_model->count(); ++i)
        {
            m_model->setData(i, SIZE, INITAL_SIZE);
            m_model->setData(i, ALIGNMENT, (layoutDirection() == Qt::RightToLeft) ?
                                 ListWidgetRow::ALIGN_RIGHT : ListWidgetRow::ALIGN_LEFT);

            if(i < sizes.count())
                m_model->setData(i, SIZE, sizes.at(i).toInt());
            if(i < alignment.count())
                m_model->setData(i, ALIGNMENT, alignment.at(i).toInt());
            if(i == autoResizeColumn)
            {
                m_model->setData(i, AUTO_RESIZE, true);
                m_auto_resize = true;
            }
            if(i == trackStateColumn)
                m_model->setData(i,TRACK_STATE, true);
        }
    }

    if(settings.value("pl_use_skin_colors", true).toBool())
    {
        Skin *skin = Skin::instance();
        m_normal.setNamedColor(skin->getPLValue("normal"));
        m_current.setNamedColor(skin->getPLValue("current"));
        m_normal_bg.setNamedColor(skin->getPLValue("normalbg"));
    }
    else
    {
        m_normal_bg.setNamedColor(settings.value("pl_bg1_color", m_normal_bg.name()).toString());
        m_normal.setNamedColor(settings.value("pl_normal_text_color", m_normal.name()).toString());
        m_current.setNamedColor(settings.value("pl_current_text_color",m_current.name()).toString());
    }

    QPixmap px1(skinned_arrow_up_xpm);
    QPixmap px2(skinned_arrow_down_xpm);
    m_arrow_up = px1;
    m_arrow_down = px2;
    m_arrow_up.fill(m_normal_bg);
    m_arrow_down.fill(m_normal_bg);
    m_arrow_up.setMask(px1.createMaskFromColor(Qt::transparent));
    m_arrow_down.setMask(px2.createMaskFromColor(Qt::transparent));

    settings.endGroup();

    updateColumns();
}

void PlayListHeader::setNumberWidth(int width)
{
    if(width != m_number_width)
    {
        m_number_width = width;
        if(m_model->count() == 1)
            updateColumns();
    }
}

void PlayListHeader::updateColumns()
{
    bool rtl = (layoutDirection() == Qt::RightToLeft);

    int sx = 5;

    if(m_model->count() == 1)
    {
        if(m_number_width)
            sx += m_number_width + 2 * m_pl_padding;

        m_model->setData(0, RECT, rtl ? QRect(5, 0, width() - sx - 5, height()) : QRect(sx, 0, width() - sx - 5, height()));
        QRect rect = m_model->data(0, RECT).toRect();
        if(m_sorting_column == 0)
        {
            m_model->setData(0, NAME, m_metrics->elidedText(m_model->name(0), Qt::ElideRight,
                                                            rect.width() - 2 * m_padding - m_arrow_up.width() - 4));
        }
        else
        {
            m_model->setData(0, NAME, m_metrics->elidedText(m_model->name(0), Qt::ElideRight,
                                                            rect.width() - 2 * m_padding));
        }
        return;
    }

    for(int i = 0; i < m_model->count(); ++i)
    {
        int size = m_model->data(i, SIZE).toInt();

        if(rtl)
            m_model->setData(i, RECT, QRect(width() - sx - size, 0, size, height()));
        else
            m_model->setData(i, RECT, QRect(sx, 0, size, height()));
        if(i == m_sorting_column)
        {
            m_model->setData(i, NAME, m_metrics->elidedText(m_model->name(i), Qt::ElideRight,
                                                            size - 2 * m_padding - m_arrow_up.width() - 4));
        }
        else
        {
            m_model->setData(i, NAME, m_metrics->elidedText(m_model->name(i), Qt::ElideRight,
                                                            size - 2 * m_padding));
        }

        sx += size;
    }
    update();
}

int PlayListHeader::requiredHeight() const
{
    return m_metrics->lineSpacing() + 1;
}

QList<int> PlayListHeader::sizes() const
{
    QList<int> sizeList;
    for(int i = 0; i < m_model->count(); ++i)
        sizeList.append(m_model->data(i, SIZE).toInt());
    return sizeList;
}

QList<int> PlayListHeader::alignment() const
{
    QList<int> alignmentList;
    for(int i = 0; i < m_model->count(); ++i)
        alignmentList.append(m_model->data(i, ALIGNMENT).toInt());
    return alignmentList;
}

int PlayListHeader::trackStateColumn() const
{
    for(int i = 0; i < m_model->count(); ++i)
    {
        if(m_model->data(i, TRACK_STATE).toBool())
        {
            return i;
        }
    }
    return -1;
}

int PlayListHeader::maxScrollValue() const
{
    if(m_model->count() == 1)
        return 0;

    const QList<int> sizeList = sizes();
    int row_width = std::accumulate(sizeList.cbegin(), sizeList.cend(), 0);
    return qMax(0, row_width - width() + 10);
}

int PlayListHeader::offset() const
{
    return m_offset;
}

bool PlayListHeader::hasAutoResizeColumn() const
{
    return m_auto_resize;
}

void PlayListHeader::scroll(int offset)
{
    m_offset = offset;
    update();
}

void PlayListHeader::showSortIndicator(int column, bool reverted)
{
    if(m_sorting_column == column && m_reverted == reverted)
        return;

    m_sorting_column = column;
    m_reverted = reverted;
    updateColumns();
}

void PlayListHeader::hideSortIndicator()
{
    if(m_sorting_column != -1)
    {
        m_sorting_column = -1;
        updateColumns();
    }
}

void PlayListHeader::addColumn()
{
    int column = findColumn(m_pressed_pos);

    if(column < 0)
    {
        QRect firstRect = m_model->data(0, RECT).toRect();
        QRect lastRect = m_model->data(m_model->count() - 1, RECT).toRect();

        if(m_pressed_pos.x() > lastRect.right())
            column = m_model->count();
        else if(m_pressed_pos.x() < firstRect.x())
            column = 0;
    }

    if(column < 0)
        return;

    m_model->execInsert(column);
}

void PlayListHeader::editColumn()
{
    if(m_pressed_column < 0)
         return;

    m_model->execEdit(m_pressed_column);
}

void PlayListHeader::removeColumn()
{
    if(m_pressed_column < 0)
         return;

    m_model->remove(m_pressed_column);
}

void PlayListHeader::setAutoResize(bool on)
{
   if(m_pressed_column < 0)
        return;

   m_auto_resize = on;

   if(on)
   {
       for(int i = 0; i < m_model->count(); ++i)
           m_model->setData(i, AUTO_RESIZE, false);
   }

   m_model->setData(m_pressed_column, AUTO_RESIZE, on);

   if(on)
   {
       m_offset = 0;
       adjustColumn(m_pressed_column);
       updateColumns();
   }
   PlayListManager::instance()->selectedPlayList()->updateMetaData();
}

void PlayListHeader::showTrackState(bool on)
{
    if(m_pressed_column < 0)
         return;

    if(on)
    {
        for(int i = 0; i < m_model->count(); ++i)
            m_model->setData(i, TRACK_STATE, false);
    }

    m_model->setData(m_pressed_column, TRACK_STATE, on);
    PlayListManager::instance()->selectedPlayList()->updateMetaData();
}

void PlayListHeader::setAlignment(QAction *action)
{
    if(m_pressed_column < 0)
         return;

    m_model->setData(m_pressed_column, ALIGNMENT, action->data().toInt());
    PlayListManager::instance()->selectedPlayList()->updateMetaData();
}

void PlayListHeader::onColumnAdded(int index)
{
    m_model->setData(index, SIZE, INITAL_SIZE);
    m_model->setData(index, ALIGNMENT, (layoutDirection() == Qt::RightToLeft) ?
                         ListWidgetRow::ALIGN_RIGHT : ListWidgetRow::ALIGN_LEFT);
    if(m_auto_resize)
    {
        adjustColumn(autoResizeColumn());
    }
    updateColumns();
}

void PlayListHeader::onColumnRemoved()
{
    m_auto_resize = autoResizeColumn() >= 0;
    if(m_auto_resize)
    {
        adjustColumn(autoResizeColumn());
    }
    updateColumns();
}

void PlayListHeader::mousePressEvent(QMouseEvent *e)
{
    bool rtl = layoutDirection() == Qt::RightToLeft;

    if(e->button() == Qt::LeftButton)
    {
        m_pressed_column = findColumn(e->pos());
        if(m_pressed_column >= 0)
        {
            m_pressed_pos = e->pos();
            m_mouse_pos = e->pos();
            m_pressed_pos.rx() += m_offset;
            m_mouse_pos.rx() += m_offset;

            if(rtl)
            {
                if(m_pressed_pos.x() < m_model->data(m_pressed_column, RECT).toRect().x() + m_metrics->horizontalAdvance("9"))
                {
                    m_old_size = size(m_pressed_column);
                    m_task = RESIZE;
                }
                else
                {
                    m_press_offset = m_pressed_pos.x() - m_model->data(m_pressed_column, RECT).toRect().x();
                    m_task = SORT;
                }
            }
            else
            {
                if(m_pressed_pos.x() > m_model->data(m_pressed_column, RECT).toRect().right() - m_metrics->horizontalAdvance("9"))
                {
                    m_old_size = size(m_pressed_column);
                    m_task = RESIZE;
                }
                else
                {
                    m_press_offset = m_pressed_pos.x() - m_model->data(m_pressed_column, RECT).toRect().x();
                    m_task = SORT;
                }
            }
        }
        else
        {
            m_task = NO_TASK;
            update();
        }
    }
}

void PlayListHeader::mouseReleaseEvent(QMouseEvent *)
{
    if(m_task == SORT)
        PlayListManager::instance()->selectedPlayList()->sortByColumn(m_pressed_column);

    m_task = NO_TASK;
    update();
}

void PlayListHeader::mouseMoveEvent(QMouseEvent *e)
{
    bool rtl = layoutDirection() == Qt::RightToLeft;

    if(m_task == SORT)
    {
        m_task = MOVE;
    }

    int x = e->pos().x() + m_offset;

    if(m_task == RESIZE && m_model->count() > 1)
    {
        int index = autoResizeColumn();

        if(index == -1 || m_pressed_column < m_model->count() - 1)
        {
            if(rtl)
                setSize(m_pressed_column, m_old_size - x + m_pressed_pos.x());
            else
                setSize(m_pressed_column, m_old_size + x - m_pressed_pos.x());
            setSize(m_pressed_column, qMax(size(m_pressed_column), MIN_SIZE));
        }

        if(m_pressed_column < index)
        {
            adjustColumn(index);
        }
        else if(index != -1 && m_pressed_column < m_model->count() - 1)
        {
            adjustColumn(m_pressed_column + 1);
        }
        m_offset = qMin(m_offset, maxScrollValue());
        updateColumns();
        PlayListManager::instance()->selectedPlayList()->updateMetaData();
    }
    else if(m_task == MOVE)
    {
        m_mouse_pos = e->pos();
        m_mouse_pos.rx() += m_offset;

        int dest = -1;
        for(int i = 0; i < m_model->count(); ++i)
        {
            QRect rect = m_model->data(i, RECT).toRect();
            int x_delta = m_mouse_pos.x() - rect.x();
            if(x_delta < 0 || x_delta > rect.width())
                continue;

            if(rtl)
            {
                if((x_delta > rect.width()/2 && m_pressed_column > i) ||
                        (x_delta < rect.width()/2 && m_pressed_column < i))
                {
                    dest = i;
                    break;
                }
            }
            else
            {
                if((x_delta > rect.width()/2 && m_pressed_column < i) ||
                        (x_delta < rect.width()/2 && m_pressed_column > i))
                {
                    dest = i;
                    break;
                }
            }
        }
        if(dest == -1 || dest == m_pressed_column)
        {
            update();
            QWidget::mouseMoveEvent(e);
            return;
        }
        m_model->move(m_pressed_column, dest);
        m_pressed_column = dest;
        update();
    }
    else if(e->button() == Qt::NoButton && m_model->count() > 1)
    {
        int column = findColumn(e->pos());

        if(!m_auto_resize || column < m_model->count() - 1)
        {
            if(rtl)
            {
                if(column >= 0 && x < m_model->data(column, RECT).toRect().x() + m_metrics->horizontalAdvance("9"))
                    setCursor(Qt::SplitHCursor);
                else
                    setCursor(Qt::ArrowCursor);
            }
            else
            {
                if(column >= 0 && x > m_model->data(column, RECT).toRect().right() - m_metrics->horizontalAdvance("9"))
                    setCursor(Qt::SplitHCursor);
                else
                    setCursor(Qt::ArrowCursor);
            }
        }
        else
        {
            setCursor(Qt::ArrowCursor);
        }
    }
}

void PlayListHeader::resizeEvent(QResizeEvent *e)
{
    if(m_model->count() == 1)
    {
        updateColumns();
        return;
    }

    int index = autoResizeColumn();

    if(index >= 0 && e->oldSize().width() > 10)
    {
        adjustColumn(index);
        m_offset = qMin(m_offset, maxScrollValue());
        updateColumns();
        return;
    }

    if(m_offset > maxScrollValue())
    {
        m_offset = maxScrollValue();
        updateColumns();
        return;
    }

    if(layoutDirection() == Qt::RightToLeft || e->oldSize().height() != e->size().height())
    {
        updateColumns();
        return;
    }
}

void PlayListHeader::contextMenuEvent(QContextMenuEvent *e)
{
    m_pressed_pos = e->pos();
    m_pressed_column = findColumn(e->pos());
    if(m_pressed_column >= 0)
    {
        m_trackStateAction->setChecked(m_model->data(m_pressed_column, TRACK_STATE).toBool());
        m_autoResizeAction->setChecked(m_model->data(m_pressed_column, AUTO_RESIZE).toBool());

        int alignment = m_model->data(m_pressed_column, ALIGNMENT).toInt();
        for(QAction *action : m_alignmentMenu->actions())
        {
            if(action->data().toInt() == alignment)
            {
                action->setChecked(true);
                break;
            }
        }

        //hide unused actions
        for(QAction *action : m_menu->actions())
        {
            if(m_menu->actions().at(0) == action)
                action->setVisible(m_model->count() < MAX_COLUMNS);
            else if(m_menu->actions().at(1) == action)
                action->setVisible(true);
            else
                action->setVisible(m_model->count() != 1); //multicolumn mode
        }

    }
    else
    {
        for(QAction *action : m_menu->actions())
        {
            if(action == m_menu->actions().first())
                action->setVisible(m_model->count() < MAX_COLUMNS);
            else
                action->setVisible(false);
        }
    }
    m_menu->exec(e->globalPos());
}

void PlayListHeader::paintEvent(QPaintEvent *)
{
    bool rtl = (layoutDirection() == Qt::RightToLeft);
    QPainter painter(this);

    painter.setBrush(m_normal);
    painter.setPen(m_normal);
    painter.setFont(m_font);
    painter.drawRect(5, -1, width() - 10, height() + 1);
    painter.translate(rtl ? m_offset : -m_offset, 0);
    painter.setPen(m_normal_bg);

    QRect rect = m_model->data(0, RECT).toRect();

    if(rtl)
    {
        if(m_model->count() == 1)
        {
            if(m_number_width)
            {
                painter.drawLine(rect.right(), 0, rect.right(), height());
            }

            painter.drawText(rect.right() - m_padding - m_metrics->horizontalAdvance(name(0)),
                    m_metrics->ascent(), name(0));
            if(m_sorting_column == 0)
            {
                painter.drawPixmap(rect.x() + 4,
                        (height() - m_arrow_up.height()) / 2,
                        m_reverted ? m_arrow_up : m_arrow_down);
            }
            return;
        }

        for(int i = 0; i < m_model->count(); ++i)
        {
            rect = m_model->data(i, RECT).toRect();

            if(m_task == MOVE && i == m_pressed_column)
            {
                painter.setBrush(m_normal_bg);
                painter.setPen(m_current);
                painter.drawRect(rect.x(), 0, rect.width(), height() - 1);
                painter.setBrush(m_normal);
                painter.setPen(m_normal_bg);
                continue;
            }

            painter.drawText(rect.right() - m_padding - m_metrics->horizontalAdvance(name(i)),
                             m_metrics->ascent(), name(i));

            painter.drawLine(rect.x() - 1, 0, rect.x() - 1, height() + 1);

            if(i == m_sorting_column)
            {
                painter.drawPixmap(rect.x() + 4,
                                   (height() - m_arrow_up.height()) / 2,
                                   m_reverted ? m_arrow_up : m_arrow_down);
            }
        }

        if(m_task == MOVE)
        {
            painter.setPen(m_normal);
            painter.drawRect(m_mouse_pos.x() - m_press_offset, 0,
                             m_model->data(m_pressed_column, RECT).toRect().width(), height());

            painter.setPen(m_normal_bg);
            painter.drawText(m_mouse_pos.x() - m_press_offset +
                             m_model->data(m_pressed_column, RECT).toRect().width() - m_padding -
                             m_metrics->horizontalAdvance(m_model->data(m_pressed_column, NAME).toString()),
                             m_metrics->ascent(), m_model->data(m_pressed_column, NAME).toString());
        }
    }
    else
    {
        if(m_model->count() == 1)
        {
            if(m_number_width)
            {
                painter.drawLine(rect.x(), 0, rect.x(), height());
            }

            painter.drawText(rect.x() + m_padding, m_metrics->ascent(), name(0));
            if(m_sorting_column == 0)
            {
                painter.drawPixmap(rect.right() - m_arrow_up.width() - 4,
                        (height() - m_arrow_up.height()) / 2,
                        m_reverted ? m_arrow_up : m_arrow_down);
            }
            return;
        }

        for(int i = 0; i < m_model->count(); ++i)
        {
            rect = m_model->data(i, RECT).toRect();

            if(m_task == MOVE && i == m_pressed_column)
            {
                painter.setBrush(m_normal_bg);
                painter.setPen(m_current);
                painter.drawRect(rect.x(), 0, rect.width(), height() - 1);
                painter.setBrush(m_normal);
                painter.setPen(m_normal_bg);
                continue;
            }

            painter.drawText(rect.x() + m_padding, m_metrics->ascent(), name(i));

            if(!m_auto_resize || i != m_model->count() - 1)
                painter.drawLine(rect.right()+1, 0, rect.right() + 1, height() + 1);

            if(i == m_sorting_column)
            {
                painter.drawPixmap(rect.right() - m_arrow_up.width() - 4,
                                   (height() - m_arrow_up.height()) / 2,
                                   m_reverted ? m_arrow_up : m_arrow_down);
            }
        }

        if(m_task == MOVE)
        {
            painter.setPen(m_normal);
            painter.drawRect(m_mouse_pos.x() - m_press_offset, 0,
                             m_model->data(m_pressed_column, RECT).toRect().width(), height());

            painter.setPen(m_normal_bg);
            painter.drawText(m_mouse_pos.x() - m_press_offset + m_padding,
                             m_metrics->ascent(), m_model->data(m_pressed_column, NAME).toString());
        }
    }
}

void PlayListHeader::adjustColumn(int index)
{
    int w = 0;

    for(int i = 0; i < m_model->count(); ++i)
    {
        if(i != index)
            w += size(i);
    }

    setSize(index, qMax(width() - 10 - w, MIN_SIZE));
}

int PlayListHeader::autoResizeColumn() const
{
    int index = -1;
    for(int i = 0; i < m_model->count(); ++i)
    {
        if(m_model->data(i, AUTO_RESIZE).toBool())
        {
            index = i;
            break;
        }
    }
    return index;
}

int PlayListHeader::findColumn(QPoint pos)
{
    pos.rx() += m_offset;
    for(int i = 0; i < m_model->count(); ++i)
    {
        if(m_model->data(i,RECT).toRect().contains(pos))
            return i;
    }
    return -1;
}

int PlayListHeader::size(int index) const
{
    return m_model->data(index, SIZE).toInt();
}

void PlayListHeader::setSize(int index, int size)
{
    m_model->setData(index, SIZE, size);
}

const QString PlayListHeader::name(int index) const
{
    return m_model->data(index, NAME).toString();
}

void PlayListHeader::writeSettings()
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("Skinned");
    m_model->saveSettings(&settings);
    QList<QVariant> sizes, alignment;
    int autoResizeColumn = -1;
    int trackStateColumn = -1;
    for(int i = 0; i < m_model->count(); ++i)
    {
       sizes << m_model->data(i, SIZE).toInt();
       alignment << m_model->data(i, ALIGNMENT).toInt();
       if(m_model->data(i, AUTO_RESIZE).toBool())
           autoResizeColumn = i;
       if(m_model->data(i, TRACK_STATE).toBool())
           trackStateColumn = i;
    }
    settings.setValue("pl_column_sizes", sizes);
    settings.setValue("pl_column_alignment", alignment);
    settings.setValue("pl_autoresize_column", autoResizeColumn);
    settings.setValue("pl_track_state_column", trackStateColumn);
    settings.endGroup();
}