1st full version of aspell support
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 391 B |
Binary file not shown.
|
After Width: | Height: | Size: 339 B |
+22
-1
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.51 2006-09-28 11:55:30 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.52 2006-10-11 14:16:26 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,6 +18,8 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.51 2006-09-28 11:55:30 dockes Exp $
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
//#define WITH_KDE
|
||||
@@ -51,6 +53,9 @@ static char rcsid[] = "@(#$Id: main.cpp,v 1.51 2006-09-28 11:55:30 dockes Exp $
|
||||
#endif
|
||||
#include "rclmain_w.h"
|
||||
#include "guiutils.h"
|
||||
#ifdef RCL_USE_ASPELL
|
||||
#include "rclaspell.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_KDE
|
||||
static const char description[] =
|
||||
@@ -68,6 +73,9 @@ const string recoll_datadir = RECOLL_DATADIR;
|
||||
|
||||
RclConfig *rclconfig;
|
||||
Rcl::Db *rcldb;
|
||||
#ifdef RCL_USE_ASPELL
|
||||
Aspell *aspell;
|
||||
#endif
|
||||
|
||||
RclHistory *g_dynconf;
|
||||
int recollNeedsExit;
|
||||
@@ -123,6 +131,10 @@ static void recollCleanup()
|
||||
rcldb = 0;
|
||||
delete rclconfig;
|
||||
rclconfig = 0;
|
||||
#ifdef RCL_USE_ASPELL
|
||||
delete aspell;
|
||||
aspell = 0;
|
||||
#endif
|
||||
LOGDEB2(("recollCleanup: done\n"));
|
||||
}
|
||||
|
||||
@@ -214,6 +226,15 @@ int main(int argc, char **argv)
|
||||
}
|
||||
// fprintf(stderr, "recollinit done\n");
|
||||
|
||||
#ifdef RCL_USE_ASPELL
|
||||
aspell = new Aspell(rclconfig);
|
||||
aspell->init(reason);
|
||||
if (!aspell || !aspell->ok()) {
|
||||
LOGDEB(("Aspell speller creation failed %s\n", reason.c_str()));
|
||||
aspell = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
string historyfile = path_cat(rclconfig->getConfDir(), "history");
|
||||
g_dynconf = new RclHistory(historyfile);
|
||||
if (!g_dynconf || !g_dynconf->ok()) {
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
<action name="toolsDoc_HistoryAction"/>
|
||||
<action name="toolsAdvanced_SearchAction"/>
|
||||
<action name="toolsSort_parametersAction"/>
|
||||
<action name="toolsSpellAction"/>
|
||||
</item>
|
||||
<item text="&Preferences" name="Preferences">
|
||||
<action name="preferencesQuery_PrefsAction"/>
|
||||
@@ -106,6 +107,7 @@
|
||||
<action name="toolsAdvanced_SearchAction"/>
|
||||
<action name="toolsSort_parametersAction"/>
|
||||
<action name="toolsDoc_HistoryAction"/>
|
||||
<action name="toolsSpellAction"/>
|
||||
</toolbar>
|
||||
<toolbar dock="2">
|
||||
<property name="name">
|
||||
@@ -251,6 +253,23 @@
|
||||
<string>Sort parameters</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>toolsSpellAction</cstring>
|
||||
</property>
|
||||
<property name="iconSet">
|
||||
<iconset>spell.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Spelling expansion</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>Spelling expansion</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Spelling expansion tool</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>nextPageAction</cstring>
|
||||
|
||||
+25
-1
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.1 2006-09-22 07:41:35 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.2 2006-10-11 14:16:26 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -17,6 +17,7 @@ static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.1 2006-09-22 07:41:35 dockes Ex
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
@@ -126,6 +127,14 @@ void RclMain::init()
|
||||
this, SLOT(showAdvSearchDialog()));
|
||||
connect(toolsSort_parametersAction, SIGNAL(activated()),
|
||||
this, SLOT(showSortDialog()));
|
||||
toolsSpellAction->setIconSet(createIconSet("spell.png"));
|
||||
#ifdef RCL_USE_ASPELL
|
||||
connect(toolsSpellAction, SIGNAL(activated()),
|
||||
this, SLOT(showSpellDialog()));
|
||||
#else
|
||||
toolsSpellAction->setEnabled(FALSE);
|
||||
#endif
|
||||
|
||||
connect(preferencesQuery_PrefsAction, SIGNAL(activated()),
|
||||
this, SLOT(showUIPrefs()));
|
||||
|
||||
@@ -379,6 +388,21 @@ void RclMain::showSortDialog()
|
||||
|
||||
}
|
||||
|
||||
void RclMain::showSpellDialog()
|
||||
{
|
||||
if (spellform == 0) {
|
||||
spellform = new SpellW(0, tr("Spell expansion"),
|
||||
WStyle_Customize | WStyle_NormalBorder |
|
||||
WStyle_Title | WStyle_SysMenu);
|
||||
spellform->show();
|
||||
} else {
|
||||
// Close and reopen, in hope that makes us visible...
|
||||
spellform->close();
|
||||
spellform->show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RclMain::showUIPrefs()
|
||||
{
|
||||
if (uiprefs == 0) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "uiprefs_w.h"
|
||||
#include "rcldb.h"
|
||||
#include "searchdata.h"
|
||||
#include "spell_w.h"
|
||||
|
||||
#include "rclmain.h"
|
||||
|
||||
@@ -52,6 +53,7 @@ public slots:
|
||||
virtual void previewClosed(QWidget * w);
|
||||
virtual void showAdvSearchDialog();
|
||||
virtual void showSortDialog();
|
||||
virtual void showSpellDialog();
|
||||
virtual void showAboutDialog();
|
||||
virtual void startManual();
|
||||
virtual void showDocHistory();
|
||||
@@ -73,6 +75,8 @@ private:
|
||||
AdvSearch *asearchform;
|
||||
SortForm *sortform;
|
||||
UIPrefsDialog *uiprefs;
|
||||
SpellW *spellform;
|
||||
|
||||
DocSeqSortSpec sortspecs;
|
||||
int m_searchId; // Serial number of current search for this process.
|
||||
// Used to match to preview windows
|
||||
|
||||
+5
-1
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _RECOLL_H_INCLUDED_
|
||||
#define _RECOLL_H_INCLUDED_
|
||||
/* @(#$Id: recoll.h,v 1.16 2006-09-11 09:08:44 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: recoll.h,v 1.17 2006-10-11 14:16:26 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include <string>
|
||||
|
||||
#include "rclconfig.h"
|
||||
@@ -34,5 +34,9 @@ extern Rcl::Db *rcldb;
|
||||
extern int recollNeedsExit;
|
||||
extern const std::string recoll_datadir;
|
||||
extern RclHistory *g_dynconf;
|
||||
#ifdef RCL_USE_ASPELL
|
||||
class Aspell;
|
||||
extern Aspell *aspell;
|
||||
#endif
|
||||
|
||||
#endif /* _RECOLL_H_INCLUDED_ */
|
||||
|
||||
@@ -5,6 +5,7 @@ CONFIG += qt warn_on thread release debug
|
||||
|
||||
HEADERS += \
|
||||
advsearch_w.h \
|
||||
spell_w.h \
|
||||
preview_w.h \
|
||||
rclmain_w.h \
|
||||
reslist.h \
|
||||
@@ -21,6 +22,7 @@ SOURCES += \
|
||||
rclmain_w.cpp \
|
||||
reslist.cpp \
|
||||
advsearch_w.cpp \
|
||||
spell_w.cpp \
|
||||
preview_w.cpp \
|
||||
sort_w.cpp \
|
||||
ssearch_w.cpp \
|
||||
@@ -28,6 +30,7 @@ SOURCES += \
|
||||
|
||||
FORMS = \
|
||||
advsearch.ui \
|
||||
spell.ui \
|
||||
preview.ui \
|
||||
rclmain.ui \
|
||||
sort.ui \
|
||||
@@ -40,7 +43,9 @@ IMAGES = images/asearch.png \
|
||||
images/nextpage.png \
|
||||
images/d_prevpage.png \
|
||||
images/prevpage.png \
|
||||
images/sortparms.png
|
||||
images/sortparms.png \
|
||||
images/d_spell.png \
|
||||
images/spell.png
|
||||
|
||||
unix {
|
||||
UI_DIR = .ui
|
||||
@@ -52,7 +57,7 @@ unix {
|
||||
$(BSTATIC) @LIBXAPIAN@ @LIBICONV@ $(BDYNAMIC) \
|
||||
-lz
|
||||
|
||||
INCLUDEPATH += ../common ../index ../query ../unac ../utils
|
||||
INCLUDEPATH += ../common ../index ../query ../unac ../utils ../aspell
|
||||
POST_TARGETDEPS = ../lib/librcl.a
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>SpellBase</class>
|
||||
<widget class="QWidget">
|
||||
<property name="name">
|
||||
<cstring>SpellBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Spelling Explorer</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout3</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout4</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout3</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel">
|
||||
<property name="name">
|
||||
<cstring>Label1</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Plain</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enter word</string>
|
||||
</property>
|
||||
<property name="buddy" stdset="0">
|
||||
<cstring>baseWordLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit">
|
||||
<property name="name">
|
||||
<cstring>baseWordLE</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>LineEditPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>expandPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Expand </string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+E</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>clearPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+C</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>dismissPB</cstring>
|
||||
</property>
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
<property name="accel">
|
||||
<string>Alt+C</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<widget class="QTextEdit">
|
||||
<property name="name">
|
||||
<cstring>suggsTE</cstring>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: spell_w.cpp,v 1.1 2006-10-11 14:16:26 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <qmessagebox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlayout.h>
|
||||
#include <qtooltip.h>
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "recoll.h"
|
||||
#include "spell_w.h"
|
||||
|
||||
#ifdef RCL_USE_ASPELL
|
||||
#include "rclaspell.h"
|
||||
#endif
|
||||
|
||||
void SpellW::init()
|
||||
{
|
||||
// signals and slots connections
|
||||
connect(baseWordLE, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(wordChanged(const QString&)));
|
||||
connect(baseWordLE, SIGNAL(returnPressed()), this, SLOT(doExpand()));
|
||||
connect(expandPB, SIGNAL(clicked()), this, SLOT(doExpand()));
|
||||
connect(clearPB, SIGNAL(clicked()), baseWordLE, SLOT(clear()));
|
||||
connect(dismissPB, SIGNAL(clicked()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void SpellW::doExpand()
|
||||
{
|
||||
#ifdef RCL_USE_ASPELL
|
||||
string reason;
|
||||
if (!aspell || !maybeOpenDb(reason)) {
|
||||
LOGDEB(("SpellW::doExpand: error aspell %p db: %s\n", aspell,
|
||||
reason.c_str()));
|
||||
return;
|
||||
}
|
||||
if (!baseWordLE->text().isEmpty()) {
|
||||
list<string> suggs;
|
||||
string word = string((const char *)baseWordLE->text().utf8());
|
||||
if (!aspell->suggest(*rcldb, word, suggs, reason)) {
|
||||
LOGERR(("SpellW::doExpand:suggest failed: %s\n", reason.c_str()));
|
||||
return;
|
||||
}
|
||||
suggsTE->clear();
|
||||
if (suggs.empty()) {
|
||||
suggsTE->append(tr("No spelling expansion found"));
|
||||
} else {
|
||||
for (list<string>::iterator it = suggs.begin();
|
||||
it != suggs.end(); it++) {
|
||||
suggsTE->append(QString::fromUtf8(it->c_str()));
|
||||
}
|
||||
suggsTE->setCursorPosition(0,0);
|
||||
suggsTE->ensureCursorVisible();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpellW::wordChanged(const QString &text)
|
||||
{
|
||||
if (text.isEmpty()) {
|
||||
expandPB->setEnabled(false);
|
||||
clearPB->setEnabled(false);
|
||||
suggsTE->clear();
|
||||
} else {
|
||||
expandPB->setEnabled(true);
|
||||
clearPB->setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef _ASPELL_W_H_INCLUDED_
|
||||
#define _ASPELL_W_H_INCLUDED_
|
||||
/* @(#$Id: spell_w.h,v 1.1 2006-10-11 14:16:26 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <qwidget.h>
|
||||
#include "rcldb.h"
|
||||
#include "spell.h"
|
||||
|
||||
class SpellW : public SpellBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpellW(QWidget* parent = 0, const char* name = 0, WFlags fl = 0) :
|
||||
SpellBase(parent,name,fl) {init();}
|
||||
|
||||
~SpellW(){}
|
||||
|
||||
public slots:
|
||||
virtual void doExpand();
|
||||
virtual void wordChanged(const QString&);
|
||||
// virtual void textDoubleClicked(int, int);
|
||||
|
||||
signals:
|
||||
// void wordSelect(QString);
|
||||
|
||||
private:
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif /* _ASPELL_W_H_INCLUDED_ */
|
||||
Reference in New Issue
Block a user