|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a widget to stack url bars. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtGui import QStackedWidget, QSizePolicy |
|
11 |
|
12 class StackedUrlBar(QStackedWidget): |
|
13 """ |
|
14 Class implementing a widget to stack url bars. |
|
15 """ |
|
16 def __init__(self, parent = None): |
|
17 """ |
|
18 Constructor |
|
19 |
|
20 @param parent reference to the parent widget (QWidget) |
|
21 """ |
|
22 QStackedWidget.__init__(self, parent) |
|
23 |
|
24 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) |
|
25 sizePolicy.setHorizontalStretch(6) |
|
26 sizePolicy.setVerticalStretch(0) |
|
27 self.setSizePolicy(sizePolicy) |
|
28 self.setMinimumSize(200, 22) |
|
29 |
|
30 def currentUrlBar(self): |
|
31 """ |
|
32 Public method to get a reference to the current url bar. |
|
33 |
|
34 @return reference to the current url bar (UrlBar) |
|
35 """ |
|
36 return self.urlBar(self.currentIndex()) |
|
37 |
|
38 def urlBar(self, index): |
|
39 """ |
|
40 Public method to get a reference to the url bar for a given index. |
|
41 |
|
42 @return reference to the url bar for the given index (UrlBar) |
|
43 """ |
|
44 return self.widget(index) |
|
45 |
|
46 def moveBar(self, from_, to_): |
|
47 """ |
|
48 Public slot to move a url bar. |
|
49 |
|
50 @param from_ index of url bar to be moved (integer) |
|
51 @param to_ into to move the url bar to (integer) |
|
52 """ |
|
53 fromBar = self.widget(from_) |
|
54 self.removeWidget(fromBar) |
|
55 self.insertWidget(to_, fromBar) |
|
56 |
|
57 def urlBars(self): |
|
58 """ |
|
59 Public method to get a list of references to all url bars. |
|
60 |
|
61 @return list of references to url bars (list of UrlBar) |
|
62 """ |
|
63 l = [] |
|
64 for index in range(self.count()): |
|
65 l.append(self.widget(index)) |
|
66 return l |