From df94e42e58623493bf64efd8d2acee2561a7729c Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Tue, 13 Jan 2015 20:49:49 +0000 Subject: [PATCH] Deprecate Lucene .. use a simple free text search against the ridecache now we have all the texts available and in memory .. no need to maintain an index, no dependency on a horrid lib with nasty dependencies and its faster too .. the free text search is very simple, will need to bolster it over time e.g. it matches text not words --- src/Athlete.cpp | 12 ------- src/Athlete.h | 8 ++--- src/ChartBar.cpp | 2 -- src/CriticalPowerWindow.cpp | 2 -- src/CriticalPowerWindow.h | 8 ----- src/DiaryWindow.h | 2 -- src/FreeSearch.cpp | 62 +++++++++++++++++++++++++++++++++ src/FreeSearch.h | 58 ++++++++++++++++++++++++++++++ src/GcCrashDialog.cpp | 14 +------- src/GcScopeBar.cpp | 4 --- src/HistogramWindow.cpp | 10 ------ src/HistogramWindow.h | 13 ++----- src/IntervalNavigator.cpp | 4 --- src/LTMSidebar.cpp | 27 ++------------ src/LTMSidebar.h | 2 -- src/LTMTool.cpp | 2 -- src/LTMTool.h | 4 --- src/LTMWindow.h | 6 ---- src/MainWindow.cpp | 14 +------- src/MainWindow.h | 2 -- src/PowerHist.cpp | 2 -- src/RideCache.cpp | 5 --- src/RideItem.cpp | 31 ++--------------- src/RideNavigator.cpp | 4 --- src/RideSummaryWindow.cpp | 6 ---- src/RideSummaryWindow.h | 10 ------ src/SearchFilterBox.cpp | 8 ++--- src/SearchFilterBox.h | 4 +-- src/TreeMapWindow.cpp | 2 -- src/TreeMapWindow.h | 3 +- src/{ => deprecated}/Lucene.cpp | 0 src/{ => deprecated}/Lucene.h | 0 src/gcconfig.pri.in | 7 ---- src/src.pro | 14 +++----- 34 files changed, 144 insertions(+), 208 deletions(-) create mode 100644 src/FreeSearch.cpp create mode 100644 src/FreeSearch.h rename src/{ => deprecated}/Lucene.cpp (100%) rename src/{ => deprecated}/Lucene.h (100%) diff --git a/src/Athlete.cpp b/src/Athlete.cpp index e36335e8e..382e8a180 100644 --- a/src/Athlete.cpp +++ b/src/Athlete.cpp @@ -40,10 +40,7 @@ #include "ICalendar.h" #include "CalDAV.h" #endif -#ifdef GC_HAVE_LUCENE -#include "Lucene.h" #include "NamedSearch.h" -#endif #include "IntervalItem.h" #include "IntervalTreeView.h" #include "LTMSettings.h" @@ -62,9 +59,6 @@ Athlete::Athlete(Context *context, const QDir &homeDir) this->context = context; context->athlete = this; cyclist = this->home->root().dirName(); -#ifdef GC_HAVE_LUCENE - emptyindex = false; -#endif // Recovering from a crash? if(!appsettings->cvalue(cyclist, GC_SAFEEXIT, true).toBool()) { @@ -136,10 +130,7 @@ Athlete::Athlete(Context *context, const QDir &homeDir) translateDefaultCharts(presets); // Search / filter -#ifdef GC_HAVE_LUCENE namedSearches = new NamedSearches(this); // must be before navigator - lucene = new Lucene(context, context); -#endif // Metadata rideCache = NULL; // let metadata know we don't have a ridecache yet @@ -256,10 +247,7 @@ Athlete::~Athlete() delete sqlBestIntervalsModel; #endif -#ifdef GC_HAVE_LUCENE delete namedSearches; - delete lucene; -#endif delete seasons; delete rideMetadata_; diff --git a/src/Athlete.h b/src/Athlete.h index fc8029492..92975abf4 100644 --- a/src/Athlete.h +++ b/src/Athlete.h @@ -41,7 +41,6 @@ class ICalendar; class CalDAV; class Seasons; class RideNavigator; -class Lucene; class NamedSearches; class RideFileCache; class RideItem; @@ -125,12 +124,9 @@ class Athlete : public QObject QList presets; void translateDefaultCharts(QList&charts); - // indexes / filters -#ifdef GC_HAVE_LUCENE - Lucene *lucene; + // named filters / queries NamedSearches *namedSearches; - bool emptyindex; // when startup and index is missing -#endif + Context *context; // work with withings data diff --git a/src/ChartBar.cpp b/src/ChartBar.cpp index 6e2a61b58..27461e5ce 100644 --- a/src/ChartBar.cpp +++ b/src/ChartBar.cpp @@ -297,7 +297,6 @@ ChartBar::clicked(int index) #if 0 ChartBar::setHighlighted() { -#ifdef GC_HAVE_LUCENE if (context->isfiltered) { searchLabel->setHighlighted(true); searchLabel->show(); @@ -319,7 +318,6 @@ ChartBar::setHighlighted() #endif #endif } -#endif } #endif diff --git a/src/CriticalPowerWindow.cpp b/src/CriticalPowerWindow.cpp index a2a90f0d3..97f3aa3a2 100644 --- a/src/CriticalPowerWindow.cpp +++ b/src/CriticalPowerWindow.cpp @@ -133,7 +133,6 @@ CriticalPowerWindow::CriticalPowerWindow(Context *context, bool rangemode) : setControls(settingsTabs); -#ifdef GC_HAVE_LUCENE // filter / searchbox searchBox = new SearchFilterBox(this, context); connect(searchBox, SIGNAL(searchClear()), cpPlot, SLOT(clearFilter())); @@ -144,7 +143,6 @@ CriticalPowerWindow::CriticalPowerWindow(Context *context, bool rangemode) : cl->addWidget(new QLabel("")); //spacing HelpWhatsThis *searchHelp = new HelpWhatsThis(searchBox); searchBox->setWhatsThis(searchHelp->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); -#endif // series seriesCombo = new QComboBox(this); diff --git a/src/CriticalPowerWindow.h b/src/CriticalPowerWindow.h index c4d5b6c0c..fd5801aee 100644 --- a/src/CriticalPowerWindow.h +++ b/src/CriticalPowerWindow.h @@ -25,9 +25,7 @@ #include "MainWindow.h" // for isfiltered and filters #include "Season.h" #include "RideFile.h" -#ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" -#endif #include #include @@ -48,9 +46,7 @@ class CriticalPowerWindow : public GcChartWindow // properties can be saved/restored/set by the layout manager -#ifdef GC_HAVE_LUCENE Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) -#endif Q_PROPERTY(int mode READ mode WRITE setMode USER true) Q_PROPERTY(bool showBest READ showBest WRITE setShowBest USER true) Q_PROPERTY(bool showPercent READ showPercent WRITE setShowPercent USER true) @@ -108,12 +104,10 @@ class CriticalPowerWindow : public GcChartWindow int variant() const; void setVariant(int x); -#ifdef GC_HAVE_LUCENE // filter bool isFiltered() const { return (searchBox->isFiltered() || context->ishomefiltered || context->isfiltered); } QString filter() const { return searchBox->filter(); } void setFilter(QString x) { searchBox->setFilter(x); } -#endif int ridePlotMode() const { return ridePlotStyleCombo->currentIndex(); } void setRidePlotMode(int x) { ridePlotStyleCombo->setCurrentIndex(x); } @@ -295,9 +289,7 @@ class CriticalPowerWindow : public GcChartWindow QList seasonsList; RideItem *currentRide; QList seriesList; -#ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox; -#endif QList intervalCurves; QLabel *intervalLabel, *secondsLabel; diff --git a/src/DiaryWindow.h b/src/DiaryWindow.h index 339e0441e..177efe029 100644 --- a/src/DiaryWindow.h +++ b/src/DiaryWindow.h @@ -53,9 +53,7 @@ class DiaryWindow : public GcWindow int view() const { return 0; /* viewMode->currentIndex(); */ } void setView(int /* x */ ) { /* viewMode->setCurrentIndex(x); */ } -#ifdef GC_HAVE_LUCENE bool isFiltered() const { return (context->ishomefiltered || context->isfiltered); } -#endif public slots: void rideSelected(); diff --git a/src/FreeSearch.cpp b/src/FreeSearch.cpp new file mode 100644 index 000000000..cba17f912 --- /dev/null +++ b/src/FreeSearch.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 Mark Liversedge (liversedge@gmail.com) + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "FreeSearch.h" +#include "Context.h" +#include "Athlete.h" +#include "RideItem.h" +#include "RideCache.h" + +FreeSearch::FreeSearch(QObject *parent, Context *context) : QObject(parent), context(context) +{ + // nothing to do, all the data we need is in the ridecache +} + +FreeSearch::~FreeSearch() +{ +} + +QList FreeSearch::search(QString query) +{ + filenames.clear(); + + QStringList tokens = query.split(" ", QString::SkipEmptyParts); + + foreach(RideItem*item, context->athlete->rideCache->rides()) { + + QMapIterator meta(item->metadata()); + meta.toFront(); + while (meta.hasNext()) { + meta.next(); + + // does the super string contain the tokens? + foreach(QString token, tokens) { + + if (meta.value().contains(token, Qt::CaseInsensitive)) { + filenames << item->fileName; + goto nextItem; + } + } + } + nextItem:; + } + + emit results(filenames); + + return filenames; +} diff --git a/src/FreeSearch.h b/src/FreeSearch.h new file mode 100644 index 000000000..2c880a9ec --- /dev/null +++ b/src/FreeSearch.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 Mark Liversedge (liversedge@gmail.com) + * + * 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., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _GC_FreeSearch_h +#define _GC_FreeSearch_h + +#include +#include +#include +#include + +#include "Context.h" +#include "RideMetadata.h" +#include "RideCache.h" +#include "RideItem.h" + +class FreeSearch : public QObject +{ + Q_OBJECT + +public: + FreeSearch(QObject *parent, Context *context); + ~FreeSearch(); + +protected: + +public slots: + + // search metadata texts in ridecache + QList search(QString query); + +signals: + void results(QStringList); + +private: + Context *context; + QDir dir; + + // Query results + QStringList filenames; +}; + +#endif diff --git a/src/GcCrashDialog.cpp b/src/GcCrashDialog.cpp index 724df8a79..709fc723b 100644 --- a/src/GcCrashDialog.cpp +++ b/src/GcCrashDialog.cpp @@ -55,10 +55,6 @@ #include "kqoauthmanager.h" #endif -#ifdef GC_HAVE_LUCENE -#include "Lucene.h" -#endif - #ifdef GC_HAVE_WFAPI #include "WFApi.h" #endif @@ -244,12 +240,6 @@ QString GcCrashDialog::versionHTML() vlc = "yes"; #endif - // -- LUCENE ---- - QString clucene = "none"; - #ifdef GC_HAVE_LUCENE - clucene = _CL_VERSION; - #endif - #ifdef GC_HAVE_WFAPI QString wfapi = WFApi::getInstance()->apiVersion(); #else @@ -292,8 +282,7 @@ QString GcCrashDialog::versionHTML() "LIBUSB%11" "Wahoo API%12" "VLC%13" - "LUCENE%14" - "VIDEO%15" + "VIDEO%14" "" ) .arg(QT_VERSION_STR) @@ -309,7 +298,6 @@ QString GcCrashDialog::versionHTML() .arg(libusb) .arg(wfapi) .arg(vlc) - .arg(clucene) #ifdef GC_VIDEO_NONE .arg("none") #elif defined GC_VIDEO_QUICKTIME diff --git a/src/GcScopeBar.cpp b/src/GcScopeBar.cpp index 92bb10974..74f38dbf7 100644 --- a/src/GcScopeBar.cpp +++ b/src/GcScopeBar.cpp @@ -44,9 +44,7 @@ GcScopeBar::GcScopeBar(Context *context) : QWidget(context->mainWindow), context layout->addWidget(searchLabel); searchLabel->hide(); -#ifdef GC_HAVE_LUCENE connect(context, SIGNAL(filterChanged()), this, SLOT(setHighlighted())); -#endif connect(context, SIGNAL(compareIntervalsStateChanged(bool)), this, SLOT(setCompare())); connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(setCompare())); @@ -146,7 +144,6 @@ GcScopeBar::GcScopeBar(Context *context) : QWidget(context->mainWindow), context void GcScopeBar::setHighlighted() { -#ifdef GC_HAVE_LUCENE if (context->isfiltered) { searchLabel->setHighlighted(true); searchLabel->show(); @@ -168,7 +165,6 @@ GcScopeBar::setHighlighted() #endif #endif } -#endif } void diff --git a/src/HistogramWindow.cpp b/src/HistogramWindow.cpp index 4b14d6664..222f9c02e 100644 --- a/src/HistogramWindow.cpp +++ b/src/HistogramWindow.cpp @@ -99,7 +99,6 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind setChartLayout(vlayout); -#ifdef GC_HAVE_LUCENE // search filter box isfiltered = false; searchBox = new SearchFilterBox(this, context); @@ -112,7 +111,6 @@ HistogramWindow::HistogramWindow(Context *context, bool rangemode) : GcChartWind } HelpWhatsThis *searchHelp = new HelpWhatsThis(searchBox); searchBox->setWhatsThis(searchHelp->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); -#endif // date selection dateSetting = new DateSettingsEdit(this); @@ -977,11 +975,7 @@ HistogramWindow::updateChart() // plotting a data series, so refresh the ridefilecache -#ifdef GC_HAVE_LUCENE source = new RideFileCache(context, use.from, use.to, isfiltered, files, rangemode); -#else - source = new RideFileCache(context, use.from, use.to); -#endif cfrom = use.from; cto = use.to; stale = false; @@ -1013,11 +1007,9 @@ HistogramWindow::updateChart() } FilterSet fs; -#ifdef GC_HAVE_LUCENE fs.addFilter(isfiltered, files); fs.addFilter(context->isfiltered, context->filters); fs.addFilter(context->ishomefiltered, context->homeFilters); -#endif // setData using the summary metrics -- always reset since filters may // have changed, or perhaps the bin width... @@ -1060,7 +1052,6 @@ HistogramWindow::updateChart() } // if stale } -#ifdef GC_HAVE_LUCENE void HistogramWindow::clearFilter() { @@ -1080,7 +1071,6 @@ HistogramWindow::setFilter(QStringList list) updateChart(); repaint(); } -#endif double HistogramWindow::getDelta() diff --git a/src/HistogramWindow.h b/src/HistogramWindow.h index 1c42f4cdb..936197562 100644 --- a/src/HistogramWindow.h +++ b/src/HistogramWindow.h @@ -38,9 +38,7 @@ #include "Season.h" #include "SeasonParser.h" -#ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" -#endif #include #include @@ -68,9 +66,7 @@ class HistogramWindow : public GcChartWindow Q_PROPERTY(bool shade READ shade WRITE setShade USER true) Q_PROPERTY(bool zoned READ zoned WRITE setZoned USER true) Q_PROPERTY(bool cpZoned READ cpZoned WRITE setCPZoned USER true) -#ifdef GC_HAVE_LUCENE Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) -#endif Q_PROPERTY(QDate fromDate READ fromDate WRITE setFromDate USER true) Q_PROPERTY(QDate toDate READ toDate WRITE setToDate USER true) Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate USER true) @@ -108,12 +104,11 @@ class HistogramWindow : public GcChartWindow void setCPZoned(bool x) { return showInCPZones->setChecked(x); } bool zoned() const { return showInZones->isChecked(); } void setZoned(bool x) { return showInZones->setChecked(x); } -#ifdef GC_HAVE_LUCENE bool isFiltered() const { if (rangemode) return (isfiltered || context->ishomefiltered || context->isfiltered); else return false; } QString filter() const { return searchBox->filter(); } void setFilter(QString x) { searchBox->setFilter(x); } -#endif + // properties int useSelected() { return dateSetting->mode(); } void setUseSelected(int x) { dateSetting->setMode(x); } @@ -155,10 +150,9 @@ class HistogramWindow : public GcChartWindow void rideAddorRemove(RideItem*); void intervalSelected(); void zonesChanged(); -#ifdef GC_HAVE_LUCENE void clearFilter(); void setFilter(QStringList files); -#endif + // date settings void useCustomRange(DateRange); void useStandardRange(); @@ -224,11 +218,10 @@ class HistogramWindow : public GcChartWindow QDate cfrom, cto; RideFileCache *source; bool interval; -#ifdef GC_HAVE_LUCENE + SearchFilterBox *searchBox; bool isfiltered; QStringList files; -#endif bool active, // active switching mode between data series and metric bactive; // active setting binwidth diff --git a/src/IntervalNavigator.cpp b/src/IntervalNavigator.cpp index 3d85d6895..ea39124f6 100644 --- a/src/IntervalNavigator.cpp +++ b/src/IntervalNavigator.cpp @@ -80,14 +80,12 @@ IntervalNavigator::IntervalNavigator(Context *context, QString type, bool mainwi sortModel->setSourceModel(groupByModel); sortModel->setDynamicSortFilter(true); -#ifdef GC_HAVE_LUCENE if (!mainwindow) { searchFilterBox = new SearchFilterBox(this, context, false); mainLayout->addWidget(searchFilterBox); HelpWhatsThis *searchHelp = new HelpWhatsThis(searchFilterBox); searchFilterBox->setWhatsThis(searchHelp->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); } -#endif // get setup tableView = new IntervalGlobalTreeView; @@ -145,12 +143,10 @@ IntervalNavigator::IntervalNavigator(Context *context, QString type, bool mainwi //connect(tableView,SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTreeContextMenuPopup(const QPoint &))); connect(tableView->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(setSortBy(int,Qt::SortOrder))); -#ifdef GC_HAVE_LUCENE if (!mainwindow) { connect(searchFilterBox, SIGNAL(searchResults(QStringList)), this, SLOT(searchStrings(QStringList))); connect(searchFilterBox, SIGNAL(searchClear()), this, SLOT(clearSearch())); } -#endif // we accept drag and drop operations setAcceptDrops(true); diff --git a/src/LTMSidebar.cpp b/src/LTMSidebar.cpp index dd65a3ac9..ef61b8ebb 100644 --- a/src/LTMSidebar.cpp +++ b/src/LTMSidebar.cpp @@ -42,11 +42,9 @@ #include // named searchs +#include "FreeSearch.h" #include "NamedSearch.h" #include "DataFilter.h" -#ifdef GC_HAVE_LUCENE -#include "Lucene.h" -#endif // ride cache #include "RideCache.h" @@ -163,7 +161,6 @@ LTMSidebar::LTMSidebar(Context *context) : QWidget(context->mainWindow), context presetsChanged(); // filters -#ifdef GC_HAVE_LUCENE filtersWidget = new GcSplitterItem(tr("Filters"), iconFromPNG(":images/toolbar/filter3.png"), this); QAction *moreFilterAct = new QAction(iconFromPNG(":images/sidebar/extra.png"), tr("Menu"), this); filtersWidget->addAction(moreFilterAct); @@ -199,8 +196,6 @@ LTMSidebar::LTMSidebar(Context *context) : QWidget(context->mainWindow), context HelpWhatsThis *helpFilterTree = new HelpWhatsThis(filterTree); filterTree->setWhatsThis(helpFilterTree->getWhatsThisText(HelpWhatsThis::SideBarTrendsView_Filter)); -#endif - seasons = context->athlete->seasons; resetSeasons(); // reset the season list resetFilters(); // reset the filters list @@ -211,9 +206,7 @@ LTMSidebar::LTMSidebar(Context *context) : QWidget(context->mainWindow), context splitter = new GcSplitter(Qt::Vertical); splitter->addWidget(seasonsWidget); // goes alongside events splitter->addWidget(eventsWidget); // goes alongside date ranges -#ifdef GC_HAVE_LUCENE splitter->addWidget(filtersWidget); -#endif splitter->addWidget(chartsWidget); // for charts that 'use sidebar chart' charts ! (confusing or what?!) GcSplitterItem *summaryWidget = new GcSplitterItem(tr("Summary"), iconFromPNG(":images/sidebar/dashboard.png"), this); @@ -244,9 +237,7 @@ LTMSidebar::LTMSidebar(Context *context) : QWidget(context->mainWindow), context connect(dateRangeTree,SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(dateRangePopup(const QPoint &))); connect(dateRangeTree,SIGNAL(itemChanged(QTreeWidgetItem *,int)), this, SLOT(dateRangeChanged(QTreeWidgetItem*, int))); connect(dateRangeTree,SIGNAL(itemMoved(QTreeWidgetItem *,int, int)), this, SLOT(dateRangeMoved(QTreeWidgetItem*, int, int))); -#ifdef GC_HAVE_LUCENE connect(filterTree,SIGNAL(itemSelectionChanged()), this, SLOT(filterTreeWidgetSelectionChanged())); -#endif connect(eventTree,SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(eventPopup(const QPoint &))); // GC signal @@ -295,9 +286,7 @@ LTMSidebar::configChanged(qint32) seasonsWidget->setStyleSheet(GCColor::stylesheet()); eventsWidget->setStyleSheet(GCColor::stylesheet()); chartsWidget->setStyleSheet(GCColor::stylesheet()); -#ifdef GC_HAVE_LUCENE filtersWidget->setStyleSheet(GCColor::stylesheet()); -#endif setAutoFilterMenu(); // set or reset the autofilter widgets @@ -564,17 +553,14 @@ LTMSidebar::eventPopup() void LTMSidebar::manageFilters() { -#ifdef GC_HAVE_LUCENE EditNamedSearches *editor = new EditNamedSearches(this, context); editor->move(QCursor::pos()+QPoint(10,-200)); editor->show(); -#endif } void LTMSidebar::setAutoFilterMenu() { -#ifdef GC_HAVE_LUCENE active = true; QStringList on = appsettings->cvalue(context->athlete->cyclist, GC_LTM_AUTOFILTERS, tr("Workout Code|Sport")).toString().split("|"); @@ -606,7 +592,6 @@ LTMSidebar::setAutoFilterMenu() } } active = false; -#endif } void @@ -705,7 +690,6 @@ LTMSidebar::autoFilterChanged() void LTMSidebar::filterTreeWidgetSelectionChanged() { -#ifdef GC_HAVE_LUCENE int selected = filterTree->selectedItems().count(); if (selected) { @@ -733,7 +717,7 @@ LTMSidebar::filterTreeWidgetSelectionChanged() case NamedSearch::search : { // use clucence - Lucene s(this, context); + FreeSearch s(this, context); results = s.search(ns.text); } @@ -763,7 +747,6 @@ LTMSidebar::filterTreeWidgetSelectionChanged() // tell the world filterNotify(); -#endif } void @@ -890,7 +873,6 @@ LTMSidebar::autoFilterSelectionChanged() void LTMSidebar::resetFilters() { -#ifdef GC_HAVE_LUCENE if (active == true) return; active = true; @@ -909,13 +891,11 @@ LTMSidebar::resetFilters() } active = false; -#endif } void LTMSidebar::filterPopup() { -#ifdef GC_HAVE_LUCENE // is one selected for deletion? int selected = filterTree->selectedItems().count(); @@ -940,13 +920,11 @@ LTMSidebar::filterPopup() // execute the menu menu.exec(splitter->mapToGlobal(QPoint(filtersWidget->pos().x()+filtersWidget->width()-20, filtersWidget->pos().y()))); -#endif } void LTMSidebar::deleteFilter() { -#ifdef GC_HAVE_LUCENE if (filterTree->selectedItems().count() <= 0) return; active = true; // no need to reset tree when items deleted from model! @@ -958,7 +936,6 @@ LTMSidebar::deleteFilter() context->athlete->namedSearches->deleteNamedSearch(index); } active = false; -#endif } void diff --git a/src/LTMSidebar.h b/src/LTMSidebar.h index 61b8ce0fd..2f2f1e148 100644 --- a/src/LTMSidebar.h +++ b/src/LTMSidebar.h @@ -29,9 +29,7 @@ #include "RideMetric.h" #include "LTMSettings.h" -#ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" -#endif #include #include diff --git a/src/LTMTool.cpp b/src/LTMTool.cpp index 8b3c87fe8..94fbcad57 100644 --- a/src/LTMTool.cpp +++ b/src/LTMTool.cpp @@ -62,7 +62,6 @@ LTMTool::LTMTool(Context *context, LTMSettings *settings) : QWidget(context->mai QFormLayout *basicsettingsLayout = new QFormLayout(basicsettings); basicsettingsLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); -#ifdef GC_HAVE_LUCENE searchBox = new SearchFilterBox(this, context); HelpWhatsThis *searchHelp = new HelpWhatsThis(searchBox); searchBox->setWhatsThis(searchHelp->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); @@ -71,7 +70,6 @@ LTMTool::LTMTool(Context *context, LTMSettings *settings) : QWidget(context->mai basicsettingsLayout->addRow(new QLabel(tr("Filter")), searchBox); basicsettingsLayout->addRow(new QLabel(tr(""))); // spacing -#endif // Basic Controls QWidget *basic = new QWidget(this); diff --git a/src/LTMTool.h b/src/LTMTool.h index 396822927..b1acfd1a4 100644 --- a/src/LTMTool.h +++ b/src/LTMTool.h @@ -26,9 +26,7 @@ #include "LTMSettings.h" #include "PDModel.h" -#ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" -#endif #include #include @@ -75,9 +73,7 @@ class LTMTool : public QWidget LTMSettings *settings; -#ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox; -#endif // basic tab: accessed by LTMWindow hence public QComboBox *groupBy; diff --git a/src/LTMWindow.h b/src/LTMWindow.h index 60383dd7b..25a5c794c 100644 --- a/src/LTMWindow.h +++ b/src/LTMWindow.h @@ -104,9 +104,7 @@ class LTMWindow : public GcChartWindow Q_PROPERTY(int stackWidth READ stackW WRITE setStackW USER true) Q_PROPERTY(bool legend READ legend WRITE setLegend USER true) Q_PROPERTY(bool events READ events WRITE setEvents USER true) -#ifdef GC_HAVE_LUCENE Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) -#endif Q_PROPERTY(QDate fromDate READ fromDate WRITE setFromDate USER true) Q_PROPERTY(QDate toDate READ toDate WRITE setToDate USER true) Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate USER true) @@ -123,9 +121,7 @@ class LTMWindow : public GcChartWindow // reveal / filters bool hasReveal() { return true; } -#ifdef GC_HAVE_LUCENE bool isFiltered() const { return (ltmTool->isFiltered() || context->ishomefiltered || context->isfiltered); } -#endif // comparing things bool isCompare() const { return context->isCompareDateRanges; } @@ -170,10 +166,8 @@ class LTMWindow : public GcChartWindow int prevN() { return ltmTool->dateSetting->prevN(); } void setPrevN(int x) { ltmTool->dateSetting->setPrevN(x); } -#ifdef GC_HAVE_LUCENE QString filter() const { return ltmTool->searchBox->filter(); } void setFilter(QString x) { ltmTool->searchBox->setFilter(x); } -#endif LTMSettings getSettings() const { return settings; } void applySettings(LTMSettings x) { diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 087095faa..255311a90 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -91,11 +91,8 @@ #endif // SEARCH / FILTER -#ifdef GC_HAVE_LUCENE -#include "Lucene.h" #include "NamedSearch.h" #include "SearchFilterBox.h" -#endif #ifdef GC_HAVE_WFAPI #include "WFApi.h" @@ -350,7 +347,6 @@ MainWindow::MainWindow(const QDir &home) head->addWidget(new Spacer(this)); head->addWidget(viewsel); -#ifdef GC_HAVE_LUCENE searchBox = new SearchFilterBox(this,context,false); #if QT_VERSION > 0x50000 QStyle *toolStyle = QStyleFactory::create("fusion"); @@ -362,7 +358,6 @@ MainWindow::MainWindow(const QDir &home) head->addWidget(searchBox); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); -#endif #endif @@ -480,7 +475,6 @@ MainWindow::MainWindow(const QDir &home) head->addWidget(lowbar); head->addWidget(styleSelector); -#ifdef GC_HAVE_LUCENE // add a search box on far right, but with a little space too searchBox = new SearchFilterBox(this,context,false); searchBox->setStyle(toolStyle); @@ -490,7 +484,7 @@ MainWindow::MainWindow(const QDir &home) connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); HelpWhatsThis *helpSearchBox = new HelpWhatsThis(searchBox); searchBox->setWhatsThis(helpSearchBox->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); -#endif + Spacer *spacer = new Spacer(this); spacer->setFixedWidth(5); head->addWidget(spacer); @@ -1552,10 +1546,8 @@ MainWindow::removeTab(Tab *tab) if (tabList.count() == 2) showTabbar(false); // don't need it for one! -#ifdef GC_HAVE_LUCENE // save the named searches tab->context->athlete->namedSearches->write(); -#endif // clear the clipboard if neccessary QApplication::clipboard()->setText(""); @@ -1690,9 +1682,7 @@ MainWindow::saveGCState(Context *context) #ifndef Q_OS_MAC // not on a Mac context->showToolbar = showhideToolbar->isChecked(); #endif -#ifdef GC_HAVE_LUCENE context->searchText = searchBox->text(); -#endif context->viewIndex = scopebar->selected(); context->style = styleAction->isChecked(); context->viewIndex = scopebar->selected(); @@ -1711,10 +1701,8 @@ MainWindow::restoreGCState(Context *context) scopebar->setSelected(context->viewIndex); scopebar->setContext(context); scopebar->setHighlighted(); // to reflect context -#ifdef GC_HAVE_LUCENE searchBox->setContext(context); searchBox->setText(context->searchText); -#endif } void diff --git a/src/MainWindow.h b/src/MainWindow.h index 8d59f5bcc..25a0126bb 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -208,9 +208,7 @@ class MainWindow : public QMainWindow QTFullScreen *fullScreen; #endif -#ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox; -#endif #ifdef Q_OS_MAC // Mac Native Support diff --git a/src/PowerHist.cpp b/src/PowerHist.cpp index ac4273dc8..cf42346e4 100644 --- a/src/PowerHist.cpp +++ b/src/PowerHist.cpp @@ -1563,10 +1563,8 @@ PowerHist::setDataFromCompare(QString totalMetric, QString distMetric) // set the specification FilterSet fs; -#ifdef GC_HAVE_LUCENE fs.addFilter(context->isfiltered, context->filters); fs.addFilter(context->ishomefiltered, context->homeFilters); -#endif Specification spec; spec.setDateRange(DateRange(cd.start,cd.end)); spec.setFilterSet(fs); diff --git a/src/RideCache.cpp b/src/RideCache.cpp index 100a1deba..eb1092d5e 100644 --- a/src/RideCache.cpp +++ b/src/RideCache.cpp @@ -391,11 +391,6 @@ RideCache::refresh() staleCount++; } - // reset emptyindex, we will have spotted that now -#ifdef GC_HAVE_LUCENE - context->athlete->emptyindex= false; -#endif - // start if there is work to do // and future watcher can notify of updates if (staleCount) { diff --git a/src/RideItem.cpp b/src/RideItem.cpp index 908faf4dd..3c20f6bc4 100644 --- a/src/RideItem.cpp +++ b/src/RideItem.cpp @@ -34,10 +34,6 @@ #include #include -#ifdef GC_HAVE_LUCENE -#include "Lucene.h" -#endif - // used to create a temporary ride item that is not in the cache and just // used to enable using the same calling semantics in things like the // merge wizard and interval navigator @@ -368,20 +364,7 @@ RideItem::checkStale() // still reckon its clean? what about the cache ? if (isstale == false) isstale = RideFileCache::checkStale(context, this); -#ifdef GC_HAVE_LUCENE - // lucene metadata value ? - if (isstale == false) { - - if (context->athlete->emptyindex == true) { - metacrc = 0; // reset as index missing - isstale = true; - } - } -#endif - - // we need to mark stale for 2 reasons - // 1) lucene index needs updating - // 2) "special" fields may have changed (e.g. CP) + // we need to mark stale in case "special" fields may have changed (e.g. CP) if (metacrc != metaCRC()) isstale = true; return isstale; @@ -449,16 +432,8 @@ RideItem::refresh() // RideFile cache needs refreshing possibly RideFileCache updater(context, context->athlete->home->activities().canonicalPath() + "/" + fileName, ride_, true); - // and Lucene search texts if they have changed since we - // last updated lucene for this ride item - unsigned long mc = metaCRC(); - if (metacrc != mc) { -#ifdef GC_HAVE_LUCENE - context->athlete->lucene->deleteRide(fileName); - context->athlete->lucene->importRide(ride_); -#endif - metacrc = mc; - } + // we now match + metacrc = metaCRC(); // close if we opened it if (doclose) { diff --git a/src/RideNavigator.cpp b/src/RideNavigator.cpp index 361198ea2..ecc55ee88 100644 --- a/src/RideNavigator.cpp +++ b/src/RideNavigator.cpp @@ -68,14 +68,12 @@ RideNavigator::RideNavigator(Context *context, bool mainwindow) : context(contex sortModel->setSourceModel(groupByModel); sortModel->setDynamicSortFilter(true); -#ifdef GC_HAVE_LUCENE if (!mainwindow) { searchFilterBox = new SearchFilterBox(this, context, false); mainLayout->addWidget(searchFilterBox); HelpWhatsThis *searchHelp = new HelpWhatsThis(searchFilterBox); searchFilterBox->setWhatsThis(searchHelp->getWhatsThisText(HelpWhatsThis::SearchFilterBox)); } -#endif // get setup tableView = new RideTreeView; @@ -145,12 +143,10 @@ RideNavigator::RideNavigator(Context *context, bool mainwindow) : context(contex connect(context, SIGNAL(refreshEnd()), this, SLOT(backgroundRefresh())); connect(context, SIGNAL(refreshUpdate(QDate)), this, SLOT(backgroundRefresh())); // we might miss 1st one -#ifdef GC_HAVE_LUCENE if (!mainwindow) { connect(searchFilterBox, SIGNAL(searchResults(QStringList)), this, SLOT(searchStrings(QStringList))); connect(searchFilterBox, SIGNAL(searchClear()), this, SLOT(clearSearch())); } -#endif // we accept drag and drop operations setAcceptDrops(true); diff --git a/src/RideSummaryWindow.cpp b/src/RideSummaryWindow.cpp index 2b7105b75..917b5192d 100644 --- a/src/RideSummaryWindow.cpp +++ b/src/RideSummaryWindow.cpp @@ -68,7 +68,6 @@ RideSummaryWindow::RideSummaryWindow(Context *context, bool ridesummary) : cl->setSpacing(0); setControls(c); -#ifdef GC_HAVE_LUCENE // filter / searchbox searchBox = new SearchFilterBox(this, context); HelpWhatsThis *searchHelp = new HelpWhatsThis(searchBox); @@ -77,7 +76,6 @@ RideSummaryWindow::RideSummaryWindow(Context *context, bool ridesummary) : connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); cl->addRow(new QLabel(tr("Filter")), searchBox); cl->addWidget(new QLabel("")); //spacing -#endif cl->addRow(new QLabel(tr("Date range")), dateSetting); } @@ -160,7 +158,6 @@ RideSummaryWindow::configChanged(qint32) force = false; } -#ifdef GC_HAVE_LUCENE void RideSummaryWindow::clearFilter() { @@ -176,7 +173,6 @@ RideSummaryWindow::setFilter(QStringList list) filtered = true; refresh(); } -#endif void RideSummaryWindow::modelProgress(int year, int month) @@ -351,11 +347,9 @@ RideSummaryWindow::refresh() } FilterSet fs; -#ifdef GC_HAVE_LUCENE fs.addFilter(filtered, filters); fs.addFilter(context->isfiltered, context->filters); fs.addFilter(context->ishomefiltered, context->homeFilters); -#endif specification.setFilterSet(fs); } rideSummary->page()->mainFrame()->setHtml(htmlSummary()); diff --git a/src/RideSummaryWindow.h b/src/RideSummaryWindow.h index 3b698ec45..2eba20ee9 100644 --- a/src/RideSummaryWindow.h +++ b/src/RideSummaryWindow.h @@ -33,9 +33,7 @@ #include "RideFileCache.h" #include "ExtendedCriticalPower.h" -#ifdef GC_HAVE_LUCENE #include "SearchFilterBox.h" -#endif #include "Specification.h" @@ -44,9 +42,7 @@ class RideSummaryWindow : public GcChartWindow Q_OBJECT G_OBJECT -#ifdef GC_HAVE_LUCENE Q_PROPERTY(QString filter READ filter WRITE setFilter USER true) -#endif Q_PROPERTY(QDate fromDate READ fromDate WRITE setFromDate USER true) Q_PROPERTY(QDate toDate READ toDate WRITE setToDate USER true) Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate USER true) @@ -76,13 +72,11 @@ class RideSummaryWindow : public GcChartWindow void setLastNX(int x) { dateSetting->setLastNX(x); } int prevN() { return dateSetting->prevN(); } void setPrevN(int x) { dateSetting->setPrevN(x); } -#ifdef GC_HAVE_LUCENE bool isFiltered() const { if (!ridesummary) return (filtered || context->ishomefiltered || context->isfiltered); else return false; } // filter QString filter() const { return ridesummary ? "" : searchBox->filter(); } void setFilter(QString x) { if (!ridesummary) searchBox->setFilter(x); } -#endif bool isCompare() const { return ((ridesummary && context->isCompareIntervals) || (!ridesummary && context->isCompareDateRanges)); } @@ -103,10 +97,8 @@ class RideSummaryWindow : public GcChartWindow void useStandardRange(); void useThruToday(); -#ifdef GC_HAVE_LUCENE void clearFilter(); void setFilter(QStringList); -#endif // compare mode started or items to compare changed void compareChanged(); @@ -139,9 +131,7 @@ class RideSummaryWindow : public GcChartWindow bool useCustom; bool useToToday; DateRange custom; -#ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox; -#endif QStringList filters; // empty when no lucene bool filtered; // are we using a filter? diff --git a/src/SearchFilterBox.cpp b/src/SearchFilterBox.cpp index 5bb389892..f2dcae1b7 100644 --- a/src/SearchFilterBox.cpp +++ b/src/SearchFilterBox.cpp @@ -18,7 +18,7 @@ #include "SearchFilterBox.h" #include "Context.h" -#include "Lucene.h" +#include "FreeSearch.h" #include "DataFilter.h" #include "SearchBox.h" @@ -34,12 +34,12 @@ SearchFilterBox::SearchFilterBox(QWidget *parent, Context *context, bool nochoos searchbox = new SearchBox(context, this, nochooser); contents->addWidget(searchbox); - lucene = new Lucene(this, context); + freeSearch = new FreeSearch(this, context); datafilter = new DataFilter(this,context); // text searching - connect(searchbox, SIGNAL(submitQuery(QString)), lucene, SLOT(search(QString))); - connect(lucene, SIGNAL(results(QStringList)), this, SIGNAL(searchResults(QStringList))); + connect(searchbox, SIGNAL(submitQuery(QString)), freeSearch, SLOT(search(QString))); + connect(freeSearch, SIGNAL(results(QStringList)), this, SIGNAL(searchResults(QStringList))); connect(searchbox, SIGNAL(clearQuery()), this, SIGNAL(searchClear())); // data filtering diff --git a/src/SearchFilterBox.h b/src/SearchFilterBox.h index cc56b9be2..66422413a 100644 --- a/src/SearchFilterBox.h +++ b/src/SearchFilterBox.h @@ -22,7 +22,7 @@ #include "Context.h" #include "SearchBox.h" // for searchboxmode -class Lucene; +class FreeSearch; class DataFilter; class SearchFilterBox : public QWidget @@ -50,7 +50,7 @@ signals: private: Context *context; - Lucene *lucene; + FreeSearch *freeSearch; DataFilter *datafilter; SearchBox *searchbox; }; diff --git a/src/TreeMapWindow.cpp b/src/TreeMapWindow.cpp index 0f8491104..7963aab95 100644 --- a/src/TreeMapWindow.cpp +++ b/src/TreeMapWindow.cpp @@ -235,10 +235,8 @@ TreeMapWindow::refresh() // set the specification FilterSet fs; -#ifdef GC_HAVE_LUCENE fs.addFilter(context->isfiltered, context->filters); fs.addFilter(context->ishomefiltered, context->homeFilters); -#endif settings.specification.setFilterSet(fs); settings.specification.setDateRange(dr); diff --git a/src/TreeMapWindow.h b/src/TreeMapWindow.h index 68346531c..721f50ec7 100644 --- a/src/TreeMapWindow.h +++ b/src/TreeMapWindow.h @@ -66,9 +66,8 @@ class TreeMapWindow : public GcWindow TreeMapWindow(Context *); ~TreeMapWindow(); -#ifdef GC_HAVE_LUCENE bool isFiltered() const { return context->ishomefiltered || context->isfiltered; } -#endif + QString f1 () { // consider translation on Screen, but Store only in EN if (field1->currentIndex() == 0) { diff --git a/src/Lucene.cpp b/src/deprecated/Lucene.cpp similarity index 100% rename from src/Lucene.cpp rename to src/deprecated/Lucene.cpp diff --git a/src/Lucene.h b/src/deprecated/Lucene.h similarity index 100% rename from src/Lucene.h rename to src/deprecated/Lucene.h diff --git a/src/gcconfig.pri.in b/src/gcconfig.pri.in index 1346659cd..1845fb9fe 100644 --- a/src/gcconfig.pri.in +++ b/src/gcconfig.pri.in @@ -177,13 +177,6 @@ #VLC_INCLUDE = #VLC_LIBS = -#If you want search functionality then uncomment the following -#two lines once you habve installed clucene developer libraries -#and runtimes. See the INSTALL guide for your platform. -#CLUCENE_INCLUDE = /usr/include/CLucene -#CLUCENE_LIBS = -lclucene-core - - # *** Mac users NOTE *** # On MAC you don't need libvlc since we use the # native QTKit (OSX framework) for video playback diff --git a/src/src.pro b/src/src.pro index cf6bba8bd..019b53734 100644 --- a/src/src.pro +++ b/src/src.pro @@ -153,15 +153,11 @@ CONFIG(debug, debug|release) { } } -!isEmpty( CLUCENE_LIBS ) { - INCLUDEPATH += $${CLUCENE_INCLUDE} - LIBS += $${CLUCENE_LIBS} - DEFINES += GC_HAVE_LUCENE - HEADERS += Lucene.h DataFilter.h SearchBox.h NamedSearch.h SearchFilterBox.h - SOURCES += Lucene.cpp DataFilter.cpp SearchBox.cpp NamedSearch.cpp SearchFilterBox.cpp - YACCSOURCES += DataFilter.y - LEXSOURCES += DataFilter.l -} +# FreeSearch replaces deprecated lucene +HEADERS += DataFilter.h SearchBox.h NamedSearch.h SearchFilterBox.h FreeSearch.h +SOURCES += DataFilter.cpp SearchBox.cpp NamedSearch.cpp SearchFilterBox.cpp FreeSearch.cpp +YACCSOURCES += DataFilter.y +LEXSOURCES += DataFilter.l # Mac specific build for # Segmented mac style button