(no commit message)
[bitbake.git] / bin / commander / provideritem.py
1 #!/usr/bin/env python
2 # -*- coding: iso8859-15 -*-
3
4 from qt import *
5 from packages import Packages
6 import os
7
8 imageDir = "%s/bin/commander/images/" % os.environ["OEDIR"]
9
10 class ProviderItem( QListViewItem ):
11
12     columns = { "PROVIDES":     0,
13                 "CATEGORY":     1,
14                 "SECTION":      2,
15                 "PRIORITY":     3,
16                 "MAINTAINER":   4,
17                 "SRC_URI":      5,
18                 "HOMEPAGE":     6,
19                 "DEPENDS":      7,
20                 "RDEPENDS":     8,
21                 "SHORTNAME":    9 }
22
23     def __init__( self, parent, provider ):
24         self.parent = parent
25         self.p = Packages.instance()
26         self.fullname = provider
27         self.shortname = provider.split( "/" )[-1]
28         self.virtual = self.virtualValue()
29
30         if self.virtual:
31             #
32             # check if a corresponding parent element already has been added
33             #
34             vparent = parent.findItem( self.virtual, 0 )
35             if not vparent:
36                 vparent = ProviderItem( parent, self.virtual )
37                 vparent.setPixmap( 0, QPixmap( imageDir + "virtual.png" ) )
38
39             QListViewItem.__init__( self, vparent, provider )
40         else:
41             QListViewItem.__init__( self, parent, provider )
42
43         self.decorate()
44         self.setPixmap( 0, QPixmap( imageDir + "package.png" ) )
45
46
47     def virtualValue( self ):
48         #print self.p.data(self.fullname, "PROVIDES" )
49         providers = self.p.data(self.fullname, "PROVIDES" ).split()
50         for p in providers:
51             if p.split( '/' )[0] == "virtual": return p
52
53     def decorate( self ):
54         if not self.fullname.startswith( "virtual" ):
55             self.st( "PROVIDES", self.fullname.split('/')[-1] )
56         self.st( "CATEGORY", self.p.data(self.fullname, "CATEGORY") )
57         self.st( "SECTION", self.p.data(self.fullname, "SECTION") )
58         self.st( "PRIORITY", self.p.data(self.fullname, "PRIORITY") )
59         self.st( "MAINTAINER", self.p.data(self.fullname, "MAINTAINER") )
60         self.st( "SRC_URI", self.p.data(self.fullname, "SRC_URI") )
61         self.st( "HOMEPAGE", self.p.data(self.fullname, "HOMEPAGE") )
62         self.st( "DEPENDS", self.p.data(self.fullname, "DEPENDS") )
63         self.st( "RDEPENDS", self.p.data(self.fullname, "RDEPENDS") )
64         self.st( "SHORTNAME", self.shortname )
65
66     def st( self, column, value ):
67         self.setText( ProviderItem.columns[column], value )
68
69 #------------------------------------------------------------------------#
70 # main
71 #------------------------------------------------------------------------#
72
73 if __name__ == "__main__":
74     import sys
75     from qt import *
76     app = QApplication( sys.argv )
77     mw = QListView()
78     app.setMainWidget( mw )
79     app.exec_loop()
80