From c5b545c1a4d692ea806d58da00d62aaf30a2d300 Mon Sep 17 00:00:00 2001 From: dockes Date: Mon, 4 Sep 2006 15:13:02 +0000 Subject: [PATCH] mostly cosmetic changes to prepare for a future qt4 port: better separate form design from code --- src/qtgui/advsearch.ui | 104 +----- src/qtgui/advsearch.ui.h | 158 -------- src/qtgui/advsearch_w.cpp | 189 ++++++++++ src/qtgui/advsearch_w.h | 53 +++ src/qtgui/guiutils.cpp | 10 +- src/qtgui/main.cpp | 4 +- src/qtgui/{preview => }/preview.ui | 67 +--- src/qtgui/preview.ui.h | 11 + src/qtgui/preview/preview.pro | 23 -- src/qtgui/preview/pvmain.cpp | 62 ---- .../{preview/preview.ui.h => preview_w.cpp} | 40 ++- src/qtgui/preview_w.h | 71 ++++ src/qtgui/rclmain.cpp | 38 +- src/qtgui/rclmain.h | 20 +- src/qtgui/recoll.pro.in | 2 +- src/qtgui/recollmain.ui | 117 +----- src/qtgui/recollmain.ui.h | 45 --- src/qtgui/sort.ui | 68 +--- src/qtgui/sort.ui.h | 80 ----- src/qtgui/sort_w.cpp | 98 +++++ src/qtgui/sort_w.h | 49 +++ src/qtgui/ssearch_w.cpp | 166 +++++++++ src/qtgui/ssearch_w.h | 51 +++ src/qtgui/ssearchb.ui | 27 -- src/qtgui/ssearchb.ui.h | 155 -------- src/qtgui/uiprefs.ui | 50 +-- src/qtgui/uiprefs.ui.h | 319 ----------------- src/qtgui/uiprefs_w.cpp | 338 ++++++++++++++++++ src/qtgui/uiprefs_w.h | 59 +++ 29 files changed, 1177 insertions(+), 1297 deletions(-) create mode 100644 src/qtgui/advsearch_w.cpp create mode 100644 src/qtgui/advsearch_w.h rename src/qtgui/{preview => }/preview.ui (71%) create mode 100644 src/qtgui/preview.ui.h delete mode 100644 src/qtgui/preview/preview.pro delete mode 100644 src/qtgui/preview/pvmain.cpp rename src/qtgui/{preview/preview.ui.h => preview_w.cpp} (94%) create mode 100644 src/qtgui/preview_w.h create mode 100644 src/qtgui/sort_w.cpp create mode 100644 src/qtgui/sort_w.h create mode 100644 src/qtgui/ssearch_w.cpp create mode 100644 src/qtgui/ssearch_w.h create mode 100644 src/qtgui/uiprefs_w.cpp create mode 100644 src/qtgui/uiprefs_w.h diff --git a/src/qtgui/advsearch.ui b/src/qtgui/advsearch.ui index 86560458..b6cdec79 100644 --- a/src/qtgui/advsearch.ui +++ b/src/qtgui/advsearch.ui @@ -1,8 +1,8 @@ -advsearch +AdvSearchBase - advsearch + AdvSearchBase @@ -414,105 +414,5 @@ - - - delFiltypPB - clicked() - advsearch - delFiltypPB_clicked() - - - searchPB - clicked() - advsearch - searchPB_clicked() - - - restrictFtCB - toggled(bool) - advsearch - restrictFtCB_toggled(bool) - - - dismissPB - clicked() - advsearch - close() - - - browsePB - clicked() - advsearch - browsePB_clicked() - - - addFiltypPB - clicked() - advsearch - addFiltypPB_clicked() - - - andWordsLE - returnPressed() - advsearch - searchPB_clicked() - - - orWordsLE - returnPressed() - advsearch - searchPB_clicked() - - - noWordsLE - returnPressed() - advsearch - searchPB_clicked() - - - phraseLE - returnPressed() - advsearch - searchPB_clicked() - - - subtreeLE - returnPressed() - advsearch - searchPB_clicked() - - - delAFiltypPB - clicked() - advsearch - delAFiltypPB_clicked() - - - addAFiltypPB - clicked() - advsearch - addAFiltypPB_clicked() - - - - recoll.h - searchdata.h - advsearch.ui.h - - - startSearch(Rcl::AdvSearchData) - - - delFiltypPB_clicked() - delAFiltypPB_clicked() - addFiltypPB_clicked() - addAFiltypPB_clicked() - restrictFtCB_toggled( bool on ) - searchPB_clicked() - browsePB_clicked() - - - init() - diff --git a/src/qtgui/advsearch.ui.h b/src/qtgui/advsearch.ui.h index 61f14801..6dbb9c2d 100644 --- a/src/qtgui/advsearch.ui.h +++ b/src/qtgui/advsearch.ui.h @@ -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 -#include - -#include -#include - -#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 types = rclconfig->getAllMimeTypes(); - - QStringList ql; - for (list::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 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::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 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::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); -} - diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp new file mode 100644 index 00000000..1e685f85 --- /dev/null +++ b/src/qtgui/advsearch_w.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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 types = rclconfig->getAllMimeTypes(); + + QStringList ql; + for (list::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 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::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 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::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); +} + diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h new file mode 100644 index 00000000..bfccaaae --- /dev/null +++ b/src/qtgui/advsearch_w.h @@ -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 +#include +#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_ */ diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 684e0b6e..272b1363 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -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); diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 4e8f12f7..0461f69d 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -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) diff --git a/src/qtgui/preview/preview.ui b/src/qtgui/preview.ui similarity index 71% rename from src/qtgui/preview/preview.ui rename to src/qtgui/preview.ui index 8b6c264e..ba1e85bb 100644 --- a/src/qtgui/preview/preview.ui +++ b/src/qtgui/preview.ui @@ -1,8 +1,8 @@ -Preview +PreviewBase - Preview + PreviewBase @@ -159,68 +159,5 @@ - - - searchTextLine - textChanged(const QString&) - Preview - searchTextLine_textChanged(const QString&) - - - nextButton - clicked() - Preview - nextPressed() - - - prevButton - clicked() - Preview - prevPressed() - - - clearPB - clicked() - searchTextLine - clear() - - - - qapplication.h - rcldb.h - preview.ui.h - - - int matchIndex; - int matchPara; - bool dynSearchActive; - bool canBeep; - void *tabData; - QWidget *currentW; - - - previewClosed(QWidget *) - wordSelect(QString) - - - searchTextLine_textChanged( const QString & text ) - doSearch( const QString &str, bool next, bool reverse ) - nextPressed() - prevPressed() - currentChanged( QWidget * tw ) - closeCurrentTab() - setCurTabProps( const string & fn, const Rcl::Doc & doc ) - textDoubleClicked(int, int) - - - init() - closeEvent( QCloseEvent * e ) - eventFilter( QObject * target, QEvent * event ) - makeDocCurrent( const string & fn, const Rcl::Doc & doc ) - getCurrentEditor() - addEditorTab() - destroy() - loadFileInCurrentTab( string fn, size_t sz, const Rcl::Doc & idoc ) - diff --git a/src/qtgui/preview.ui.h b/src/qtgui/preview.ui.h new file mode 100644 index 00000000..6dbb9c2d --- /dev/null +++ b/src/qtgui/preview.ui.h @@ -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. +*****************************************************************************/ diff --git a/src/qtgui/preview/preview.pro b/src/qtgui/preview/preview.pro deleted file mode 100644 index 0e26b65a..00000000 --- a/src/qtgui/preview/preview.pro +++ /dev/null @@ -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 - } - diff --git a/src/qtgui/preview/pvmain.cpp b/src/qtgui/preview/pvmain.cpp deleted file mode 100644 index 5bd16d1e..00000000 --- a/src/qtgui/preview/pvmain.cpp +++ /dev/null @@ -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 -#include - -#include -#include - -#ifndef NO_NAMESPACES -using std::string; -using std::list; -using std::pair; -#endif /* NO_NAMESPACES */ - -#include -#include -#include -#include -#include - -#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 terms; - list > 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(); -} diff --git a/src/qtgui/preview/preview.ui.h b/src/qtgui/preview_w.cpp similarity index 94% rename from src/qtgui/preview/preview.ui.h rename to src/qtgui/preview_w.cpp index 64c1b9ec..87713ac2 100644 --- a/src/qtgui/preview/preview.ui.h +++ b/src/qtgui/preview_w.cpp @@ -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 #include @@ -37,6 +29,17 @@ using std::pair; #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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; } + diff --git a/src/qtgui/preview_w.h b/src/qtgui/preview_w.h new file mode 100644 index 00000000..ea00eab2 --- /dev/null +++ b/src/qtgui/preview_w.h @@ -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 +#include +#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_ */ diff --git a/src/qtgui/rclmain.cpp b/src/qtgui/rclmain.cpp index 2a2f1ff1..aaa64991 100644 --- a/src/qtgui/rclmain.cpp +++ b/src/qtgui/rclmain.cpp @@ -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); diff --git a/src/qtgui/rclmain.h b/src/qtgui/rclmain.h index 1440a4a7..cf6182d5 100644 --- a/src/qtgui/rclmain.h +++ b/src/qtgui/rclmain.h @@ -20,11 +20,11 @@ #include #include #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 diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index 850b2be1..711615bd 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -14,7 +14,7 @@ SOURCES += main.cpp \ FORMS = recollmain.ui \ advsearch.ui \ - preview/preview.ui \ + preview.ui \ sort.ui \ uiprefs.ui \ ssearchb.ui diff --git a/src/qtgui/recollmain.ui b/src/qtgui/recollmain.ui index d25837c5..2e3408a8 100644 --- a/src/qtgui/recollmain.ui +++ b/src/qtgui/recollmain.ui @@ -41,7 +41,7 @@ unnamed - + sSearch @@ -120,8 +120,8 @@ - SSearchBase -
ssearchb.h
+ SSearch +
ssearch_w.h
-1 -1 @@ -133,7 +133,6 @@ 0 0 - image0 startSearch(Rcl::AdvSearchData)
@@ -298,118 +297,10 @@ - - - 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082 - - - - - fileExitAction - activated() - RclMainBase - fileExit() - - - fileStart_IndexingAction - activated() - RclMainBase - fileStart_IndexingAction_activated() - - - helpAbout_RecollAction - activated() - RclMainBase - showAboutDialog() - - - userManualAction - activated() - RclMainBase - startManual() - - - toolsDoc_HistoryAction - activated() - RclMainBase - showDocHistory() - - - toolsAdvanced_SearchAction - activated() - RclMainBase - showAdvSearchDialog() - - - toolsSort_parametersAction - activated() - RclMainBase - showSortDialog() - - - preferencesQuery_PrefsAction - activated() - RclMainBase - showUIPrefs() - - - prevPageAction - activated() - resList - resultPageBack() - - - nextPageAction - activated() - resList - showResultPage() - - - resList - nextPageAvailable(bool) - RclMainBase - enableNextPage(bool) - - - resList - prevPageAvailable(bool) - RclMainBase - enablePrevPage(bool) - - - resList - docEditClicked(int) - RclMainBase - startNativeViewer(int) - - - resList - docPreviewClicked(int) - RclMainBase - startPreview(int) - - - ssearchb.h + ssearch_w.h rclreslist.h - - fileExit() - periodic100() - fileStart_IndexingAction_activated() - previewClosed( QWidget * w ) - showAdvSearchDialog() - showSortDialog() - showAboutDialog() - startManual() - showDocHistory() - showUIPrefs() - setUIPrefs() - enableNextPage(bool) - enablePrevPage(bool) - startNativeViewer(int) - startPreview(int) - diff --git a/src/qtgui/recollmain.ui.h b/src/qtgui/recollmain.ui.h index 4371d43b..1e0bb7b3 100644 --- a/src/qtgui/recollmain.ui.h +++ b/src/qtgui/recollmain.ui.h @@ -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) -{ -} diff --git a/src/qtgui/sort.ui b/src/qtgui/sort.ui index 6a737fdd..7a8da312 100644 --- a/src/qtgui/sort.ui +++ b/src/qtgui/sort.ui @@ -1,8 +1,8 @@ -SortForm +SortFormBase - SortForm + SortFormBase @@ -161,69 +161,5 @@
- - - resetPB - clicked() - SortForm - reset() - - - closePB - clicked() - SortForm - close() - - - mcntSB - valueChanged(int) - SortForm - setData() - - - fldCMB1 - activated(const QString&) - SortForm - setData() - - - fldCMB2 - activated(const QString&) - SortForm - setData() - - - descCB1 - stateChanged(int) - SortForm - setData() - - - descCB2 - stateChanged(int) - SortForm - setData() - - - sortCB - toggled(bool) - SortForm - setData() - - - - sortseq.h - sort.ui.h - - - sortDataChanged(RclSortSpec) - - - reset() - setData() - - - init() - diff --git a/src/qtgui/sort.ui.h b/src/qtgui/sort.ui.h index 95602d40..79983421 100644 --- a/src/qtgui/sort.ui.h +++ b/src/qtgui/sort.ui.h @@ -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); -} diff --git a/src/qtgui/sort_w.cpp b/src/qtgui/sort_w.cpp new file mode 100644 index 00000000..94fb132e --- /dev/null +++ b/src/qtgui/sort_w.cpp @@ -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 +#include +#include +#include + +#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); +} diff --git a/src/qtgui/sort_w.h b/src/qtgui/sort_w.h new file mode 100644 index 00000000..4293739f --- /dev/null +++ b/src/qtgui/sort_w.h @@ -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 +#include +#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_ */ diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp new file mode 100644 index 00000000..f88d383a --- /dev/null +++ b/src/qtgui/ssearch_w.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +#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 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::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 ); +} + diff --git a/src/qtgui/ssearch_w.h b/src/qtgui/ssearch_w.h new file mode 100644 index 00000000..d65b3878 --- /dev/null +++ b/src/qtgui/ssearch_w.h @@ -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 +#include +#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_ */ diff --git a/src/qtgui/ssearchb.ui b/src/qtgui/ssearchb.ui index 49eb85d0..b5b35f92 100644 --- a/src/qtgui/ssearchb.ui +++ b/src/qtgui/ssearchb.ui @@ -113,32 +113,5 @@
- - - searchPB - clicked() - SSearchBase - startSimpleSearch() - - - - recoll.h - searchdata.h - ssearchb.ui.h - - - startSearch(Rcl::AdvSearchData) - clearSearch() - - - searchTextChanged( const QString & text ) - startSimpleSearch() - - - init() - setAnyTermMode() - completion() - event( QEvent * evt ) - diff --git a/src/qtgui/ssearchb.ui.h b/src/qtgui/ssearchb.ui.h index 55ed3caa..6dbb9c2d 100644 --- a/src/qtgui/ssearchb.ui.h +++ b/src/qtgui/ssearchb.ui.h @@ -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 -#include - -#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 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::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 ); -} - diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index 8f78fb18..66e7a4a9 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -1,8 +1,8 @@ -UIPrefsDialog +UIPrefsDialogBase - uiPrefsDialog + uiPrefsDialogBase @@ -558,51 +558,5 @@ May be slow for big documents. - - - buttonOk - clicked() - uiPrefsDialog - accept() - - - buttonCancel - clicked() - uiPrefsDialog - reject() - - - buildAbsCB - toggled(bool) - replAbsCB - setEnabled(bool) - - - - uiprefs.ui.h - - - QString reslistFontFamily; - int reslistFontSize; - - - uiprefsDone() - - - accept() - showFontDialog() - resetReslistFont() - showBrowserDialog() - extraDbTextChanged( const QString & text ) - addAADbPB_clicked() - addADbPB_clicked() - delADbPB_clicked() - delAADbPB_clicked() - addExtraDbPB_clicked() - browseDbPB_clicked() - - - init() - diff --git a/src/qtgui/uiprefs.ui.h b/src/qtgui/uiprefs.ui.h index 75d3c994..6dbb9c2d 100644 --- a/src/qtgui/uiprefs.ui.h +++ b/src/qtgui/uiprefs.ui.h @@ -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 - -#include -#include -#include - -#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 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::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::iterator it = prefs.allExtraDbs.begin(); - it != prefs.allExtraDbs.end(); it++) { - ql.append(QString::fromLocal8Bit(it->c_str())); - } - allDbsLB->insertStringList(ql); - ql.clear(); - for (list::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 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::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); -} diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp new file mode 100644 index 00000000..15e4f9e9 --- /dev/null +++ b/src/qtgui/uiprefs_w.cpp @@ -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 + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 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::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::iterator it = prefs.allExtraDbs.begin(); + it != prefs.allExtraDbs.end(); it++) { + ql.append(QString::fromLocal8Bit(it->c_str())); + } + allDbsLB->insertStringList(ql); + ql.clear(); + for (list::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 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::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); +} diff --git a/src/qtgui/uiprefs_w.h b/src/qtgui/uiprefs_w.h new file mode 100644 index 00000000..28b714b5 --- /dev/null +++ b/src/qtgui/uiprefs_w.h @@ -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 +#include + +#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_ */