mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-04 03:27:00 -05:00 
			
		
		
		
	Show a summary with word counts
This commit is contained in:
		
							parent
							
								
									66958760fe
								
							
						
					
					
						commit
						5d9516f9e0
					
				@ -303,6 +303,7 @@ class WordsModel(QAbstractTableModel):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def __init__(self, parent=None):
 | 
					    def __init__(self, parent=None):
 | 
				
			||||||
        QAbstractTableModel.__init__(self, parent)
 | 
					        QAbstractTableModel.__init__(self, parent)
 | 
				
			||||||
 | 
					        self.counts = (0, 0)
 | 
				
			||||||
        self.words = {}
 | 
					        self.words = {}
 | 
				
			||||||
        self.spell_map = {}
 | 
					        self.spell_map = {}
 | 
				
			||||||
        self.sort_on = (0, False)
 | 
					        self.sort_on = (0, False)
 | 
				
			||||||
@ -392,6 +393,7 @@ class WordsModel(QAbstractTableModel):
 | 
				
			|||||||
        self.beginResetModel()
 | 
					        self.beginResetModel()
 | 
				
			||||||
        self.do_filter()
 | 
					        self.do_filter()
 | 
				
			||||||
        self.do_sort()
 | 
					        self.do_sort()
 | 
				
			||||||
 | 
					        self.counts = (len([None for w, recognized in spell_map.iteritems() if not recognized]), len(self.words))
 | 
				
			||||||
        self.endResetModel()
 | 
					        self.endResetModel()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_filter(self):
 | 
					    def do_filter(self):
 | 
				
			||||||
@ -480,6 +482,9 @@ class SpellCheck(Dialog):
 | 
				
			|||||||
            # Sort by the restored state, if any
 | 
					            # Sort by the restored state, if any
 | 
				
			||||||
            w.sortByColumn(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
 | 
					            w.sortByColumn(hh.sortIndicatorSection(), hh.sortIndicatorOrder())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.summary = s = QLabel('')
 | 
				
			||||||
 | 
					        l.addWidget(s)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def highlight_row(self, row):
 | 
					    def highlight_row(self, row):
 | 
				
			||||||
        idx = self.words_model.index(row, 0)
 | 
					        idx = self.words_model.index(row, 0)
 | 
				
			||||||
        if idx.isValid():
 | 
					        if idx.isValid():
 | 
				
			||||||
@ -550,6 +555,10 @@ class SpellCheck(Dialog):
 | 
				
			|||||||
        self.words_view.horizontalHeader().setSortIndicator(
 | 
					        self.words_view.horizontalHeader().setSortIndicator(
 | 
				
			||||||
            col, Qt.DescendingOrder if reverse else Qt.AscendingOrder)
 | 
					            col, Qt.DescendingOrder if reverse else Qt.AscendingOrder)
 | 
				
			||||||
        self.highlight_row(0)
 | 
					        self.highlight_row(0)
 | 
				
			||||||
 | 
					        self.update_summary()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def update_summary(self):
 | 
				
			||||||
 | 
					        self.summary.setText(_('Misspelled words: {0} Total words: {1}').format(*self.words_model.counts))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def sizeHint(self):
 | 
					    def sizeHint(self):
 | 
				
			||||||
        return QSize(1000, 650)
 | 
					        return QSize(1000, 650)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user