import com.evernote.edam.type.PrivilegeLevel;\r
import com.evernote.edam.type.User;\r
import com.evernote.edam.type.UserAttributes;\r
+import com.swabunga.spell.engine.Configuration;\r
import com.trolltech.qt.core.QByteArray;\r
import com.trolltech.qt.core.QSettings;\r
import com.trolltech.qt.gui.QPalette;\r
return buf.toString(); \r
}\r
\r
+ public static boolean getSpellSetting(String value) {\r
+ settings.beginGroup("Spell");\r
+ String text = (String)settings.value(value, "");\r
+ settings.endGroup();\r
+ if (text.equalsIgnoreCase("true"))\r
+ return true;\r
+ if (text.equalsIgnoreCase("false"))\r
+ return false;\r
+ if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREDIGITWORDS))\r
+ return true;\r
+ if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREINTERNETADDRESSES))\r
+ return true;\r
+ if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREUPPERCASE))\r
+ return true;\r
+ return false;\r
+ }\r
+ public static void setSpellSetting(String setting, boolean val) {\r
+ settings.beginGroup("Spell");\r
+ if (val)\r
+ settings.setValue(setting, "true");\r
+ else\r
+ settings.setValue(setting, "false");\r
+ settings.endGroup();\r
+ }\r
+ \r
\r
// What to do with inactive tags?\r
public static String tagBehavior() {\r
startTraceTime = null;\r
}\r
\r
-\r
public static FileManager getFileManager() {\r
return fileManager;\r
}\r
private final ConfigConnectionPage connectionPage;\r
private final ConfigDebugPage debugPage;\r
private final ConfigAppearancePage appearancePage;\r
+ private final ConfigSpellPage spellPage;\r
private final ConfigIndexPage indexPage;\r
\r
public ConfigDialog(QWidget parent) {\r
appearancePage = new ConfigAppearancePage(this);\r
indexPage = new ConfigIndexPage(this);\r
debugPage = new ConfigDebugPage(this);\r
+ spellPage = new ConfigSpellPage(this);\r
pagesWidget.addWidget(appearancePage);\r
pagesWidget.addWidget(indexPage);\r
+ pagesWidget.addWidget(spellPage);\r
pagesWidget.addWidget(connectionPage);\r
pagesWidget.addWidget(debugPage);\r
\r
indexButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
indexButton.setIcon(new QIcon(iconPath+"search_config.jpg"));\r
\r
+ QListWidgetItem spellButton = new QListWidgetItem(contentsWidget);\r
+ spellButton.setText(tr("Spell Check"));\r
+ spellButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
+ spellButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
+ spellButton.setIcon(new QIcon(iconPath+"dictionary.png"));\r
+\r
QListWidgetItem configButton = new QListWidgetItem(contentsWidget);\r
configButton.setText(tr("Connection"));\r
configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
--- /dev/null
+/*\r
+ * This file is part of NeverNote \r
+ * Copyright 2009 Randy Baumgarte\r
+ * \r
+ * This file may be licensed under the terms of of the\r
+ * GNU General Public License Version 2 (the ``GPL'').\r
+ *\r
+ * Software distributed under the License is distributed\r
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
+ * express or implied. See the GPL for the specific language\r
+ * governing rights and limitations.\r
+ *\r
+ * You should have received a copy of the GPL along with this\r
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
+ * or write to the Free Software Foundation, Inc.,\r
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+ *\r
+*/\r
+\r
+package cx.fbn.nevernote.dialog;\r
+\r
+import com.swabunga.spell.engine.Configuration;\r
+import com.trolltech.qt.gui.QCheckBox;\r
+import com.trolltech.qt.gui.QVBoxLayout;\r
+import com.trolltech.qt.gui.QWidget;\r
+\r
+import cx.fbn.nevernote.Global;\r
+\r
+public class ConfigSpellPage extends QWidget {\r
+ \r
+\r
+ private final QCheckBox ignoreDigitWords;\r
+ private final QCheckBox ignoreInternetAddresses;\r
+ private final QCheckBox ignoreMixedCase;\r
+ private final QCheckBox ignoreUpperCase;\r
+ private final QCheckBox ignoreSentenceCapitalization;\r
+\r
+ \r
+ public ConfigSpellPage(QWidget parent) { \r
+ ignoreDigitWords = new QCheckBox(tr("Ignore words with numbers in them"));\r
+ ignoreInternetAddresses = new QCheckBox(tr("Ignore internet addresses (i.e. http:// ftp://)"));\r
+ ignoreMixedCase = new QCheckBox(tr("Ignore words with upper and lower cased letters"));\r
+ ignoreUpperCase = new QCheckBox(tr("Ignore upper cased words"));\r
+ ignoreSentenceCapitalization = new QCheckBox(tr("Ignore that sentences should begin with a capital letter"));\r
+ \r
+ setIgnoreDigitWords(Global.getSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS));\r
+ setIgnoreInternetAddresses(Global.getSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES));\r
+ setIgnoreMixedCase(Global.getSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE));\r
+ setIgnoreUpperCase(Global.getSpellSetting(Configuration.SPELL_IGNOREUPPERCASE));\r
+ setIgnoreSentenceCapitalization(Global.getSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION));\r
+ \r
+ QVBoxLayout mainLayout = new QVBoxLayout();\r
+ mainLayout.addWidget(ignoreDigitWords);\r
+ mainLayout.addWidget(ignoreInternetAddresses);\r
+ mainLayout.addWidget(ignoreMixedCase);\r
+ mainLayout.addWidget(ignoreUpperCase);\r
+ mainLayout.addWidget(ignoreSentenceCapitalization);\r
+ mainLayout.addStretch(1);\r
+ setLayout(mainLayout);\r
+ }\r
+ \r
+ //****************************************\r
+ //* Getter/Setter for ignore digit words *\r
+ //****************************************\r
+ public boolean getIgnoreDigitWords() {\r
+ return ignoreDigitWords.isChecked();\r
+ }\r
+ public void setIgnoreDigitWords(boolean value) {\r
+ ignoreDigitWords.setChecked(value);\r
+ }\r
+ \r
+ //***********************************************\r
+ //* Getter/Setter for ignore internet addresses *\r
+ //***********************************************\r
+ public boolean getIgnoreInternetAddresses() {\r
+ return ignoreInternetAddresses.isChecked();\r
+ }\r
+ public void setIgnoreInternetAddresses(boolean value) {\r
+ ignoreInternetAddresses.setChecked(value);\r
+ }\r
+ \r
+ //*********************************************\r
+ //* Getter/Setter for ignore Mixed Case words *\r
+ //*********************************************\r
+ public boolean getIgnoreMixedCase() {\r
+ return ignoreMixedCase.isChecked();\r
+ }\r
+ public void setIgnoreMixedCase(boolean value) {\r
+ ignoreMixedCase.setChecked(value);\r
+ }\r
+ \r
+ //*********************************************\r
+ //* Getter/Setter for ignore Mixed Case words *\r
+ //*********************************************\r
+ public boolean getUpperMixedCase() {\r
+ return ignoreUpperCase.isChecked();\r
+ }\r
+ public void setIgnoreUpperCase(boolean value) {\r
+ ignoreUpperCase.setChecked(value);\r
+ }\r
+ \r
+ //****************************************************************\r
+ //* Getter/Setter for ignore that sentences begin with a capital *\r
+ //****************************************************************\r
+ public boolean getSentenceCapitalization() {\r
+ return ignoreSentenceCapitalization.isChecked();\r
+ }\r
+ public void setIgnoreSentenceCapitalization(boolean value) {\r
+ ignoreSentenceCapitalization.setChecked(value);\r
+ }\r
+\r
+}\r
import com.evernote.edam.type.Resource;\r
import com.evernote.edam.type.ResourceAttributes;\r
import com.evernote.edam.type.Tag;\r
+import com.swabunga.spell.engine.Configuration;\r
import com.swabunga.spell.engine.SpellDictionary;\r
import com.swabunga.spell.engine.SpellDictionaryHashMap;\r
import com.swabunga.spell.engine.Word;\r
\r
// We know something has changed...\r
String oldTagArray[] = saveTagList.split(Global.tagDelimeter);\r
- String newTagArray[] = tagEdit.text().split(Global.tagDelimeter);\r
- \r
- if (!completionText.equals("") && newTagArray.length > 0) {\r
- newTagArray[newTagArray.length-1] = completionText;\r
+ String newTagArray[];\r
+ if (!completionText.equals("")) {\r
+ String before = tagEdit.text().substring(0,tagEdit.cursorPosition());\r
+ before = before.substring(0,before.lastIndexOf(Global.tagDelimeter));\r
+ String after = tagEdit.text().substring(tagEdit.cursorPosition());\r
+ newTagArray = (before+Global.tagDelimeter+completionText+Global.tagDelimeter+after).split(Global.tagDelimeter);\r
+ }\r
+ else {\r
+ newTagArray = tagEdit.text().split(Global.tagDelimeter);\r
}\r
+ \r
+ // Remove any traling or leading blanks\r
+ for (int i=0; i<newTagArray.length; i++)\r
+ newTagArray[i] = newTagArray[i].trim().replaceAll("^\\s+", "");;\r
+ \r
// Remove any potential duplicates from the new list\r
for (int i=0; i<newTagArray.length; i++) {\r
boolean foundOnce = false;\r
for (int i=0; i<newTagList.size(); i++) {\r
newDisplay = newDisplay+newTagList.get(i);\r
if (i<newTagList.size()-1)\r
- newDisplay = newDisplay+", ";\r
+ newDisplay = newDisplay+Global.tagDelimeter +" ";\r
}\r
tagEdit.blockSignals(true);\r
tagEdit.setText(newDisplay);\r
try {\r
dictionary = new SpellDictionaryHashMap(wordList);\r
spellChecker = new SpellChecker(dictionary);\r
+ \r
+ // Read user settings\r
+ spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREDIGITWORDS, \r
+ Global.getSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS));\r
+ spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREINTERNETADDRESSES, \r
+ Global.getSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES));\r
+ spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREMIXEDCASE, \r
+ Global.getSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE));\r
+ spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREUPPERCASE, \r
+ Global.getSpellSetting(Configuration.SPELL_IGNOREUPPERCASE));\r
+ spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, \r
+ Global.getSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION));\r
+ \r
File userWordList;\r
userWordList = new File(Global.getFileManager().getSpellDirPathUser()+"user.dic");\r
\r
\r
import java.util.ArrayList;\r
import java.util.List;\r
+import java.util.StringTokenizer;\r
\r
import com.evernote.edam.type.Tag;\r
import com.trolltech.qt.core.QEvent;\r
public void completeText(String text){\r
int cursor_pos = cursorPosition();\r
String before_text = text().substring(0,cursor_pos);\r
- String after_text = text().substring(cursor_pos);\r
+ String after_text = text().substring(cursor_pos) +" " +Global.tagDelimeter;\r
int prefix_len = before_text.lastIndexOf(Global.tagDelimeter);\r
if (prefix_len == -1) {\r
prefix_len = cursor_pos;\r
before_text = "";\r
} else {\r
- before_text = before_text.substring(0,cursor_pos-1);\r
+ before_text = before_text.substring(0, prefix_len);\r
}\r
- int nextTagPos = after_text.indexOf(Global.tagDelimeter);\r
- if (nextTagPos == -1) {\r
- nextTagPos = 0;\r
- after_text = "";\r
- }\r
- setText(before_text +text +Global.tagDelimeter +" " +after_text);\r
- setCursorPosition(cursor_pos - prefix_len + text().length() +2);\r
+\r
+ setText(rebuildTags(before_text+Global.tagDelimeter+text+Global.tagDelimeter+after_text));\r
+// setText(before_text +text +Global.tagDelimeter +" " +after_text);\r
+// setCursorPosition(cursor_pos - prefix_len + text().length() +2);\r
+ setCursorPosition(text().length());\r
}\r
\r
public void setTagList(List<Tag> t) {\r
@Override\r
public boolean event(QEvent e) {\r
if (e.type().equals(QEvent.Type.FocusOut)) {\r
+ \r
focusLost.emit();\r
}\r
return super.event(e);\r
}\r
+ \r
+ private String rebuildTags(String tags) {\r
+ StringBuffer tagBuffer = new StringBuffer(tags.length() *2);\r
+ StringTokenizer tokens = new StringTokenizer (tags, Global.tagDelimeter);\r
+ boolean first = true;\r
+ while (tokens.hasMoreElements()) {\r
+ String token = tokens.nextToken().trim();\r
+ if (!token.equals("")) {\r
+ if (!first)\r
+ tagBuffer.append(Global.tagDelimeter+ " ");\r
+ first = false;\r
+ tagBuffer.append(token);\r
+ }\r
+ }\r
+ return tagBuffer.toString();\r
+ }\r
}\r