1
1
# -*- coding: utf-8 -*-
2
+
2
3
"""
3
4
Copyright (C) 2007-2008 Matthew Perry
4
5
Copyright (C) 2008-2010 Borys Jurgiel
12
13
* *
13
14
***************************************************************************/
14
15
"""
15
-
16
+ import sys
17
+ import time
16
18
17
19
from PyQt4 .QtCore import *
18
20
from PyQt4 .QtGui import *
21
+
19
22
from qgis .core import QgsApplication , QgsContextHelp
20
- import sys , time
23
+
21
24
from ui_qgsplugininstallerfetchingbase import Ui_QgsPluginInstallerFetchingDialogBase
22
25
from ui_qgsplugininstallerinstallingbase import Ui_QgsPluginInstallerInstallingDialogBase
23
26
from ui_qgsplugininstallerrepositorybase import Ui_QgsPluginInstallerRepositoryDetailsDialogBase
24
27
from ui_qgsplugininstallerpluginerrorbase import Ui_QgsPluginInstallerPluginErrorDialogBase
25
28
from ui_qgsplugininstallerbase import Ui_QgsPluginInstallerDialogBase
29
+
26
30
from installer_data import *
27
31
28
32
try :
@@ -475,16 +479,22 @@ def addItem(p):
475
479
repository = self .tr ("only locally available" )
476
480
else :
477
481
repository = p ["repository" ]
478
- a = QTreeWidgetItem (self .treePlugins )
482
+ a = QgsPluginTreeItem (self .treePlugins )
483
+ if p ["experimental" ]:
484
+ a .setIcon (0 , QIcon (":/plugins/installer/pluginExperimental.png" ))
485
+ a .setToolTip (0 , self .tr ("Experimental plugin. Use at own risk" ))
486
+ a .setData (0 , Qt .UserRole , QVariant (0 ))
487
+ else :
488
+ a .setData (0 , Qt .UserRole , QVariant (1 ))
479
489
if p ["error" ]:
480
- a .setText (0 ,statuses [p ["error" ]])
490
+ a .setText (1 ,statuses [p ["error" ]])
481
491
else :
482
- a .setText (0 ,statuses [p ["status" ]])
483
- a .setToolTip (0 ,statusTip )
484
- a .setText (1 ,p ["name" ])
485
- a .setText (2 ,ver )
486
- a .setToolTip (2 ,verTip )
487
- a .setText (3 ,desc )
492
+ a .setText (1 ,statuses [p ["status" ]])
493
+ a .setToolTip (1 ,statusTip )
494
+ a .setText (2 ,p ["name" ])
495
+ a .setText (3 ,ver )
496
+ a .setToolTip (3 ,verTip )
497
+ a .setText (4 ,desc )
488
498
# split the tooltip into multiple lines when they are too long
489
499
tmp = ""
490
500
splitTip = ""
@@ -494,16 +504,16 @@ def addItem(p):
494
504
else :
495
505
splitTip += tmp + "\n "
496
506
tmp = word
497
- a .setToolTip (3 , splitTip + tmp )
498
- a .setText (4 ,p ["author" ])
507
+ a .setToolTip (4 , splitTip + tmp )
508
+ a .setText (5 ,p ["author" ])
499
509
if p ["homepage" ]:
500
- a .setToolTip (4 ,p ["homepage" ])
510
+ a .setToolTip (5 ,p ["homepage" ])
501
511
else :
502
- a .setToolTip (4 ,"" )
503
- a .setText (5 ,repository )
504
- a .setToolTip (5 ,p ["url" ])
512
+ a .setToolTip (6 ,"" )
513
+ a .setText (6 ,repository )
514
+ a .setToolTip (6 ,p ["url" ])
505
515
# set fonts and colors
506
- for i in [0 ,1 ,2 ,3 ,4 ,5 ]:
516
+ for i in [0 ,1 ,2 ,3 ,4 ,5 , 6 ]:
507
517
if p ["error" ]:
508
518
a .setForeground (i ,QBrush (QColor (Qt .red )))
509
519
if p ["status" ] in ["new" ,"upgradeable" ] or p ["error" ]:
@@ -922,3 +932,14 @@ def reject(self):
922
932
plugins .updateSeenPluginsList ()
923
933
QDialog .reject (self )
924
934
# --- /class QgsPluginInstallerDialog ------------------------------------------------------------------------ #
935
+
936
+ class QgsPluginTreeItem (QTreeWidgetItem ):
937
+ def __init__ (self , parent = None ):
938
+ QTreeWidgetItem .__init__ (self , parent )
939
+
940
+ def __lt__ (self , otherItem ):
941
+ column = self .treeWidget ().sortColumn ()
942
+ if column == 0 :
943
+ return self .data (column , Qt .UserRole ).toInt ()[0 ] < otherItem .data (column , Qt .UserRole ).toInt ()[0 ]
944
+ else :
945
+ return self .text (column ) < otherItem .text (column )
0 commit comments