294 |
295 |
295 def getTableNames(self): |
296 def getTableNames(self): |
296 """ |
297 """ |
297 Public method to get a list of table names. |
298 Public method to get a list of table names. |
298 |
299 |
299 @return list of table names (list of strings) |
300 @return list of table names |
|
301 @rtype list of str |
300 """ |
302 """ |
301 return [table[2] for table in self.__tables] |
303 return [table[2] for table in self.__tables] |
302 |
304 |
303 def getTableBoundaries(self, index): |
305 def getTableBoundaries(self, index): |
304 """ |
306 """ |
305 Public method to get the first and last character position |
307 Public method to get the first and last character position |
306 of the given table. |
308 of the given table. |
307 |
309 |
308 @param index index of the character table (integer) |
310 @param index index of the character table |
309 @return first and last character position (integer, integer) |
311 @type int |
|
312 @return first and last character position |
|
313 @rtype tuple of (int, int) |
310 """ |
314 """ |
311 return self.__tables[index][0], self.__tables[index][1] |
315 return self.__tables[index][0], self.__tables[index][1] |
312 |
316 |
313 def getTableIndex(self): |
317 def getTableIndex(self): |
314 """ |
318 """ |
315 Public method to get the current table index. |
319 Public method to get the current table index. |
316 |
320 |
317 @return current table index (integer) |
321 @return current table index |
|
322 @rtype int |
318 """ |
323 """ |
319 return self.__currentTableIndex |
324 return self.__currentTableIndex |
320 |
325 |
321 def selectTable(self, index): |
326 def selectTable(self, index): |
322 """ |
327 """ |
323 Public method to select the shown character table. |
328 Public method to select the shown character table. |
324 |
329 |
325 @param index index of the character table (integer) |
330 @param index index of the character table |
|
331 @type int |
326 """ |
332 """ |
327 self.beginResetModel() |
333 self.beginResetModel() |
328 self.__currentTableIndex = index |
334 self.__currentTableIndex = index |
329 self.endResetModel() |
335 self.endResetModel() |
330 |
336 |
331 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
337 def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
332 """ |
338 """ |
333 Public method to get header data from the model. |
339 Public method to get header data from the model. |
334 |
340 |
335 @param section section number (integer) |
341 @param section section number |
336 @param orientation orientation (Qt.Orientation) |
342 @type int |
337 @param role role of the data to retrieve (Qt.ItemDataRole) |
343 @param orientation orientation |
|
344 @type Qt.Orientation |
|
345 @param role role of the data to retrieve |
|
346 @type Qt.ItemDataRole |
338 @return requested data |
347 @return requested data |
|
348 @rtype Any |
339 """ |
349 """ |
340 if ( |
350 if ( |
341 orientation == Qt.Orientation.Horizontal |
351 orientation == Qt.Orientation.Horizontal |
342 and role == Qt.ItemDataRole.DisplayRole |
352 and role == Qt.ItemDataRole.DisplayRole |
343 ): |
353 ): |
347 |
357 |
348 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
358 def data(self, index, role=Qt.ItemDataRole.DisplayRole): |
349 """ |
359 """ |
350 Public method to get data from the model. |
360 Public method to get data from the model. |
351 |
361 |
352 @param index index to get data for (QModelIndex) |
362 @param index index to get data for |
353 @param role role of the data to retrieve (integer) |
363 @type QModelIndex |
|
364 @param role role of the data to retrieve |
|
365 @type int |
354 @return requested data |
366 @return requested data |
|
367 @rtype Any |
355 """ |
368 """ |
356 symbolId = self.__tables[self.__currentTableIndex][0] + index.row() |
369 symbolId = self.__tables[self.__currentTableIndex][0] + index.row() |
357 |
370 |
358 if role == Qt.ItemDataRole.DisplayRole: |
371 if role == Qt.ItemDataRole.DisplayRole: |
359 col = index.column() |
372 col = index.column() |
411 |
424 |
412 def columnCount(self, parent): |
425 def columnCount(self, parent): |
413 """ |
426 """ |
414 Public method to get the number of columns of the model. |
427 Public method to get the number of columns of the model. |
415 |
428 |
416 @param parent parent index (QModelIndex) |
429 @param parent parent index |
417 @return number of columns (integer) |
430 @type QModelIndex |
|
431 @return number of columns |
|
432 @rtype int |
418 """ |
433 """ |
419 if parent.column() > 0: |
434 if parent.column() > 0: |
420 return 0 |
435 return 0 |
421 else: |
436 else: |
422 return len(self.__headerData) |
437 return len(self.__headerData) |
423 |
438 |
424 def rowCount(self, parent): |
439 def rowCount(self, parent): |
425 """ |
440 """ |
426 Public method to get the number of rows of the model. |
441 Public method to get the number of rows of the model. |
427 |
442 |
428 @param parent parent index (QModelIndex) |
443 @param parent parent index |
429 @return number of columns (integer) |
444 @type QModelIndex |
|
445 @return number of columns |
|
446 @rtype int |
430 """ |
447 """ |
431 if parent.isValid(): |
448 if parent.isValid(): |
432 return 0 |
449 return 0 |
433 else: |
450 else: |
434 first, last = self.__tables[self.__currentTableIndex][:2] |
451 first, last = self.__tables[self.__currentTableIndex][:2] |
436 |
453 |
437 def __isDigit(self, char): |
454 def __isDigit(self, char): |
438 """ |
455 """ |
439 Private method to check, if a character is a digit. |
456 Private method to check, if a character is a digit. |
440 |
457 |
441 @param char character to test (one character string) |
458 @param char character to test |
442 @return flag indicating a digit (boolean) |
459 @type str |
|
460 @return flag indicating a digit |
|
461 @rtype bool |
443 """ |
462 """ |
444 return unicodedata.category(str(char)) in ("Nd", "Nl", "No") |
463 return unicodedata.category(str(char)) in ("Nd", "Nl", "No") |
445 |
464 |
446 def __isLetter(self, char): |
465 def __isLetter(self, char): |
447 """ |
466 """ |
448 Private method to check, if a character is a letter. |
467 Private method to check, if a character is a letter. |
449 |
468 |
450 @param char character to test (one character string) |
469 @param char character to test |
451 @return flag indicating a letter (boolean) |
470 @type str |
|
471 @return flag indicating a letter |
|
472 @rtype bool |
452 """ |
473 """ |
453 return unicodedata.category(str(char)) in ("Lu", "Ll", "Lt", "Lm", "Lo") |
474 return unicodedata.category(str(char)) in ("Lu", "Ll", "Lt", "Lm", "Lo") |
454 |
475 |
455 def __isMark(self, char): |
476 def __isMark(self, char): |
456 """ |
477 """ |
457 Private method to check, if a character is a mark character. |
478 Private method to check, if a character is a mark character. |
458 |
479 |
459 @param char character to test (one character string) |
480 @param char character to test |
460 @return flag indicating a mark character (boolean) |
481 @type str |
|
482 @return flag indicating a mark character |
|
483 @rtype bool |
461 """ |
484 """ |
462 return unicodedata.category(str(char)) in ("Mn", "Mc", "Me") |
485 return unicodedata.category(str(char)) in ("Mn", "Mc", "Me") |
463 |
486 |
464 def __isPunct(self, char): |
487 def __isPunct(self, char): |
465 """ |
488 """ |
466 Private method to check, if a character is a punctuation character. |
489 Private method to check, if a character is a punctuation character. |
467 |
490 |
468 @param char character to test (one character string) |
491 @param char character to test |
469 @return flag indicating a punctuation character (boolean) |
492 @type str |
|
493 @return flag indicating a punctuation character |
|
494 @rtype boolean) |
470 """ |
495 """ |
471 return unicodedata.category(str(char)) in ( |
496 return unicodedata.category(str(char)) in ( |
472 "Pc", |
497 "Pc", |
473 "Pd", |
498 "Pd", |
474 "Ps", |
499 "Ps", |
480 |
505 |
481 def __isSymbol(self, char): |
506 def __isSymbol(self, char): |
482 """ |
507 """ |
483 Private method to check, if a character is a symbol. |
508 Private method to check, if a character is a symbol. |
484 |
509 |
485 @param char character to test (one character string) |
510 @param char character to test |
486 @return flag indicating a symbol (boolean) |
511 @type str |
|
512 @return flag indicating a symbol |
|
513 @rtype bool |
487 """ |
514 """ |
488 return unicodedata.category(str(char)) in ("Sm", "Sc", "Sk", "So") |
515 return unicodedata.category(str(char)) in ("Sm", "Sc", "Sk", "So") |
489 |
516 |
490 def getLocale(self): |
517 def getLocale(self): |
491 """ |
518 """ |
552 @pyqtSlot(QModelIndex) |
580 @pyqtSlot(QModelIndex) |
553 def on_symbolsTable_activated(self, index): |
581 def on_symbolsTable_activated(self, index): |
554 """ |
582 """ |
555 Private slot to signal the selection of a symbol. |
583 Private slot to signal the selection of a symbol. |
556 |
584 |
557 @param index index of the selected symbol (QModelIndex) |
585 @param index index of the selected symbol |
|
586 @type QModelIndex |
558 """ |
587 """ |
559 txt = self.__model.data(index) |
588 txt = self.__model.data(index) |
560 if txt: |
589 if txt: |
561 self.insertSymbol.emit(txt) |
590 self.insertSymbol.emit(txt) |
562 |
591 |
576 @pyqtSlot(int) |
605 @pyqtSlot(int) |
577 def on_tableCombo_currentIndexChanged(self, index): |
606 def on_tableCombo_currentIndexChanged(self, index): |
578 """ |
607 """ |
579 Private slot to select the current character table. |
608 Private slot to select the current character table. |
580 |
609 |
581 @param index index of the character table (integer) |
610 @param index index of the character table |
|
611 @type int |
582 """ |
612 """ |
583 self.symbolsTable.setUpdatesEnabled(False) |
613 self.symbolsTable.setUpdatesEnabled(False) |
584 self.__model.selectTable(index) |
614 self.__model.selectTable(index) |
585 self.symbolsTable.setUpdatesEnabled(True) |
615 self.symbolsTable.setUpdatesEnabled(True) |
586 self.symbolsTable.resizeColumnsToContents() |
616 self.symbolsTable.resizeColumnsToContents() |
594 @pyqtSlot(QModelIndex, QModelIndex) |
624 @pyqtSlot(QModelIndex, QModelIndex) |
595 def __currentRowChanged(self, current, previous): |
625 def __currentRowChanged(self, current, previous): |
596 """ |
626 """ |
597 Private slot recording the currently selected row. |
627 Private slot recording the currently selected row. |
598 |
628 |
599 @param current current index (QModelIndex) |
629 @param current current index |
600 @param previous previous current index (QModelIndex) |
630 @type QModelIndex |
|
631 @param previous previous current index |
|
632 @type QModelIndex |
601 """ |
633 """ |
602 Preferences.getSettings().setValue("Symbols/Top", current.row()) |
634 Preferences.getSettings().setValue("Symbols/Top", current.row()) |
603 self.symbolSpinBox.setValue( |
635 self.symbolSpinBox.setValue( |
604 self.__model.getLocale().toInt( |
636 self.__model.getLocale().toInt( |
605 self.__model.data(self.__model.index(current.row(), 0)) |
637 self.__model.data(self.__model.index(current.row(), 0)) |