mostly cosmetic changes to prepare for a future qt4 port: better separate form design from code

This commit is contained in:
dockes 2006-09-04 15:13:02 +00:00
parent ed7dde42c6
commit c5b545c1a4
29 changed files with 1177 additions and 1297 deletions

View File

@ -1,8 +1,8 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>advsearch</class>
<class>AdvSearchBase</class>
<widget class="QDialog">
<property name="name">
<cstring>advsearch</cstring>
<cstring>AdvSearchBase</cstring>
</property>
<property name="geometry">
<rect>
@ -414,105 +414,5 @@
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>delFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>delFiltypPB_clicked()</slot>
</connection>
<connection>
<sender>searchPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>restrictFtCB</sender>
<signal>toggled(bool)</signal>
<receiver>advsearch</receiver>
<slot>restrictFtCB_toggled(bool)</slot>
</connection>
<connection>
<sender>dismissPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>close()</slot>
</connection>
<connection>
<sender>browsePB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>browsePB_clicked()</slot>
</connection>
<connection>
<sender>addFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>addFiltypPB_clicked()</slot>
</connection>
<connection>
<sender>andWordsLE</sender>
<signal>returnPressed()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>orWordsLE</sender>
<signal>returnPressed()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>noWordsLE</sender>
<signal>returnPressed()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>phraseLE</sender>
<signal>returnPressed()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>subtreeLE</sender>
<signal>returnPressed()</signal>
<receiver>advsearch</receiver>
<slot>searchPB_clicked()</slot>
</connection>
<connection>
<sender>delAFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>delAFiltypPB_clicked()</slot>
</connection>
<connection>
<sender>addAFiltypPB</sender>
<signal>clicked()</signal>
<receiver>advsearch</receiver>
<slot>addAFiltypPB_clicked()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">recoll.h</include>
<include location="local" impldecl="in declaration">searchdata.h</include>
<include location="local" impldecl="in implementation">advsearch.ui.h</include>
</includes>
<signals>
<signal>startSearch(Rcl::AdvSearchData)</signal>
</signals>
<slots>
<slot>delFiltypPB_clicked()</slot>
<slot>delAFiltypPB_clicked()</slot>
<slot>addFiltypPB_clicked()</slot>
<slot>addAFiltypPB_clicked()</slot>
<slot>restrictFtCB_toggled( bool on )</slot>
<slot>searchPB_clicked()</slot>
<slot>browsePB_clicked()</slot>
</slots>
<functions>
<function access="private">init()</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1,19 +1,3 @@
/*
* 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.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
@ -25,145 +9,3 @@
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <list>
#include <string>
#ifndef NO_NAMESPACES
using std::list;
using std::string;
#endif /* NO_NAMESPACES */
#include "recoll.h"
#include "rclconfig.h"
#include "debuglog.h"
#include "searchdata.h"
extern RclConfig *rclconfig;
// Constructor/initialization
void advsearch::init()
{
list<string> types = rclconfig->getAllMimeTypes();
QStringList ql;
for (list<string>::iterator it = types.begin(); it != types.end(); it++) {
ql.append(it->c_str());
}
yesFiltypsLB->insertStringList(ql);
}
// Move selected file types from the searched to the ignored box
void advsearch::delFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
QListBoxItem *item = yesFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
noFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
yesFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
void advsearch::delAFiltypPB_clicked()
{
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
yesFiltypsLB->setSelected(i, true);
}
delFiltypPB_clicked();
}
// Move selected file types from the ignored to the searched box
void advsearch::addFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < noFiltypsLB->count(); i++) {
QListBoxItem *item = noFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
yesFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
noFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
void advsearch::addAFiltypPB_clicked()
{
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
noFiltypsLB->setSelected(i, true);
}
addFiltypPB_clicked();
}
// Activate file type selection
void advsearch::restrictFtCB_toggled(bool on)
{
yesFiltypsLB->setEnabled(on);
delFiltypPB->setEnabled(on);
addFiltypPB->setEnabled(on);
delAFiltypPB->setEnabled(on);
addAFiltypPB->setEnabled(on);
noFiltypsLB->setEnabled(on);
}
void advsearch::searchPB_clicked()
{
Rcl::AdvSearchData mydata;
mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
mydata.phrase = string((const char*)(phraseLE->text().utf8()));
mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
mydata.orwords1 = string((const char*)(orWords1LE->text().utf8()));
mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
mydata.filename = string((const char*)(fileNameLE->text().utf8()));
if (mydata.allwords.empty() && mydata.phrase.empty() &&
mydata.orwords.empty() && mydata.orwords1.empty() &&
mydata.filename.empty()) {
if (mydata.nowords.empty())
return;
QMessageBox::warning(0, "Recoll",
tr("Cannot execute pure negative query. "
"Please enter common terms in the 'any words' field"));
return;
}
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
QCString ctext = yesFiltypsLB->item(i)->text().utf8();
mydata.filetypes.push_back(string((const char *)ctext));
}
}
if (!subtreeLE->text().isEmpty()) {
mydata.topdir = string((const char*)(subtreeLE->text().utf8()));
}
emit startSearch(mydata);
}
void advsearch::browsePB_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
subtreeLE->setText(dir);
}

189
src/qtgui/advsearch_w.cpp Normal file
View File

