r24127 by jghali - Show spellcheck dialog to user faster by extracting suggestions only when they are about to be displayed to user

scribus-commit scribus-commit at lists.scribus.net
Fri Oct 30 12:55:28 UTC 2020


Author: jghali
Date: Fri Oct 30 12:55:28 2020
New Revision: 24127

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24127
Log:
Show spellcheck dialog to user faster by extracting suggestions only when they are about to be displayed to user

Modified:
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
    branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24127&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp	(original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.cpp	Fri Oct 30 12:55:28 2020
@@ -51,6 +51,14 @@
 	goToNextWord(0);
 }
 
+void HunspellDialog::updateSuggestions(const WordsFound& wordFound)
+{
+	QStringList suggestions;
+	if (m_hspellerMap->contains(wordFound.lang))
+		suggestions = (*m_hspellerMap)[wordFound.lang]->suggest(wordFound.w);
+	updateSuggestions(suggestions);
+}
+
 void HunspellDialog::updateSuggestions(QStringList &newSuggestions)
 {
 	suggestionsListWidget->clear();
@@ -75,7 +83,7 @@
 		} while (wfListIndex<m_wfList->count() && (m_wfList->at(wfListIndex).changed || m_wfList->at(wfListIndex).ignore));
 		//qDebug()<<"selected word index"<<wfListIndex;
 	}
-	if (wfListIndex>=m_wfList->count())
+	if (wfListIndex >= m_wfList->count())
 	{
 		statusLabel->setText(tr("Spelling check complete"));
 		suggestionsListWidget->clear();
@@ -90,7 +98,7 @@
 		statusLabel->setText("");
 	currWF = m_wfList->at(wfListIndex);
 	setLanguageCombo(currWF.lang);
-	updateSuggestions(currWF.replacements);
+	updateSuggestions(currWF);
 
 	int sentencePos = 0;
 	QString sentence(m_iText->sentence(currWF.start + currWF.changeOffset, sentencePos));

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24127&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h	(original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspelldialog.h	Fri Oct 30 12:55:28 2020
@@ -21,8 +21,11 @@
 	public:
 		HunspellDialog(QWidget* parent, ScribusDoc *doc, StoryText* iText);
 		~HunspellDialog() {};
+
 		void set(QMap<QString, QString>* dictionaryMap, QMap<QString, HunspellDict*> *hspellerMap, QList<WordsFound>* wfList);
 		bool docChanged() {return m_docChanged;}
+
+		void updateSuggestions(const WordsFound& wordFound);
 		void updateSuggestions(QStringList& newSuggestions);
 
 	public slots:

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24127&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp	(original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginimpl.cpp	Fri Oct 30 12:55:28 2020
@@ -129,11 +129,11 @@
 		if (!dictionaryMap.contains(langAbbrev))
 		{
 			//qDebug()<<"Spelling language to match style language not installed ("<<langAbbrev<<")";
-			QString langAbbrev2=LanguageManager::instance()->getAbbrevFromLang(wordLang, false, false, 2);
+			QString langAbbrev2 = LanguageManager::instance()->getAbbrevFromLang(wordLang, false, false, 2);
 			if (!langAbbrev2.isEmpty() && dictionaryMap.contains(langAbbrev2))
 			{
 				//qDebug()<<"Spelling language swapped to :"<<langAbbrev2;
-				langAbbrev=langAbbrev2;
+				langAbbrev = langAbbrev2;
 			}
 		}
 		else
@@ -142,7 +142,7 @@
 			QMap<QString, QString>::iterator it = dictionaryMap.begin();
 			while (it != dictionaryMap.end())
 			{
-				if (it.key()==langAbbrev)
+				if (it.key() == langAbbrev)
 					break;
 				++i;
 				++it;
@@ -152,14 +152,13 @@
 		if (hspellerMap.contains(langAbbrev) && hspellerMap[langAbbrev]->spell(word)==0)
 		{
 			struct WordsFound wf;
-			wf.start=wordStart;
-			wf.end=wordEnd;
-			wf.w=word;
-			wf.changed=false;
-			wf.ignore=false;
-			wf.changeOffset=0;
+			wf.start = wordStart;
+			wf.end = wordEnd;
+			wf.w = word;
+			wf.changed = false;
+			wf.ignore = false;
+			wf.changeOffset = 0;
 			wf.lang = langAbbrev;
-			wf.replacements = hspellerMap[langAbbrev]->suggest(word);
 			wordsToCorrect.append(wf);
 		}
 		currPos = iText->nextWord(wordStart);

Modified: branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24127&path=/branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h	(original)
+++ branches/Version14x/Scribus/scribus/plugins/tools/hunspellcheck/hunspellpluginstructs.h	Fri Oct 30 12:55:28 2020
@@ -8,7 +8,6 @@
 	int start;
 	int end;
 	QString w;
-	QStringList replacements;
 	bool changed;
 	bool ignore;
 	int changeOffset;




More information about the scribus-commit mailing list