OSDN Git Service

uni-gramで日本語全文検索できるように変更。ノートコンテンツとタイトルが対象。日本語全文検索時に日本語がハイライトされない問題を修正。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigDialog.java
index 1a4cabd..2b285c6 100644 (file)
@@ -44,6 +44,8 @@ import com.trolltech.qt.gui.QVBoxLayout;
 import com.trolltech.qt.gui.QWidget;\r
 \r
 import cx.fbn.nevernote.Global;\r
+import cx.fbn.nevernote.sql.DatabaseConnection;\r
+import cx.fbn.nevernote.sql.driver.NSqlQuery;\r
 public class ConfigDialog extends QDialog {\r
        private final QListWidget                               contentsWidget;\r
        private final ConfigFontPage                    fontPage;\r
@@ -55,10 +57,12 @@ public class ConfigDialog extends QDialog {
        private final ConfigIndexPage                   indexPage;\r
        // ICHANGED\r
        private final ConfigRensoNoteListPage           rensoNoteListPage;\r
+       private final DatabaseConnection conn;\r
        \r
     private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
-       public ConfigDialog(QWidget parent) {\r
+       public ConfigDialog(QWidget parent, DatabaseConnection conn) {\r
+               this.conn = conn;\r
                \r
                contentsWidget = new QListWidget(this);\r
                setWindowIcon(new QIcon(iconPath+"config.png"));\r
@@ -238,6 +242,29 @@ public class ConfigDialog extends QDialog {
                Global.setVerifyExclude(rensoNoteListPage.getVerifyExcludeChecked());\r
                Global.setRensoListItemMaximum(rensoNoteListPage.getRensoListItemMaximum());\r
                \r
+               // 全文検索の対象項目を再設定\r
+               NSqlQuery query = new NSqlQuery(conn.getConnection());\r
+               query.exec("CALL FTL_DROP_ALL();");     // カラム単位で削除できないので一度全部消して、再構築\r
+               \r
+               StringBuilder noteTableTarget = new StringBuilder();\r
+               if (Global.indexNoteBody()) {\r
+                       noteTableTarget.append("CONTENTTEXT");\r
+               }\r
+               if (Global.indexNoteTitle()) {\r
+                       if (noteTableTarget.length() > 0) {\r
+                               noteTableTarget.append(", ");\r
+                       }\r
+                       noteTableTarget.append("TITLE");\r
+               }\r
+               \r
+               // TODO 他の項目もあとで追加\r
+               \r
+               if (noteTableTarget.length() > 0) {\r
+                       query.prepare("CALL FTL_CREATE_INDEX('PUBLIC', 'NOTE', :column);");\r
+                       query.bindValue(":column", noteTableTarget.toString());\r
+                       query.exec();\r
+               }\r
+               \r
                close();\r
        }\r
        \r