@ -0,0 +1,189 @@
#ifndef lint
static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.1 2006-09-04 15:13:01 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 "advsearch_w.h"
#include <qvariant.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qframe.h>
#include <qcheckbox.h>
#include <qlistbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <list>
#include <string>
#ifndef NO_NAMESPACES
using std::list;
using std::string;
#endif /* NO_NAMESPACES */
#include "recoll.h"
#include "rclconfig.h"
#include "debuglog.h"
#include "searchdata.h"
extern RclConfig *rclconfig;
void AdvSearch::init()
{
// signals and slots connections
connect( delFiltypPB, SIGNAL( clicked() ), this, SLOT( delFiltypPB_clicked() ) );
connect( searchPB, SIGNAL( clicked() ), this, SLOT( searchPB_clicked() ) );
connect( restrictFtCB, SIGNAL( toggled(bool) ), this, SLOT( restrictFtCB_toggled(bool) ) );
connect( dismissPB, SIGNAL( clicked() ), this, SLOT( close() ) );
connect( browsePB, SIGNAL( clicked() ), this, SLOT( browsePB_clicked() ) );
connect( addFiltypPB, SIGNAL( clicked() ), this, SLOT( addFiltypPB_clicked() ) );
connect( andWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
connect( orWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
connect( noWordsLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
connect( phraseLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
connect( subtreeLE, SIGNAL( returnPressed() ), this, SLOT( searchPB_clicked() ) );
connect( delAFiltypPB, SIGNAL( clicked() ), this, SLOT( delAFiltypPB_clicked() ) );
connect( addAFiltypPB, SIGNAL( clicked() ), this, SLOT( addAFiltypPB_clicked() ) );
list<string> types = rclconfig->getAllMimeTypes();
QStringList ql;
for (list<string>::iterator it = types.begin(); it != types.end(); it++) {
ql.append(it->c_str());
}
yesFiltypsLB->insertStringList(ql);
}
// Move selected file types from the searched to the ignored box
void AdvSearch::delFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
QListBoxItem *item = yesFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
noFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
yesFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
void AdvSearch::delAFiltypPB_clicked()
{
for (unsigned int i = 0; i < yesFiltypsLB->count();i++) {
yesFiltypsLB->setSelected(i, true);
}
delFiltypPB_clicked();
}
// Move selected file types from the ignored to the searched box
void AdvSearch::addFiltypPB_clicked()
{
list<int> trl;
QStringList moved;
for (unsigned int i = 0; i < noFiltypsLB->count(); i++) {
QListBoxItem *item = noFiltypsLB->item(i);
if (item && item->isSelected()) {
moved.push_back(item->text());
trl.push_front(i);
}
}
if (!moved.empty()) {
yesFiltypsLB->insertStringList(moved);
for (list<int>::iterator it = trl.begin();it != trl.end(); it++)
noFiltypsLB->removeItem(*it);
}
yesFiltypsLB->sort();
noFiltypsLB->sort();
}
void AdvSearch::addAFiltypPB_clicked()
{
for (unsigned int i = 0; i < noFiltypsLB->count();i++) {
noFiltypsLB->setSelected(i, true);
}
addFiltypPB_clicked();
}
// Activate file type selection
void AdvSearch::restrictFtCB_toggled(bool on)
{
yesFiltypsLB->setEnabled(on);
delFiltypPB->setEnabled(on);
addFiltypPB->setEnabled(on);
delAFiltypPB->setEnabled(on);
addAFiltypPB->setEnabled(on);
noFiltypsLB->setEnabled(on);
}
void AdvSearch::searchPB_clicked()
{
Rcl::AdvSearchData mydata;
mydata.allwords = string((const char*)(andWordsLE->text().utf8()));
mydata.phrase = string((const char*)(phraseLE->text().utf8()));
mydata.orwords = string((const char*)(orWordsLE->text().utf8()));
mydata.orwords1 = string((const char*)(orWords1LE->text().utf8()));
mydata.nowords = string((const char*)(noWordsLE->text().utf8()));
mydata.filename = string((const char*)(fileNameLE->text().utf8()));
if (mydata.allwords.empty() && mydata.phrase.empty() &&
mydata.orwords.empty() && mydata.orwords1.empty() &&
mydata.filename.empty()) {
if (mydata.nowords.empty())
return;
QMessageBox::warning(0, "Recoll",
tr("Cannot execute pure negative query. "
"Please enter common terms in the 'any words' field"));
return;
}
if (restrictFtCB->isOn() && noFiltypsLB->count() > 0) {
for (unsigned int i = 0; i < yesFiltypsLB->count(); i++) {
QCString ctext = yesFiltypsLB->item(i)->text().utf8();
mydata.filetypes.push_back(string((const char *)ctext));
}
}
if (!subtreeLE->text().isEmpty()) {
mydata.topdir = string((const char*)(subtreeLE->text().utf8()));
}
emit startSearch(mydata);
}
void AdvSearch::browsePB_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
subtreeLE->setText(dir);
}

53
src/qtgui/advsearch_w.h Normal file
View File

@ -0,0 +1,53 @@
#ifndef _ADVSEARCH_W_H_INCLUDED_
#define _ADVSEARCH_W_H_INCLUDED_
/* @(#$Id: advsearch_w.h,v 1.1 2006-09-04 15:13:01 dockes Exp $ (C) 2005 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 <qdialog.h>
#include "advsearch.h"
#include "recoll.h"
#include "searchdata.h"
class AdvSearch : public AdvSearchBase
{
Q_OBJECT
public:
AdvSearch( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ) : AdvSearchBase(parent,name,modal,fl)
{init();}
~AdvSearch(){}
public slots:
virtual void delFiltypPB_clicked();
virtual void delAFiltypPB_clicked();
virtual void addFiltypPB_clicked();
virtual void addAFiltypPB_clicked();
virtual void restrictFtCB_toggled( bool on );
virtual void searchPB_clicked();
virtual void browsePB_clicked();
signals:
void startSearch(Rcl::AdvSearchData);
private:
virtual void init();
};
#endif /* _ADVSEARCH_W_H_INCLUDED_ */

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.11 2006-05-02 09:49:06 dockes Exp $ (C) 2005 Jean-Francois Dockes";
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.12 2006-09-04 15:13:01 dockes Exp $ (C) 2005 Jean-Francois Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -120,9 +120,13 @@ PrefsPack prefs;
*/
void rwSettings(bool writing)
{
fprintf(stderr, "rwSettings: write %d\n", int(writing));
#if QT_VERSION >= 0x040000
QSettings settings("Recoll.org", "recoll");
#else
QSettings settings;
settings.setPath("Recoll.org", "Recoll");
settings.setPath("Recoll.org", "Recoll", QSettings::User);
#endif
SETTING_RW(prefs.mainwidth, "/Recoll/geometry/width", Num, 500);
SETTING_RW(prefs.mainheight, "/Recoll/geometry/height", Num, 400);
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Num, 0);

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.44 2006-04-28 07:54:38 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: main.cpp,v 1.45 2006-09-04 15:13:01 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -70,7 +70,7 @@ RclConfig *rclconfig;
Rcl::Db *rcldb;
int recollNeedsExit;
static string dbdir;
static RclMainBase *mainWindow;
static RclMain *mainWindow;
static string recollsharedir;
bool maybeOpenDb(string &reason, bool force)

View File

@ -1,8 +1,8 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>Preview</class>
<class>PreviewBase</class>
<widget class="QWidget">
<property name="name">
<cstring>Preview</cstring>
<cstring>PreviewBase</cstring>
</property>
<property name="geometry">
<rect>
@ -159,68 +159,5 @@
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>searchTextLine</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>Preview</receiver>
<slot>searchTextLine_textChanged(const QString&amp;)</slot>
</connection>
<connection>
<sender>nextButton</sender>
<signal>clicked()</signal>
<receiver>Preview</receiver>
<slot>nextPressed()</slot>
</connection>
<connection>
<sender>prevButton</sender>
<signal>clicked()</signal>
<receiver>Preview</receiver>
<slot>prevPressed()</slot>
</connection>
<connection>
<sender>clearPB</sender>
<signal>clicked()</signal>
<receiver>searchTextLine</receiver>
<slot>clear()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">qapplication.h</include>
<include location="local" impldecl="in declaration">rcldb.h</include>
<include location="local" impldecl="in implementation">preview.ui.h</include>
</includes>
<variables>
<variable>int matchIndex;</variable>
<variable>int matchPara;</variable>
<variable>bool dynSearchActive;</variable>
<variable>bool canBeep;</variable>
<variable>void *tabData;</variable>
<variable>QWidget *currentW;</variable>
</variables>
<signals>
<signal>previewClosed(QWidget *)</signal>
<signal>wordSelect(QString)</signal>
</signals>
<slots>
<slot>searchTextLine_textChanged( const QString &amp; text )</slot>
<slot>doSearch( const QString &amp;str, bool next, bool reverse )</slot>
<slot>nextPressed()</slot>
<slot>prevPressed()</slot>
<slot>currentChanged( QWidget * tw )</slot>
<slot>closeCurrentTab()</slot>
<slot>setCurTabProps( const string &amp; fn, const Rcl::Doc &amp; doc )</slot>
<slot>textDoubleClicked(int, int)</slot>
</slots>
<functions>
<function access="private" specifier="non virtual">init()</function>
<function>closeEvent( QCloseEvent * e )</function>
<function returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
<function returnType="bool">makeDocCurrent( const string &amp; fn, const Rcl::Doc &amp; doc )</function>
<function returnType="QTextEdit *">getCurrentEditor()</function>
<function returnType="QTextEdit *">addEditorTab()</function>
<function access="private">destroy()</function>
<function access="public" returnType="bool">loadFileInCurrentTab( string fn, size_t sz, const Rcl::Doc &amp; idoc )</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>
</UI>

11
src/qtgui/preview.ui.h Normal file
View File

@ -0,0 +1,11 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

View File

@ -1,23 +0,0 @@
TEMPLATE = app
LANGUAGE = C++
CONFIG += qt warn_on release
unix:LIBS += ../../lib/librcl.a ../../bincimapmime/libmime.a -L/usr/local/lib -lxapian -liconv -lfontconfig -lfreetype -lexpat -lz
unix:INCLUDEPATH += ../ ../../common ../../index ../../query ../../unac ../../utils
SOURCES += pvmain.cpp \
../plaintorich.cpp
FORMS = preview.ui
#
unix {
UI_DIR = .ui
MOC_DIR = .moc
OBJECTS_DIR = .obj
}

View File

@ -1,62 +0,0 @@
#ifndef lint
static char rcsid[] = "@(#$Id: pvmain.cpp,v 1.5 2005-11-24 07:16:16 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <list>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::pair;
#endif /* NO_NAMESPACES */
#include <qapplication.h>
#include <qobject.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlayout.h>
#include "preview.h"
#include "../plaintorich.h"
#include "readfile.h"
const char *filename = "/home/dockes/tmp/tstpv-utf8.txt";
int recollNeedsExit;
int main( int argc, char ** argv )
{
QApplication a(argc, argv);
Preview w;
string text;
if (!file_to_string(filename, text)) {
fprintf(stderr, "Could not read %s\n", filename);
exit(1);
}
list<string> terms;
list<pair<int, int> > termoffs;
string rich = plaintorich(text, terms, termoffs);
QString str = QString::fromUtf8(rich.c_str(), rich.length());
w.pvEdit->setText(str);
// QVBoxLayout *unnamedLayout =
// new QVBoxLayout(0, 11, 6, "unnamedLayout");
QWidget *anon = new QWidget(w.pvTab);
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 11, 6, "unnamedLayout");
QTextEdit *newEd = new QTextEdit(anon, "pvEdit");
anonLayout->addWidget(newEd);
fprintf(stderr, "pvEdit %p newEd: %p\n", w.pvEdit, newEd);
newEd->setReadOnly( TRUE );
newEd->setUndoRedoEnabled( FALSE );
newEd->setText(str);
w.pvTab->addTab(anon, "Tab 2");
#if QT_VERSION < 0x040000
a.setMainWidget(&w);
#endif
w.show();
return a.exec();
}

View File

@ -1,3 +1,6 @@
#ifndef lint
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.1 2006-09-04 15:13:01 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
@ -14,17 +17,6 @@
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <unistd.h>
#include <time.h>
@ -37,6 +29,17 @@ using std::pair;
#include <qmessagebox.h>
#include <qprogressdialog.h>
#include <qthread.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qtextedit.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include "qapplication.h"
#include "debuglog.h"
#include "pathut.h"
@ -46,6 +49,7 @@ using std::pair;
#include "smallut.h"
#include "wipedir.h"
#include "cancelcheck.h"
#include "preview_w.h"
#if (QT_VERSION < 0x030300)
#define wasCanceled wasCancelled
@ -64,8 +68,15 @@ class TabData {
void Preview::init()
{
// signals and slots connections
connect(searchTextLine, SIGNAL(textChanged(const QString&)),
this, SLOT(searchTextLine_textChanged(const QString&)));
connect(nextButton, SIGNAL(clicked()), this, SLOT(nextPressed()));
connect(prevButton, SIGNAL(clicked()), this, SLOT(prevPressed()));
connect(clearPB, SIGNAL(clicked()), searchTextLine, SLOT(clear()));
connect(pvTab, SIGNAL(currentChanged(QWidget *)),
this, SLOT(currentChanged(QWidget *)));
searchTextLine->installEventFilter(this);
dynSearchActive = false;
canBeep = true;
@ -278,13 +289,13 @@ void Preview::closeCurrentTab()
}
QTextEdit * Preview::addEditorTab()
QTextEdit *Preview::addEditorTab()
{
QWidget *anon = new QWidget((QWidget *)pvTab);
QVBoxLayout *anonLayout = new QVBoxLayout(anon, 1, 1, "anonLayout");
QTextEdit *editor = new QTextEdit(anon, "pvEdit");
editor->setReadOnly( TRUE );
editor->setUndoRedoEnabled( FALSE );
editor->setReadOnly(TRUE);
editor->setUndoRedoEnabled(FALSE );
anonLayout->addWidget(editor);
pvTab->addTab(anon, "Tab");
pvTab->showPage(anon);
@ -589,3 +600,4 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc)
}
return true;
}

71
src/qtgui/preview_w.h Normal file
View File

@ -0,0 +1,71 @@
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
/* @(#$Id: preview_w.h,v 1.1 2006-09-04 15:13:01 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 "preview.h"
class Preview : public PreviewBase
{
Q_OBJECT
public:
Preview( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ) :
PreviewBase(parent,name,fl) {init();}
~Preview(){}
virtual void closeEvent( QCloseEvent * e );
virtual bool eventFilter( QObject * target, QEvent * event );
virtual bool makeDocCurrent( const string & fn, const Rcl::Doc & doc );
virtual QTextEdit * getCurrentEditor();
virtual QTextEdit * addEditorTab();
virtual bool loadFileInCurrentTab(string fn, size_t sz,
const Rcl::Doc & idoc );
public slots:
virtual void searchTextLine_textChanged( const QString & text );
virtual void doSearch( const QString &str, bool next, bool reverse );
virtual void nextPressed();
virtual void prevPressed();
virtual void currentChanged( QWidget * tw );
virtual void closeCurrentTab();
virtual void setCurTabProps( const string & fn, const Rcl::Doc & doc );
virtual void textDoubleClicked(int, int);
signals:
void previewClosed(QWidget *);
void wordSelect(QString);
protected:
int matchIndex;
int matchPara;
bool dynSearchActive;
bool canBeep;
void *tabData;
QWidget *currentW;
private:
void init();
virtual void destroy();
};
#endif /* _PREVIEW_W_H_INCLUDED_ */

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.27 2006-04-27 09:23:10 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmain.cpp,v 1.28 2006-09-04 15:13:01 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -95,10 +95,40 @@ void RclMain::init()
m_history = new RclDHistory(historyfile);
connect(sSearch, SIGNAL(startSearch(Rcl::AdvSearchData)),
this, SLOT(startAdvSearch(Rcl::AdvSearchData)));
connect(sSearch, SIGNAL(clearSearch()), resList, SLOT(resetSearch()));
// signals and slots connections
connect(sSearch, SIGNAL(clearSearch()),
resList, SLOT(resetSearch()));
connect(prevPageAction, SIGNAL(activated()),
resList, SLOT(resultPageBack()));
connect(nextPageAction, SIGNAL(activated()),
resList, SLOT(showResultPage()));
connect(resList, SIGNAL(docExpand(int)), this, SLOT(docExpand(int)));
connect(resList, SIGNAL(wordSelect(QString)),
this, SLOT(ssearchAddTerm(QString)));
connect(fileExitAction, SIGNAL(activated() ), this, SLOT(fileExit() ) );
connect(fileStart_IndexingAction, SIGNAL(activated()),
this, SLOT(startIndexing()));
connect(helpAbout_RecollAction, SIGNAL(activated()),
this, SLOT(showAboutDialog()));
connect(userManualAction, SIGNAL(activated()), this, SLOT(startManual()));
connect(toolsDoc_HistoryAction, SIGNAL(activated()),
this, SLOT(showDocHistory()));
connect(toolsAdvanced_SearchAction, SIGNAL(activated()),
this, SLOT(showAdvSearchDialog()));
connect(toolsSort_parametersAction, SIGNAL(activated()),
this, SLOT(showSortDialog()));
connect(preferencesQuery_PrefsAction, SIGNAL(activated()),
this, SLOT(showUIPrefs()));
connect(resList, SIGNAL(nextPageAvailable(bool)),
this, SLOT(enableNextPage(bool)));
connect(resList, SIGNAL(prevPageAvailable(bool)),
this, SLOT(enablePrevPage(bool)));
connect(resList, SIGNAL(docEditClicked(int)),
this, SLOT(startNativeViewer(int)));
connect(resList, SIGNAL(docPreviewClicked(int)),
this, SLOT(startPreview(int)));
nextPageAction->setIconSet(createIconSet("nextpage.png"));
prevPageAction->setIconSet(createIconSet("prevpage.png"));
@ -264,7 +294,7 @@ void RclMain::periodic100()
fileExit();
}
void RclMain::fileStart_IndexingAction_activated()
void RclMain::startIndexing()
{
if (indexingdone)
startindexing = 1;
@ -319,7 +349,7 @@ void RclMain::startAdvSearch(Rcl::AdvSearchData sdata)
void RclMain::showAdvSearchDialog()
{
if (asearchform == 0) {
asearchform = new advsearch(0, tr("Advanced search"), FALSE,
asearchform = new AdvSearch(0, tr("Advanced search"), FALSE,
WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu);
asearchform->setSizeGripEnabled(FALSE);

View File

@ -20,11 +20,11 @@
#include <qvariant.h>
#include <qmainwindow.h>
#include "sortseq.h"
#include "preview.h"
#include "preview_w.h"
#include "recoll.h"
#include "advsearch.h"
#include "sort.h"
#include "uiprefs.h"
#include "advsearch_w.h"
#include "sort_w.h"
#include "uiprefs_w.h"
#include "rcldb.h"
#include "searchdata.h"
@ -47,7 +47,7 @@ public:
public slots:
virtual void fileExit();
virtual void periodic100();
virtual void fileStart_IndexingAction_activated();
virtual void startIndexing();
virtual void startAdvSearch(Rcl::AdvSearchData sdata);
virtual void previewClosed(QWidget * w);
virtual void showAdvSearchDialog();
@ -62,17 +62,17 @@ public slots:
virtual void enablePrevPage(bool);
virtual void docExpand(int);
virtual void ssearchAddTerm(QString);
protected:
virtual void startPreview(int docnum);
virtual void startNativeViewer(int docnum);
private:
Preview *curPreview;
advsearch *asearchform;
AdvSearch *asearchform;
SortForm *sortform;
UIPrefsDialog *uiprefs;
RclSortSpec sortspecs;
RclDHistory *m_history;
private:
virtual void init();
virtual void startPreview( int docnum );
virtual void startNativeViewer( int docnum );
};
#endif // RCLMAIN_H

View File

@ -14,7 +14,7 @@ SOURCES += main.cpp \
FORMS = recollmain.ui \
advsearch.ui \
preview/preview.ui \
preview.ui \
sort.ui \
uiprefs.ui \
ssearchb.ui

View File

@ -41,7 +41,7 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="SSearchBase">
<widget class="SSearch">
<property name="name">
<cstring>sSearch</cstring>
</property>
@ -120,8 +120,8 @@
</toolbars>
<customwidgets>
<customwidget>
<class>SSearchBase</class>
<header location="local">ssearchb.h</header>
<class>SSearch</class>
<header location="local">ssearch_w.h</header>
<sizehint>
<width>-1</width>
<height>-1</height>
@ -133,7 +133,6 @@
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<pixmap>image0</pixmap>
<signal>startSearch(Rcl::AdvSearchData)</signal>
</customwidget>
<customwidget>
@ -298,118 +297,10 @@
</property>
</action>
</actions>
<images>
<image name="image0">
<data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data>
</image>
</images>
<connections>
<connection>
<sender>fileExitAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>fileExit()</slot>
</connection>
<connection>
<sender>fileStart_IndexingAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>fileStart_IndexingAction_activated()</slot>
</connection>
<connection>
<sender>helpAbout_RecollAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showAboutDialog()</slot>
</connection>
<connection>
<sender>userManualAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>startManual()</slot>
</connection>
<connection>
<sender>toolsDoc_HistoryAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showDocHistory()</slot>
</connection>
<connection>
<sender>toolsAdvanced_SearchAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showAdvSearchDialog()</slot>
</connection>
<connection>
<sender>toolsSort_parametersAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showSortDialog()</slot>
</connection>
<connection>
<sender>preferencesQuery_PrefsAction</sender>
<signal>activated()</signal>
<receiver>RclMainBase</receiver>
<slot>showUIPrefs()</slot>
</connection>
<connection>
<sender>prevPageAction</sender>
<signal>activated()</signal>
<receiver>resList</receiver>
<slot>resultPageBack()</slot>
</connection>
<connection>
<sender>nextPageAction</sender>
<signal>activated()</signal>
<receiver>resList</receiver>
<slot>showResultPage()</slot>
</connection>
<connection>
<sender>resList</sender>
<signal>nextPageAvailable(bool)</signal>
<receiver>RclMainBase</receiver>
<slot>enableNextPage(bool)</slot>
</connection>
<connection>
<sender>resList</sender>
<signal>prevPageAvailable(bool)</signal>
<receiver>RclMainBase</receiver>
<slot>enablePrevPage(bool)</slot>
</connection>
<connection>
<sender>resList</sender>
<signal>docEditClicked(int)</signal>
<receiver>RclMainBase</receiver>
<slot>startNativeViewer(int)</slot>
</connection>
<connection>
<sender>resList</sender>
<signal>docPreviewClicked(int)</signal>
<receiver>RclMainBase</receiver>
<slot>startPreview(int)</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">ssearchb.h</include>
<include location="local" impldecl="in declaration">ssearch_w.h</include>
<include location="local" impldecl="in declaration">rclreslist.h</include>
</includes>
<slots>
<slot>fileExit()</slot>
<slot>periodic100()</slot>
<slot>fileStart_IndexingAction_activated()</slot>
<slot>previewClosed( QWidget * w )</slot>
<slot>showAdvSearchDialog()</slot>
<slot>showSortDialog()</slot>
<slot>showAboutDialog()</slot>
<slot>startManual()</slot>
<slot>showDocHistory()</slot>
<slot>showUIPrefs()</slot>
<slot>setUIPrefs()</slot>
<slot>enableNextPage(bool)</slot>
<slot>enablePrevPage(bool)</slot>
<slot>startNativeViewer(int)</slot>
<slot>startPreview(int)</slot>
</slots>
<pixmapinproject/>
<layoutdefaults spacing="6" margin="11"/>
<includehints>

View File

@ -25,48 +25,3 @@
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
void RclMainBase::fileExit()
{
}
void RclMainBase::periodic100()
{
}
void RclMainBase::fileStart_IndexingAction_activated()
{
}
void RclMainBase::previewClosed( QWidget * )
{
}
void RclMainBase::showAdvSearchDialog()
{
}
void RclMainBase::showSortDialog()
{
}
void RclMainBase::showAboutDialog()
{
}
void RclMainBase::startManual()
{
}
void RclMainBase::showDocHistory()
{
}
void RclMainBase::showUIPrefs()
{
}
void RclMainBase::setUIPrefs()
{
}
void RclMainBase::enableNextPage(bool)
{
}
void RclMainBase::enablePrevPage(bool)
{
}
void RclMainBase::startNativeViewer(int)
{
}
void RclMainBase::startPreview(int)
{
}

View File

@ -1,8 +1,8 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>SortForm</class>
<class>SortFormBase</class>
<widget class="QDialog">
<property name="name">
<cstring>SortForm</cstring>
<cstring>SortFormBase</cstring>
</property>
<property name="geometry">
<rect>
@ -161,69 +161,5 @@
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>resetPB</sender>
<signal>clicked()</signal>
<receiver>SortForm</receiver>
<slot>reset()</slot>
</connection>
<connection>
<sender>closePB</sender>
<signal>clicked()</signal>
<receiver>SortForm</receiver>
<slot>close()</slot>
</connection>
<connection>
<sender>mcntSB</sender>
<signal>valueChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>fldCMB1</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>fldCMB2</sender>
<signal>activated(const QString&amp;)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>descCB1</sender>
<signal>stateChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>descCB2</sender>
<signal>stateChanged(int)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
<connection>
<sender>sortCB</sender>
<signal>toggled(bool)</signal>
<receiver>SortForm</receiver>
<slot>setData()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">sortseq.h</include>
<include location="local" impldecl="in implementation">sort.ui.h</include>
</includes>
<signals>
<signal>sortDataChanged(RclSortSpec)</signal>
</signals>
<slots>
<slot>reset()</slot>
<slot>setData()</slot>
</slots>
<functions>
<function>init()</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1,19 +1,3 @@
/*
* 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.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
@ -26,67 +10,3 @@
** destructor.
*****************************************************************************/
#include "sortseq.h"
#include "debuglog.h"
void SortForm::init()
{
const char *labels[5];
labels[0] = "";
labels[1] = "Date";
labels[2] = "Mime type";
labels[3] = 0;
fldCMB1->insertStrList(labels, 3);
fldCMB1->setCurrentItem(0);
fldCMB2->insertStrList(labels, 3);
fldCMB2->setCurrentItem(0);
}
void SortForm::reset()
{
mcntSB->setValue(100);
fldCMB1->setCurrentItem(0);
fldCMB2->setCurrentItem(0);
descCB1->setChecked(false);
descCB1->setChecked(false);
sortCB->setChecked(false);
setData();
}
void SortForm::setData()
{
LOGDEB(("SortForm::setData\n"));
RclSortSpec spec;
mcntSB->setEnabled(sortCB->isChecked());
fldCMB1->setEnabled(sortCB->isChecked());
descCB1->setEnabled(sortCB->isChecked());
fldCMB2->setEnabled(sortCB->isChecked());
descCB2->setEnabled(sortCB->isChecked());
if (!sortCB->isChecked()) {
spec.sortwidth = 0;
} else {
bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
desc = descCB2->isChecked();
switch (fldCMB2->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
spec.sortwidth = mcntSB->value();
}
emit sortDataChanged(spec);
}

98
src/qtgui/sort_w.cpp Normal file
View File

@ -0,0 +1,98 @@
#ifndef lint
static char rcsid[] = "@(#$Id: sort_w.cpp,v 1.1 2006-09-04 15:13:01 dockes Exp $ (C) 2006 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 <qcombobox.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include "sortseq.h"
#include "debuglog.h"
#include "sort_w.h"
void SortForm::init()
{
const char *labels[5];
labels[0] = "";
labels[1] = "Date";
labels[2] = "Mime type";
labels[3] = 0;
fldCMB1->insertStrList(labels, 3);
fldCMB1->setCurrentItem(0);
fldCMB2->insertStrList(labels, 3); fldCMB2->setCurrentItem(0);
// signals and slots connections
connect(resetPB, SIGNAL(clicked()), this, SLOT(reset()));
connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
connect(mcntSB, SIGNAL(valueChanged(int)), this, SLOT(setData()));
connect(fldCMB1, SIGNAL(activated(const QString&)), this, SLOT(setData()));
connect(fldCMB2, SIGNAL(activated(const QString&)), this, SLOT(setData()));
connect(descCB1, SIGNAL(stateChanged(int)), this, SLOT(setData()));
connect(descCB2, SIGNAL(stateChanged(int)), this, SLOT(setData()));
connect(sortCB, SIGNAL(toggled(bool)), this, SLOT(setData()));
}
void SortForm::reset()
{
mcntSB->setValue(100);
fldCMB1->setCurrentItem(0);
fldCMB2->setCurrentItem(0);
descCB1->setChecked(false);
descCB1->setChecked(false);
sortCB->setChecked(false);
setData();
}
void SortForm::setData()
{
LOGDEB(("SortForm::setData\n"));
RclSortSpec spec;
mcntSB->setEnabled(sortCB->isChecked());
fldCMB1->setEnabled(sortCB->isChecked());
descCB1->setEnabled(sortCB->isChecked());
fldCMB2->setEnabled(sortCB->isChecked());
descCB2->setEnabled(sortCB->isChecked());
if (!sortCB->isChecked()) {
spec.sortwidth = 0;
} else {
bool desc = descCB1->isChecked();
switch (fldCMB1->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
desc = descCB2->isChecked();
switch (fldCMB2->currentItem()) {
case 1:
spec.addCrit(RclSortSpec::RCLFLD_MTIME, desc?true:false);
break;
case 2:
spec.addCrit(RclSortSpec::RCLFLD_MIMETYPE, desc?true:false);
break;
}
spec.sortwidth = mcntSB->value();
}
emit sortDataChanged(spec);
}

49
src/qtgui/sort_w.h Normal file
View File

@ -0,0 +1,49 @@
/* @(#$Id: sort_w.h,v 1.1 2006-09-04 15:13:01 dockes Exp $ (C) 2005 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.
*/
#ifndef _SORT_W_H_INCLUDED_
#define _SORT_W_H_INCLUDED_
#include <qvariant.h>
#include <qdialog.h>
#include "sortseq.h"
#include "sort.h"
class SortForm : public SortFormBase
{
Q_OBJECT
public:
SortForm(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ) : SortFormBase(parent, name, modal, fl) {
init();
}
~SortForm() {}
public slots:
virtual void reset();
virtual void setData();
signals:
void sortDataChanged(RclSortSpec);
private:
virtual void init();
};
#endif /* _SORT_W_H_INCLUDED_ */

166
src/qtgui/ssearch_w.cpp Normal file
View File

@ -0,0 +1,166 @@
#ifndef lint
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.1 2006-09-04 15:13:02 dockes Exp $ (C) 2006 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 <qapplication.h>
#include <qinputdialog.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include "debuglog.h"
#include "guiutils.h"
#include "searchdata.h"
#include "ssearch_w.h"
void SSearch::init()
{
searchTypCMB->insertItem(tr("Any term"));
searchTypCMB->insertItem(tr("All terms"));
searchTypCMB->insertItem(tr("File name"));
queryText->insertStringList(prefs.ssearchHistory);
queryText->setEditText("");
connect(queryText->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(startSimpleSearch()));
connect(queryText->lineEdit(), SIGNAL(textChanged(const QString&)),
this, SLOT(searchTextChanged(const QString&)));
connect(clearqPB, SIGNAL(clicked()),
queryText->lineEdit(), SLOT(clear()));
connect(searchPB, SIGNAL(clicked()), this, SLOT(startSimpleSearch()));
}
void SSearch::searchTextChanged( const QString & text )
{
if (text.isEmpty()) {
searchPB->setEnabled(false);
clearqPB->setEnabled(false);
emit clearSearch();
} else {
searchPB->setEnabled(true);
clearqPB->setEnabled(true);
string u8 = (const char *)queryText->currentText().utf8();
if (prefs.autoSearchOnWS && !u8.empty() && u8[u8.length()-1] == ' ')
startSimpleSearch();
}
}
void SSearch::startSimpleSearch()
{
LOGDEB(("SSearch::startSimpleSearch\n"));
Rcl::AdvSearchData sdata;
QCString u8 = queryText->currentText().utf8();
switch (searchTypCMB->currentItem()) {
case 0:
default:
sdata.orwords = u8;
break;
case 1:
sdata.allwords = u8;
break;
case 2:
sdata.filename = u8;
break;
}
prefs.ssearchHistory.clear();
for (int index = 0; index < queryText->count(); index++)
prefs.ssearchHistory.push_back(queryText->text(index));
emit startSearch(sdata);
}
void SSearch::setAnyTermMode()
{
searchTypCMB->setCurrentItem(0);
}
// Complete last word in input by querying db for all possible terms.
void SSearch::completion()
{
if (!rcldb)
return;
if (searchTypCMB->currentItem() == 2) {
// Filename: no completion
QApplication::beep();
return;
}
// Extract last word in text
string txt = (const char *)queryText->currentText().utf8();
string::size_type cs = txt.find_last_of(" ");
if (cs == string::npos)
cs = 0;
else
cs++;
if (txt.size() == 0 || cs == txt.size()) {
QApplication::beep();
return;
}
string s = txt.substr(cs);
LOGDEB(("Completing: [%s]\n", s.c_str()));
// Query database
const int max = 100;
list<string> strs = rcldb->completions(s, prefs.queryStemLang.ascii(),max);
if (strs.size() == 0 || strs.size() == (unsigned int)max) {
QApplication::beep();
return;
}
// If list from db is single word, insert it, else ask user to select
QString res;
bool ok = false;
if (strs.size() == 1) {
res = QString::fromUtf8(strs.begin()->c_str());
ok = true;
} else {
QStringList lst;
for (list<string>::iterator it=strs.begin(); it != strs.end(); it++)
lst.push_back(QString::fromUtf8(it->c_str()));
res = QInputDialog::getItem(tr("Completions"),
tr("Select an item:"), lst, 0,
FALSE, &ok, this);
}
// Insert result
if (ok) {
txt.erase(cs);
txt.append(res.utf8());
queryText->setEditText(QString::fromUtf8(txt.c_str()));
} else {
return;
}
}
// Handle CTRL-TAB to mean completion
bool SSearch::event( QEvent *evt )
{
if ( evt->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent *)evt;
if ( ke->key() == Key_Tab && (ke->state() & Qt::ControlButton)) {
// special tab handling here
completion();
ke->accept();
return TRUE;
}
}
return QWidget::event( evt );
}

51
src/qtgui/ssearch_w.h Normal file
View File

@ -0,0 +1,51 @@
/* @(#$Id: ssearch_w.h,v 1.1 2006-09-04 15:13:02 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.
*/
#ifndef _SSEARCH_W_H_INCLUDED_
#define _SSEARCH_W_H_INCLUDED_
#include <qvariant.h>
#include <qwidget.h>
#include "recoll.h"
#include "searchdata.h"
#include "ssearchb.h"
class SSearch : public SSearchBase
{
Q_OBJECT
public:
SSearch( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 )
: SSearchBase(parent,name,fl) {init();}
~SSearch(){}
virtual void init();
virtual void setAnyTermMode();
virtual void completion();
virtual bool event( QEvent * evt );
public slots:
virtual void searchTextChanged( const QString & text );
virtual void startSimpleSearch();
signals:
void startSearch(Rcl::AdvSearchData);
void clearSearch();
};
#endif /* _SSEARCH_W_H_INCLUDED_ */

View File

@ -113,32 +113,5 @@
</widget>
</hbox>
</widget>
<connections>
<connection>
<sender>searchPB</sender>
<signal>clicked()</signal>
<receiver>SSearchBase</receiver>
<slot>startSimpleSearch()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in declaration">recoll.h</include>
<include location="local" impldecl="in declaration">searchdata.h</include>
<include location="local" impldecl="in implementation">ssearchb.ui.h</include>
</includes>
<signals>
<signal>startSearch(Rcl::AdvSearchData)</signal>
<signal>clearSearch()</signal>
</signals>
<slots>
<slot>searchTextChanged( const QString &amp; text )</slot>
<slot>startSimpleSearch()</slot>
</slots>
<functions>
<function>init()</function>
<function>setAnyTermMode()</function>
<function>completion()</function>
<function returnType="bool">event( QEvent * evt )</function>
</functions>
<layoutdefaults spacing="6" margin="0"/>
</UI>

View File

@ -1,19 +1,3 @@
/*
* 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.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
@ -25,142 +9,3 @@
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <qapplication.h>
#include <qinputdialog.h>
#include "debuglog.h"
#include "guiutils.h"
#include "searchdata.h"
void SSearchBase::init()
{
searchTypCMB->insertItem(tr("Any term"));
searchTypCMB->insertItem(tr("All terms"));
searchTypCMB->insertItem(tr("File name"));
queryText->insertStringList(prefs.ssearchHistory);
queryText->setEditText("");
connect(queryText->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(startSimpleSearch()));
connect(queryText->lineEdit(), SIGNAL(textChanged(const QString&)),
this, SLOT(searchTextChanged(const QString&)));
connect(clearqPB, SIGNAL(clicked()),
queryText->lineEdit(), SLOT(clear()));
}
void SSearchBase::searchTextChanged( const QString & text )
{
if (text.isEmpty()) {
searchPB->setEnabled(false);
clearqPB->setEnabled(false);
emit clearSearch();
} else {
searchPB->setEnabled(true);
clearqPB->setEnabled(true);
string u8 = (const char *)queryText->currentText().utf8();
if (prefs.autoSearchOnWS && !u8.empty() && u8[u8.length()-1] == ' ')
startSimpleSearch();
}
}
void SSearchBase::startSimpleSearch()
{
LOGDEB(("SSearchBase::startSimpleSearch\n"));
Rcl::AdvSearchData sdata;
QCString u8 = queryText->currentText().utf8();
switch (searchTypCMB->currentItem()) {
case 0:
default:
sdata.orwords = u8;
break;
case 1:
sdata.allwords = u8;
break;
case 2:
sdata.filename = u8;
break;
}
prefs.ssearchHistory.clear();
for (int index = 0; index < queryText->count(); index++)
prefs.ssearchHistory.push_back(queryText->text(index));
emit startSearch(sdata);
}
void SSearchBase::setAnyTermMode()
{
searchTypCMB->setCurrentItem(0);
}
// Complete last word in input by querying db for all possible terms.
void SSearchBase::completion()
{
if (!rcldb)
return;
if (searchTypCMB->currentItem() == 2) {
// Filename: no completion
QApplication::beep();
return;
}
// Extract last word in text
string txt = (const char *)queryText->currentText().utf8();
string::size_type cs = txt.find_last_of(" ");
if (cs == string::npos)
cs = 0;
else
cs++;
if (txt.size() == 0 || cs == txt.size()) {
QApplication::beep();
return;
}
string s = txt.substr(cs);
LOGDEB(("Completing: [%s]\n", s.c_str()));
// Query database
const int max = 100;
list<string> strs = rcldb->completions(s, prefs.queryStemLang.ascii(),max);
if (strs.size() == 0 || strs.size() == (unsigned int)max) {
QApplication::beep();
return;
}
// If list from db is single word, insert it, else ask user to select
QString res;
bool ok = false;
if (strs.size() == 1) {
res = QString::fromUtf8(strs.begin()->c_str());
ok = true;
} else {
QStringList lst;
for (list<string>::iterator it=strs.begin(); it != strs.end(); it++)
lst.push_back(QString::fromUtf8(it->c_str()));
res = QInputDialog::getItem(tr("Completions"),
tr("Select an item:"), lst, 0,
FALSE, &ok, this);
}
// Insert result
if (ok) {
txt.erase(cs);
txt.append(res.utf8());
queryText->setEditText(QString::fromUtf8(txt.c_str()));
} else {
return;
}
}
// Handle CTRL-TAB to mean completion
bool SSearchBase::event( QEvent *evt )
{
if ( evt->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent *)evt;
if ( ke->key() == Key_Tab && (ke->state() & Qt::ControlButton)) {
// special tab handling here
completion();
ke->accept();
return TRUE;
}
}
return QWidget::event( evt );
}

View File

@ -1,8 +1,8 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>UIPrefsDialog</class>
<class>UIPrefsDialogBase</class>
<widget class="QDialog">
<property name="name">
<cstring>uiPrefsDialog</cstring>
<cstring>uiPrefsDialogBase</cstring>
</property>
<property name="geometry">
<rect>
@ -558,51 +558,5 @@ May be slow for big documents.</string>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>uiPrefsDialog</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>uiPrefsDialog</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>buildAbsCB</sender>
<signal>toggled(bool)</signal>
<receiver>replAbsCB</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">uiprefs.ui.h</include>
</includes>
<variables>
<variable access="public">QString reslistFontFamily;</variable>
<variable access="public">int reslistFontSize;</variable>
</variables>
<signals>
<signal>uiprefsDone()</signal>
</signals>
<slots>
<slot access="protected">accept()</slot>
<slot>showFontDialog()</slot>
<slot>resetReslistFont()</slot>
<slot>showBrowserDialog()</slot>
<slot>extraDbTextChanged( const QString &amp; text )</slot>
<slot>addAADbPB_clicked()</slot>
<slot>addADbPB_clicked()</slot>
<slot>delADbPB_clicked()</slot>
<slot>delAADbPB_clicked()</slot>
<slot>addExtraDbPB_clicked()</slot>
<slot>browseDbPB_clicked()</slot>
</slots>
<functions>
<function>init()</function>
</functions>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -1,19 +1,3 @@
/*
* 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.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
@ -25,306 +9,3 @@
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <sys/stat.h>
#include <string>
#include <algorithm>
#include <list>
#include "qfontdialog.h"
#include "qfiledialog.h"
#include "qspinbox.h"
#include "qmessagebox.h"
#include "recoll.h"
#include "guiutils.h"
#include "rcldb.h"
#include "pathut.h"
void UIPrefsDialog::init()
{
// Entries per result page spinbox
pageLenSB->setValue(prefs.respagesize);
// Show icons checkbox
useIconsCB->setChecked(prefs.showicons);
autoSearchCB->setChecked(prefs.autoSearchOnWS);
// Result list font family and size
reslistFontFamily = prefs.reslistfontfamily;
reslistFontSize = prefs.reslistfontsize;
QString s;
if (prefs.reslistfontfamily.length() == 0) {
reslistFontPB->setText(this->font().family() + "-" +
s.setNum(this->font().pointSize()));
} else {
reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize));
}
helpBrowserLE->setText(prefs.htmlBrowser);
// Stemming language combobox
stemLangCMB->insertItem("(no stemming)");
list<string> langs;
string reason;
if (!maybeOpenDb(reason)) {
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
exit(1);
}
langs = rcldb->getStemLangs();
int i = 0, cur = -1;
for (list<string>::const_iterator it = langs.begin();
it != langs.end(); it++) {
stemLangCMB->
insertItem(QString::fromAscii(it->c_str(), it->length()));
i++;
if (cur == -1) {
if (!strcmp(prefs.queryStemLang.ascii(), it->c_str()))
cur = i;
}
}
if (cur < 0)
cur = 0;
stemLangCMB->setCurrentItem(cur);
buildAbsCB->setDown(prefs.queryBuildAbstract);
if (!prefs.queryBuildAbstract) {
replAbsCB->setEnabled(false);
}
replAbsCB->setDown(prefs.queryReplaceAbstract);
// Initialize the extra databases listboxes
QStringList ql;
for (list<string>::iterator it = prefs.allExtraDbs.begin();
it != prefs.allExtraDbs.end(); it++) {
ql.append(QString::fromLocal8Bit(it->c_str()));
}
allDbsLB->insertStringList(ql);
ql.clear();
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
ql.append(QString::fromLocal8Bit(it->c_str()));
}
actDbsLB->insertStringList(ql);
ql.clear();
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
SLOT(extraDbTextChanged(const QString&)));
connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked()));
connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked()));
connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked()));
connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked()));
connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked()));
connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
}
void UIPrefsDialog::accept()
{
prefs.showicons = useIconsCB->isChecked();
prefs.autoSearchOnWS = autoSearchCB->isChecked();
prefs.respagesize = pageLenSB->value();
prefs.reslistfontfamily = reslistFontFamily;
prefs.reslistfontsize = reslistFontSize;
prefs.htmlBrowser = helpBrowserLE->text();
if (stemLangCMB->currentItem() == 0) {
prefs.queryStemLang = "";
} else {
prefs.queryStemLang = stemLangCMB->currentText();
}
prefs.queryBuildAbstract = buildAbsCB->isChecked();
prefs.queryReplaceAbstract = buildAbsCB->isChecked() &&
replAbsCB->isChecked();
prefs.activeExtraDbs.clear();
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
QListBoxItem *item = actDbsLB->item(i);
if (item)
prefs.activeExtraDbs.push_back((const char *)item->text().local8Bit());
}
prefs.allExtraDbs.clear();
for (unsigned int i = 0; i < allDbsLB->count(); i++) {
QListBoxItem *item = allDbsLB->item(i);
if (item)
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit());
}
rwSettings(true);
string reason;
maybeOpenDb(reason, true);
emit uiprefsDone();
QDialog::accept();
}
void UIPrefsDialog::showFontDialog()
{
bool ok;
QFont font;
if (prefs.reslistfontfamily.length()) {
font.setFamily(prefs.reslistfontfamily);
font.setPointSize(prefs.reslistfontsize);
}
font = QFontDialog::getFont(&ok, font, this );
if (ok) {
// Check if the default font was set, in which case we
// erase the preference
if (font.family().compare(this->font().family()) ||
font.pointSize() != this->font().pointSize()) {
reslistFontFamily = font.family();
reslistFontSize = font.pointSize();
QString s;
reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize));
} else {
reslistFontFamily = "";
reslistFontSize = 0;
}
}
}
void UIPrefsDialog::resetReslistFont()
{
reslistFontFamily = "";
reslistFontSize = 0;
reslistFontPB->setText(this->font().family() + "-" +
QString().setNum(this->font().pointSize()));
}
void UIPrefsDialog::showBrowserDialog()
{
QString s = QFileDialog::getOpenFileName("/usr",
"",
this,
"open file dialog",
"Choose a file" );
if (s)
helpBrowserLE->setText(s);
}
////////////////////////////////////////////
// External / extra search databases setup
// TBD: a way to remove entry from 'all' list (del button? )
void UIPrefsDialog::extraDbTextChanged(const QString &text)
{
if (text.isEmpty()) {
addExtraDbPB->setEnabled(false);
} else {
addExtraDbPB->setEnabled(true);
}
}
/**
* Add the selected extra dbs to the active list
*/
void UIPrefsDialog::addADbPB_clicked()
{
for (unsigned int i = 0; i < allDbsLB->count();i++) {
QListBoxItem *item = allDbsLB->item(i);
if (item && item->isSelected()) {
allDbsLB->setSelected(i, false);
if (!actDbsLB->findItem(item->text(),
Qt::CaseSensitive|Qt::ExactMatch)) {
actDbsLB->insertItem(item->text());
}
}
}
actDbsLB->sort();
}
/**
* Make all extra dbs active
*/
void UIPrefsDialog::addAADbPB_clicked()
{
for (unsigned int i = 0; i < allDbsLB->count();i++) {
allDbsLB->setSelected(i, true);
}
addADbPB_clicked();
}
/**
* Remove the selected entries from the list of active extra search dbs
*/
void UIPrefsDialog::delADbPB_clicked()
{
list<int> rmi;
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
QListBoxItem *item = actDbsLB->item(i);
if (item && item->isSelected()) {
rmi.push_front(i);
}
}
for (list<int>::iterator ii = rmi.begin(); ii != rmi.end(); ii++) {
actDbsLB->removeItem(*ii);
}
}
/**
* Remove all extra search databases from the active list
*/
void UIPrefsDialog::delAADbPB_clicked()
{
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
actDbsLB->setSelected(i, true);
}
delADbPB_clicked();
}
/**
* Add the current content of the extra db line editor to the list of all
* extra dbs. We do a textual comparison to check for duplicates, except for
* the main db for which we check inode numbers.
*/
void UIPrefsDialog::addExtraDbPB_clicked()
{
string dbdir = (const char *)extraDbLE->text().local8Bit();
path_catslash(dbdir);
if (!Rcl::Db::testDbDir(dbdir)) {
QMessageBox::warning(0, "Recoll",
tr("The selected directory does not appear to be a Xapian database"));
return;
}
struct stat st1, st2;
stat(dbdir.c_str(), &st1);
string rcldbdir;
if (rcldb)
rcldbdir = rcldb->getDbDir();
stat(rcldbdir.c_str(), &st2);
path_catslash(rcldbdir);
fprintf(stderr, "rcldbdir: [%s]\n", rcldbdir.c_str());
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
QMessageBox::warning(0, "Recoll",
tr("This is the main/local database!"));
return;
}
if (allDbsLB->findItem(extraDbLE->text(),
Qt::CaseSensitive|Qt::ExactMatch)) {
QMessageBox::warning(0, "Recoll",
tr("The selected directory is already in the database list"));
return;
}
allDbsLB->insertItem(extraDbLE->text());
allDbsLB->sort();
}
void UIPrefsDialog::browseDbPB_clicked()
{
QFileDialog fdia;
bool savedh = fdia.showHiddenFiles();
fdia.setShowHiddenFiles(true);
QString s = QFileDialog::getExistingDirectory("", this, 0,
tr("Select directory holding xapian database (ie: /home/someone/.recoll/xapiandb)"));
fdia.setShowHiddenFiles(savedh);
if (s)
extraDbLE->setText(s);
}

338
src/qtgui/uiprefs_w.cpp Normal file
View File

@ -0,0 +1,338 @@
#ifndef lint
static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.1 2006-09-04 15:13:02 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 <sys/stat.h>
#include <string>
#include <algorithm>
#include <list>
#include <qfontdialog.h>
#include <qfiledialog.h>
#include <qspinbox.h>
#include <qmessagebox.h>
#include <qvariant.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qwidget.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qlistbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include "recoll.h"
#include "guiutils.h"
#include "rcldb.h"
#include "pathut.h"
#include "uiprefs_w.h"
void UIPrefsDialog::init()
{
// Entries per result page spinbox
pageLenSB->setValue(prefs.respagesize);
// Show icons checkbox
useIconsCB->setChecked(prefs.showicons);
autoSearchCB->setChecked(prefs.autoSearchOnWS);
// Result list font family and size
reslistFontFamily = prefs.reslistfontfamily;
reslistFontSize = prefs.reslistfontsize;
QString s;
if (prefs.reslistfontfamily.length() == 0) {
reslistFontPB->setText(this->font().family() + "-" +
s.setNum(this->font().pointSize()));
} else {
reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize));
}
helpBrowserLE->setText(prefs.htmlBrowser);
// Stemming language combobox
stemLangCMB->insertItem("(no stemming)");
list<string> langs;
string reason;
if (!maybeOpenDb(reason)) {
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
exit(1);
}
langs = rcldb->getStemLangs();
int i = 0, cur = -1;
for (list<string>::const_iterator it = langs.begin();
it != langs.end(); it++) {
stemLangCMB->
insertItem(QString::fromAscii(it->c_str(), it->length()));
i++;
if (cur == -1) {
if (!strcmp(prefs.queryStemLang.ascii(), it->c_str()))
cur = i;
}
}
if (cur < 0)
cur = 0;
stemLangCMB->setCurrentItem(cur);
buildAbsCB->setDown(prefs.queryBuildAbstract);
if (!prefs.queryBuildAbstract) {
replAbsCB->setEnabled(false);
}
replAbsCB->setDown(prefs.queryReplaceAbstract);
// Initialize the extra databases listboxes
QStringList ql;
for (list<string>::iterator it = prefs.allExtraDbs.begin();
it != prefs.allExtraDbs.end(); it++) {
ql.append(QString::fromLocal8Bit(it->c_str()));
}
allDbsLB->insertStringList(ql);
ql.clear();
for (list<string>::iterator it = prefs.activeExtraDbs.begin();
it != prefs.activeExtraDbs.end(); it++) {
ql.append(QString::fromLocal8Bit(it->c_str()));
}
actDbsLB->insertStringList(ql);
ql.clear();
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
SLOT(extraDbTextChanged(const QString&)));
connect(addAADbPB, SIGNAL(clicked()), this, SLOT(addAADbPB_clicked()));
connect(addADbPB, SIGNAL(clicked()), this, SLOT(addADbPB_clicked()));
connect(delADbPB, SIGNAL(clicked()), this, SLOT(delADbPB_clicked()));
connect(delAADbPB, SIGNAL(clicked()), this, SLOT(delAADbPB_clicked()));
connect(addExtraDbPB, SIGNAL(clicked()), this, SLOT(addExtraDbPB_clicked()));
connect(browseDbPB, SIGNAL(clicked()), this, SLOT(browseDbPB_clicked()));
connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(buildAbsCB, SIGNAL(toggled(bool)),
replAbsCB, SLOT(setEnabled(bool)));
}
void UIPrefsDialog::accept()
{
prefs.showicons = useIconsCB->isChecked();
prefs.autoSearchOnWS = autoSearchCB->isChecked();
prefs.respagesize = pageLenSB->value();
prefs.reslistfontfamily = reslistFontFamily;
prefs.reslistfontsize = reslistFontSize;
prefs.htmlBrowser = helpBrowserLE->text();
if (stemLangCMB->currentItem() == 0) {
prefs.queryStemLang = "";
} else {
prefs.queryStemLang = stemLangCMB->currentText();
}
prefs.queryBuildAbstract = buildAbsCB->isChecked();
prefs.queryReplaceAbstract = buildAbsCB->isChecked() &&
replAbsCB->isChecked();
prefs.activeExtraDbs.clear();
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
QListBoxItem *item = actDbsLB->item(i);
if (item)
prefs.activeExtraDbs.push_back((const char *)item->text().local8Bit());
}
prefs.allExtraDbs.clear();
for (unsigned int i = 0; i < allDbsLB->count(); i++) {
QListBoxItem *item = allDbsLB->item(i);
if (item)
prefs.allExtraDbs.push_back((const char *)item->text().local8Bit());
}
rwSettings(true);
string reason;
maybeOpenDb(reason, true);
emit uiprefsDone();
QDialog::accept();
}
void UIPrefsDialog::showFontDialog()
{
bool ok;
QFont font;
if (prefs.reslistfontfamily.length()) {
font.setFamily(prefs.reslistfontfamily);
font.setPointSize(prefs.reslistfontsize);
}
font = QFontDialog::getFont(&ok, font, this);
if (ok) {
// Check if the default font was set, in which case we
// erase the preference
if (font.family().compare(this->font().family()) ||
font.pointSize() != this->font().pointSize()) {
reslistFontFamily = font.family();
reslistFontSize = font.pointSize();
QString s;
reslistFontPB->setText(reslistFontFamily + "-" +
s.setNum(reslistFontSize));
} else {
reslistFontFamily = "";
reslistFontSize = 0;
}
}
}
void UIPrefsDialog::resetReslistFont()
{
reslistFontFamily = "";
reslistFontSize = 0;
reslistFontPB->setText(this->font().family() + "-" +
QString().setNum(this->font().pointSize()));
}
void UIPrefsDialog::showBrowserDialog()
{
QString s = QFileDialog::getOpenFileName("/usr",
"",
this,
"open file dialog",
"Choose a file");
if (s)
helpBrowserLE->setText(s);
}
////////////////////////////////////////////
// External / extra search databases setup
// TBD: a way to remove entry from 'all' list (del button?)
void UIPrefsDialog::extraDbTextChanged(const QString &text)
{
if (text.isEmpty()) {
addExtraDbPB->setEnabled(false);
} else {
addExtraDbPB->setEnabled(true);
}
}
/**
* Add the selected extra dbs to the active list
*/
void UIPrefsDialog::addADbPB_clicked()
{
for (unsigned int i = 0; i < allDbsLB->count();i++) {
QListBoxItem *item = allDbsLB->item(i);
if (item && item->isSelected()) {
allDbsLB->setSelected(i, false);
if (!actDbsLB->findItem(item->text(),
Qt::CaseSensitive|Qt::ExactMatch)) {
actDbsLB->insertItem(item->text());
}
}
}
actDbsLB->sort();
}
/**
* Make all extra dbs active
*/
void UIPrefsDialog::addAADbPB_clicked()
{
for (unsigned int i = 0; i < allDbsLB->count();i++) {
allDbsLB->setSelected(i, true);
}
addADbPB_clicked();
}
/**
* Remove the selected entries from the list of active extra search dbs
*/
void UIPrefsDialog::delADbPB_clicked()
{
list<int> rmi;
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
QListBoxItem *item = actDbsLB->item(i);
if (item && item->isSelected()) {
rmi.push_front(i);
}
}
for (list<int>::iterator ii = rmi.begin(); ii != rmi.end(); ii++) {
actDbsLB->removeItem(*ii);
}
}
/**
* Remove all extra search databases from the active list
*/
void UIPrefsDialog::delAADbPB_clicked()
{
for (unsigned int i = 0; i < actDbsLB->count(); i++) {
actDbsLB->setSelected(i, true);
}
delADbPB_clicked();
}
/**
* Add the current content of the extra db line editor to the list of all
* extra dbs. We do a textual comparison to check for duplicates, except for
* the main db for which we check inode numbers.
*/
void UIPrefsDialog::addExtraDbPB_clicked()
{
string dbdir = (const char *)extraDbLE->text().local8Bit();
path_catslash(dbdir);
if (!Rcl::Db::testDbDir(dbdir)) {
QMessageBox::warning(0, "Recoll",
tr("The selected directory does not appear to be a Xapian database"));
return;
}
struct stat st1, st2;
stat(dbdir.c_str(), &st1);
string rcldbdir;
if (rcldb)
rcldbdir = rcldb->getDbDir();
stat(rcldbdir.c_str(), &st2);
path_catslash(rcldbdir);
fprintf(stderr, "rcldbdir: [%s]\n", rcldbdir.c_str());
if (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
QMessageBox::warning(0, "Recoll",
tr("This is the main/local database!"));
return;
}
if (allDbsLB->findItem(extraDbLE->text(),
Qt::CaseSensitive|Qt::ExactMatch)) {
QMessageBox::warning(0, "Recoll",
tr("The selected directory is already in the database list"));
return;
}
allDbsLB->insertItem(extraDbLE->text());
allDbsLB->sort();
}
void UIPrefsDialog::browseDbPB_clicked()
{
QFileDialog fdia;
bool savedh = fdia.showHiddenFiles();
fdia.setShowHiddenFiles(true);
QString s = QFileDialog::getExistingDirectory("", this, 0,
tr("Select directory holding xapian database (ie: /home/someone/.recoll/xapiandb)"));
fdia.setShowHiddenFiles(savedh);
if (s)
extraDbLE->setText(s);
}

