24 def __init__(self, manager, parent=None): |
24 def __init__(self, manager, parent=None): |
25 """ |
25 """ |
26 Constructor |
26 Constructor |
27 |
27 |
28 @param manager reference to the search engine manager |
28 @param manager reference to the search engine manager |
29 (OpenSearchManager) |
29 @type OpenSearchManager |
30 @param parent reference to the parent object (QObject) |
30 @param parent reference to the parent object |
|
31 @type QObject |
31 """ |
32 """ |
32 super().__init__(parent) |
33 super().__init__(parent) |
33 |
34 |
34 self.__manager = manager |
35 self.__manager = manager |
35 manager.changed.connect(self.__enginesChanged) |
36 manager.changed.connect(self.__enginesChanged) |
41 |
42 |
42 def removeRows(self, row, count, parent=None): |
43 def removeRows(self, row, count, parent=None): |
43 """ |
44 """ |
44 Public method to remove entries from the model. |
45 Public method to remove entries from the model. |
45 |
46 |
46 @param row start row (integer) |
47 @param row start row |
47 @param count number of rows to remove (integer) |
48 @type int |
48 @param parent parent index (QModelIndex) |
49 @param count number of rows to remove |
49 @return flag indicating success (boolean) |
50 @type int |
|
51 @param parent parent index |
|
52 @type QModelIndex |
|
53 @return flag indicating success |
|
54 @rtype bool |
50 """ |
55 """ |
51 if parent is None: |
56 if parent is None: |
52 parent = QModelIndex() |
57 parent = QModelIndex() |
53 |
58 |
54 if parent.isValid(): |
59 if parent.isValid(): |
72 |
77 |
73 def rowCount(self, parent=None): |
78 def rowCount(self, parent=None): |
74 """ |
79 """ |
75 Public method to get the number of rows of the model. |
80 Public method to get the number of rows of the model. |
76 |
81 |
77 @param parent parent index (QModelIndex) |
82 @param parent parent index |
78 @return number of rows (integer) |
83 @type QModelIndex |
|
84 @return number of rows |
|
85 @rtype int |
79 """ |
86 """ |
80 if parent is None: |
87 if parent is None: |
81 parent = QModelIndex() |
88 parent = QModelIndex() |
82 |
89 |
83 if parent.isValid(): |
90 if parent.isValid(): |
87 |
94 |
88 def columnCount(self, parent=None): # noqa: U100 |
95 def columnCount(self, parent=None): # noqa: U100 |
89 """ |
96 """ |
90 Public method to get the number of columns of the model. |
97 Public method to get the number of columns of the model. |
91 |
98 |
92 @param parent parent index (QModelIndex) (Unused) |
99 @param parent parent index (Unused) |
93 @return number of columns (integer) |
100 @type QModelIndex |
|
101 @return number of columns |
|
102 @rtype int |
94 """ |
103 """ |
95 return 2 |
104 return 2 |
96 |
105 |
97 def flags(self, index): |
106 def flags(self, index): |
98 """ |
107 """ |
99 Public method to get flags for a model cell. |
108 Public method to get flags for a model cell. |
100 |
109 |
101 @param index index of the model cell (QModelIndex) |
110 @param index index of the model cell |
102 @return flags (Qt.ItemFlags) |
111 @type QModelIndex |
|
112 @return flags |
|
113 @rtype Qt.ItemFlags |
103 """ |
114 """ |
104 if index.column() == 1: |
115 if index.column() == 1: |
105 return ( |
116 return ( |
106 Qt.ItemFlag.ItemIsEnabled |
117 Qt.ItemFlag.ItemIsEnabled |
107 | Qt.ItemFlag.ItemIsSelectable |
118 | Qt.ItemFlag.ItemIsSelectable |
112 |
123 |
113 def data(self, index, role): |
124 def data(self, index, role): |
114 """ |
125 """ |
115 Public method to get data from the model. |
126 Public method to get data from the model. |
116 |
127 |
117 @param index index to get data for (QModelIndex) |
128 @param index index to get data for |
118 @param role role of the data to retrieve (integer) |
129 @type QModelIndex |
|
130 @param role role of the data to retrieve |
|
131 @type int |
119 @return requested data |
132 @return requested data |
|
133 @rtype Any |
120 """ |
134 """ |
121 if index.row() >= self.__manager.enginesCount() or index.row() < 0: |
135 if index.row() >= self.__manager.enginesCount() or index.row() < 0: |
122 return None |
136 return None |
123 |
137 |
124 engine = self.__manager.engine(self.__manager.allEnginesNames()[index.row()]) |
138 engine = self.__manager.engine(self.__manager.allEnginesNames()[index.row()]) |
163 |
177 |
164 def setData(self, index, value, role=Qt.ItemDataRole.EditRole): |
178 def setData(self, index, value, role=Qt.ItemDataRole.EditRole): |
165 """ |
179 """ |
166 Public method to set the data of a model cell. |
180 Public method to set the data of a model cell. |
167 |
181 |
168 @param index index of the model cell (QModelIndex) |
182 @param index index of the model cell |
|
183 @type QModelIndex |
169 @param value value to be set |
184 @param value value to be set |
170 @param role role of the data (integer) |
185 @type Any |
171 @return flag indicating success (boolean) |
186 @param role role of the data |
|
187 @type int |
|
188 @return flag indicating success |
|
189 @rtype bool |
172 """ |
190 """ |
173 if not index.isValid() or index.column() != 1: |
191 if not index.isValid() or index.column() != 1: |
174 return False |
192 return False |
175 |
193 |
176 if index.row() >= self.rowCount() or index.row() < 0: |
194 if index.row() >= self.rowCount() or index.row() < 0: |
187 |
205 |
188 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
206 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
189 """ |
207 """ |
190 Public method to get the header data. |
208 Public method to get the header data. |
191 |
209 |
192 @param section section number (integer) |
210 @param section section number |
193 @param orientation header orientation (Qt.Orientation) |
211 @type int |
194 @param role data role (Qt.ItemDataRole) |
212 @param orientation header orientation |
|
213 @type Qt.Orientation |
|
214 @param role data role |
|
215 @type Qt.ItemDataRole |
195 @return header data |
216 @return header data |
|
217 @rtype Any |
196 """ |
218 """ |
197 if ( |
219 if ( |
198 orientation == Qt.Orientation.Horizontal |
220 orientation == Qt.Orientation.Horizontal |
199 and role == Qt.ItemDataRole.DisplayRole |
221 and role == Qt.ItemDataRole.DisplayRole |
200 ): |
222 ): |