34 |
35 |
35 @param event reference to the paint event (QPaintEvent) |
36 @param event reference to the paint event (QPaintEvent) |
36 """ |
37 """ |
37 fm = self.fontMetrics() |
38 fm = self.fontMetrics() |
38 if fm.width(self.__text) > self.contentsRect().width(): |
39 if fm.width(self.__text) > self.contentsRect().width(): |
39 self.__elided = fm.elidedText(self.text(), Qt.ElideMiddle, self.width()) |
40 self.__elided = fm.elidedText( |
|
41 self.text(), Qt.ElideMiddle, self.width()) |
40 super().setText(self.__elided) |
42 super().setText(self.__elided) |
41 else: |
43 else: |
42 super().setText(self.__text) |
44 super().setText(self.__text) |
43 super().paintEvent(event) |
45 super().paintEvent(event) |
44 |
46 |
69 |
71 |
70 def setSurrounding(self, surrounding): |
72 def setSurrounding(self, surrounding): |
71 """ |
73 """ |
72 Public method to set the surrounding of the path string. |
74 Public method to set the surrounding of the path string. |
73 |
75 |
74 @param surrounding the a string containg placeholders for the path (string) |
76 @param surrounding the a string containg placeholders for the path |
|
77 (string) |
75 """ |
78 """ |
76 self.__surrounding = surrounding |
79 self.__surrounding = surrounding |
77 super().setText(self.__surrounding.format(self.__path)) |
80 super().setText(self.__surrounding.format(self.__path)) |
78 |
81 |
79 def setPath(self, path): |
82 def setPath(self, path): |
87 |
90 |
88 def setTextPath(self, surrounding, path): |
91 def setTextPath(self, surrounding, path): |
89 """ |
92 """ |
90 Public method to set the surrounding and the path of the label. |
93 Public method to set the surrounding and the path of the label. |
91 |
94 |
92 @param surrounding the a string containg placeholders for the path (string) |
95 @param surrounding the a string containg placeholders for the path |
|
96 (string) |
93 @param path path to be shown (string) |
97 @param path path to be shown (string) |
94 """ |
98 """ |
95 self.__surrounding = surrounding |
99 self.__surrounding = surrounding |
96 self.__path = path |
100 self.__path = path |
97 super().setText(self.__surrounding.format(self.__path)) |
101 super().setText(self.__surrounding.format(self.__path)) |
101 Protected method called when some painting is required. |
105 Protected method called when some painting is required. |
102 |
106 |
103 @param event reference to the paint event (QPaintEvent) |
107 @param event reference to the paint event (QPaintEvent) |
104 """ |
108 """ |
105 fm = self.fontMetrics() |
109 fm = self.fontMetrics() |
106 if fm.width(self.__surrounding.format(self.__path)) > self.contentsRect().width(): |
110 if (fm.width(self.__surrounding.format(self.__path)) > |
|
111 self.contentsRect().width()): |
107 super().setText( |
112 super().setText( |
108 self.__surrounding.format(compactPath(self.__path, |
113 self.__surrounding.format(compactPath(self.__path, |
109 self.contentsRect().width(), |
114 self.contentsRect().width(), |
110 self.length)) |
115 self.length)) |
111 ) |
116 ) |