59
src/qtgui/uiprefs_w.h Normal file
View File

@ -0,0 +1,59 @@
/* @(#$Id: uiprefs_w.h,v 1.1 2006-09-04 15:13:02 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.
*/
#ifndef _UIPREFS_W_H_INCLUDED_
#define _UIPREFS_W_H_INCLUDED_
/* @(#$Id: uiprefs_w.h,v 1.1 2006-09-04 15:13:02 dockes Exp $ (C) 2005 J.F.Dockes */
#include <qvariant.h>
#include <qdialog.h>
#include "uiprefs.h"
class UIPrefsDialog : public UIPrefsDialogBase
{
Q_OBJECT
public:
UIPrefsDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ): UIPrefsDialogBase(parent,name,modal,fl) {init();}
~UIPrefsDialog(){};
QString reslistFontFamily;
int reslistFontSize;
virtual void init();
public slots:
virtual void showFontDialog();
virtual void resetReslistFont();
virtual void showBrowserDialog();
virtual void extraDbTextChanged( const QString & text );
virtual void addAADbPB_clicked();
virtual void addADbPB_clicked();
virtual void delADbPB_clicked();
virtual void delAADbPB_clicked();
virtual void addExtraDbPB_clicked();
virtual void browseDbPB_clicked();
signals:
void uiprefsDone();
protected slots:
virtual void accept();
};
#endif /* _UIPREFS_W_H_INCLUDED_ */