22 |
22 |
23 def __init__(self, parent=None): |
23 def __init__(self, parent=None): |
24 """ |
24 """ |
25 Constructor |
25 Constructor |
26 |
26 |
27 @param parent reference to the parent object (QObject) |
27 @param parent reference to the parent object |
|
28 @type QObject |
28 """ |
29 """ |
29 super().__init__(parent) |
30 super().__init__(parent) |
30 |
31 |
31 def columnCount(self, parent): |
32 def columnCount(self, parent): |
32 """ |
33 """ |
33 Public method to return the number of columns. |
34 Public method to return the number of columns. |
34 |
35 |
35 @param parent index of the parent (QModelIndex) |
36 @param parent index of the parent |
36 @return number of columns (integer) |
37 @type QModelIndex |
|
38 @return number of columns |
|
39 @rtype int |
37 """ |
40 """ |
38 return min(1, QSortFilterProxyModel.columnCount(self, parent)) |
41 return min(1, QSortFilterProxyModel.columnCount(self, parent)) |
39 |
42 |
40 def filterAcceptsRow(self, sourceRow, sourceParent): |
43 def filterAcceptsRow(self, sourceRow, sourceParent): |
41 """ |
44 """ |
42 Public method to determine, if the row is acceptable. |
45 Public method to determine, if the row is acceptable. |
43 |
46 |
44 @param sourceRow row number in the source model (integer) |
47 @param sourceRow row number in the source model |
45 @param sourceParent index of the source item (QModelIndex) |
48 @type int |
46 @return flag indicating acceptance (boolean) |
49 @param sourceParent index of the source item |
|
50 @type QModelIndex |
|
51 @return flag indicating acceptance |
|
52 @rtype bool |
47 """ |
53 """ |
48 idx = self.sourceModel().index(sourceRow, 0, sourceParent) |
54 idx = self.sourceModel().index(sourceRow, 0, sourceParent) |
49 return self.sourceModel().hasChildren(idx) |
55 return self.sourceModel().hasChildren(idx) |
50 |
56 |
51 def filterAcceptsColumn(self, sourceColumn, sourceParent): # noqa: U100 |
57 def filterAcceptsColumn(self, sourceColumn, sourceParent): # noqa: U100 |
52 """ |
58 """ |
53 Public method to determine, if the column is acceptable. |
59 Public method to determine, if the column is acceptable. |
54 |
60 |
55 @param sourceColumn column number in the source model (integer) |
61 @param sourceColumn column number in the source model |
56 @param sourceParent index of the source item (QModelIndex) |
62 @type int |
57 @return flag indicating acceptance (boolean) |
63 @param sourceParent index of the source item |
|
64 @type QModelIndex |
|
65 @return flag indicating acceptance |
|
66 @rtype bool |
58 """ |
67 """ |
59 return sourceColumn == 0 |
68 return sourceColumn == 0 |
60 |
69 |
61 def hasChildren(self, parent=None): |
70 def hasChildren(self, parent=None): |
62 """ |
71 """ |
63 Public method to check, if a parent node has some children. |
72 Public method to check, if a parent node has some children. |
64 |
73 |
65 @param parent index of the parent node (QModelIndex) |
74 @param parent index of the parent node |
66 @return flag indicating the presence of children (boolean) |
75 @type QModelIndex |
|
76 @return flag indicating the presence of children |
|
77 @rtype bool |
67 """ |
78 """ |
68 if parent is None: |
79 if parent is None: |
69 parent = QModelIndex() |
80 parent = QModelIndex() |
70 sindex = self.mapToSource(parent) |
81 sindex = self.mapToSource(parent) |
71 return self.sourceModel().hasChildren(sindex) |
82 return self.sourceModel().hasChildren(sindex) |
115 |
127 |
116 def setUrl(self, url): |
128 def setUrl(self, url): |
117 """ |
129 """ |
118 Public slot to set the URL of the new bookmark. |
130 Public slot to set the URL of the new bookmark. |
119 |
131 |
120 @param url URL of the bookmark (string) |
132 @param url URL of the bookmark |
|
133 @type str |
121 """ |
134 """ |
122 self.addressEdit.setText(url) |
135 self.addressEdit.setText(url) |
123 self.resize(self.sizeHint()) |
136 self.resize(self.sizeHint()) |
124 |
137 |
125 def url(self): |
138 def url(self): |
126 """ |
139 """ |
127 Public method to get the URL of the bookmark. |
140 Public method to get the URL of the bookmark. |
128 |
141 |
129 @return URL of the bookmark (string) |
142 @return URL of the bookmark |
|
143 @rtype str |
130 """ |
144 """ |
131 return self.addressEdit.text() |
145 return self.addressEdit.text() |
132 |
146 |
133 def setTitle(self, title): |
147 def setTitle(self, title): |
134 """ |
148 """ |
135 Public method to set the title of the new bookmark. |
149 Public method to set the title of the new bookmark. |
136 |
150 |
137 @param title title of the bookmark (string) |
151 @param title title of the bookmark |
|
152 @type str |
138 """ |
153 """ |
139 self.nameEdit.setText(title) |
154 self.nameEdit.setText(title) |
140 |
155 |
141 def title(self): |
156 def title(self): |
142 """ |
157 """ |
143 Public method to get the title of the bookmark. |
158 Public method to get the title of the bookmark. |
144 |
159 |
145 @return title of the bookmark (string) |
160 @return title of the bookmark |
|
161 @rtype str |
146 """ |
162 """ |
147 return self.nameEdit.text() |
163 return self.nameEdit.text() |
148 |
164 |
149 def setDescription(self, description): |
165 def setDescription(self, description): |
150 """ |
166 """ |
151 Public method to set the description of the new bookmark. |
167 Public method to set the description of the new bookmark. |
152 |
168 |
153 @param description description of the bookamrk (string) |
169 @param description description of the bookamrk |
|
170 @type str |
154 """ |
171 """ |
155 self.descriptionEdit.setPlainText(description) |
172 self.descriptionEdit.setPlainText(description) |
156 |
173 |
157 def description(self): |
174 def description(self): |
158 """ |
175 """ |
159 Public method to get the description of the bookmark. |
176 Public method to get the description of the bookmark. |
160 |
177 |
161 @return description of the bookamrk (string) |
178 @return description of the bookamrk |
|
179 @rtype str |
162 """ |
180 """ |
163 return self.descriptionEdit.toPlainText() |
181 return self.descriptionEdit.toPlainText() |
164 |
182 |
165 def setCurrentIndex(self, idx): |
183 def setCurrentIndex(self, idx): |
166 """ |
184 """ |
167 Public method to set the current index. |
185 Public method to set the current index. |
168 |
186 |
169 @param idx current index to be set (QModelIndex) |
187 @param idx current index to be set |
|
188 @type QModelIndex |
170 """ |
189 """ |
171 proxyIndex = self.__proxyModel.mapFromSource(idx) |
190 proxyIndex = self.__proxyModel.mapFromSource(idx) |
172 self.__treeView.setCurrentIndex(proxyIndex) |
191 self.__treeView.setCurrentIndex(proxyIndex) |
173 self.locationCombo.setCurrentIndex(proxyIndex.row()) |
192 self.locationCombo.setCurrentIndex(proxyIndex.row()) |
174 |
193 |
175 def currentIndex(self): |
194 def currentIndex(self): |
176 """ |
195 """ |
177 Public method to get the current index. |
196 Public method to get the current index. |
178 |
197 |
179 @return current index (QModelIndex) |
198 @return current index |
|
199 @rtype QModelIndex |
180 """ |
200 """ |
181 idx = self.locationCombo.view().currentIndex() |
201 idx = self.locationCombo.view().currentIndex() |
182 idx = self.__proxyModel.mapToSource(idx) |
202 idx = self.__proxyModel.mapToSource(idx) |
183 return idx |
203 return idx |
184 |
204 |
185 def setFolder(self, folder): |
205 def setFolder(self, folder): |
186 """ |
206 """ |
187 Public method to set the dialog to "Add Folder" mode. |
207 Public method to set the dialog to "Add Folder" mode. |
188 |
208 |
189 @param folder flag indicating "Add Folder" mode (boolean) |
209 @param folder flag indicating "Add Folder" mode |
|
210 @type bool |
190 """ |
211 """ |
191 self.__addFolder = folder |
212 self.__addFolder = folder |
192 |
213 |
193 if folder: |
214 if folder: |
194 self.setWindowTitle(self.tr("Add Folder")) |
215 self.setWindowTitle(self.tr("Add Folder")) |