From 382cdc9f8a95940933bdc6fa54e4bcb2a7e437fb Mon Sep 17 00:00:00 2001 From: "\"Jean-Francois Dockes ext:(%22)" Date: Tue, 13 Mar 2012 16:33:59 +0100 Subject: [PATCH] GUI split advanced search dialog in 2 tabs and add/adjust date and size filtering --- src/qtgui/advsearch.ui | 963 +++++++++++++++++++++----------------- src/qtgui/advsearch_w.cpp | 51 +- src/qtgui/advsearch_w.h | 2 + 3 files changed, 576 insertions(+), 440 deletions(-) diff --git a/src/qtgui/advsearch.ui b/src/qtgui/advsearch.ui index f44f18f9..911b4d71 100644 --- a/src/qtgui/advsearch.ui +++ b/src/qtgui/advsearch.ui @@ -6,8 +6,8 @@ 0 0 - 545 - 537 + 544 + 441 @@ -16,446 +16,537 @@ true - + - - - - - 2 - + + + 0 + + + + Find + + - - - - 0 - 0 - - - - All non empty fields on the right will be combined with AND ("All clauses" choice) or OR ("Any clause" choice) conjunctions. <br>"Any" "All" and "None" field types can accept a mix of simple words, and phrases enclosed in double quotes.<br>Fields with no data are ignored. - - - QFrame::NoFrame - - - QFrame::Plain - - - Search for <br>documents<br>satisfying: - - - false - - - 4 - - - - - - - - 8 - 0 - - - - All non empty fields on the right will be combined with AND ("All clauses" choice) or OR ("Any clause" choice) conjunctions. <br>"Any" "All" and "None" field types can accept a mix of simple words, and phrases enclosed in double quotes.<br>Fields with no data are ignored. - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Delete clause - - - false - - - - - - - - 0 - 0 - - - - Add clause - - - false - - + + + + + 2 + + + + + + 0 + 0 + + + + All non empty fields on the right will be combined with AND ("All clauses" choice) or OR ("Any clause" choice) conjunctions. <br>"Any" "All" and "None" field types can accept a mix of simple words, and phrases enclosed in double quotes.<br>Fields with no data are ignored. + + + QFrame::NoFrame + + + QFrame::Plain + + + Search for <br>documents<br>satisfying: + + + false + + + 4 + + + + + + + + 8 + 0 + + + + All non empty fields on the right will be combined with AND ("All clauses" choice) or OR ("Any clause" choice) conjunctions. <br>"Any" "All" and "None" field types can accept a mix of simple words, and phrases enclosed in double quotes.<br>Fields with no data are ignored. + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Delete clause + + + false + + + + + + + + 0 + 0 + + + + Add clause + + + false + + + + + + + + + QFrame::StyledPanel + + + QFrame::Plain + + + + 1 + + + 0 + + + + + QFrame::HLine + + + QFrame::Plain + + + + + + + - - - - - QFrame::StyledPanel - - - QFrame::Plain - - - - 1 - - - 0 - - - - - QFrame::HLine - - - QFrame::Plain - - - - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - - - Minimum size. You can use k/K,m/M,g/G as multipliers - - - Min. Size - - - - - - - - - Maximum size. You can use k/K,m/M,g/G as multipliers - - - Max. Size - + + + Filter + + + + + + + + + + + 1 + 0 + + + + Check this to enable filtering on dates + + + Filter dates + + + + + + + From + + + + + + + false + + + + + + + To + + + + + + + false + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + + 1 + 0 + + + + Check this to enable filtering on sizes + + + Filter sizes + + + + + + + Minimum size. You can use k/K,m/M,g/G as multipliers + + + Min. Size + + + + + + + false + + + + + + + Maximum size. You can use k/K,m/M,g/G as multipliers + + + Max. Size + + + + + + + false + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + + + + 1 + 0 + + + + Check this to enable filtering on file types + + + Restrict file types + + + + + + + false + + + + 1 + 0 + + + + Check this to use file categories instead of raw mime types + + + By categories + + + + + + + false + + + Save as default + + + false + + + + + + + + + + + 0 + + + + + Searched file types + + + false + + + + + + + false + + + + 200 + 20 + + + + QAbstractItemView::ExtendedSelection + + + + + + + + + 0 + + + + + false + + + All ----> + + + false + + + + + + + false + + + Sel -----> + + + false + + + + + + + false + + + <----- Sel + + + false + + + + + + + false + + + <----- All + + + false + + + + + + + + + 0 + + + + + Ignored file types + + + false + + + + + + + false + + + + 200 + 20 + + + + QAbstractItemView::ExtendedSelection + + + + + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + + + + 8 + 0 + + + + + 300 + 0 + + + + Enter top directory for search + + + true + + + 20 + + + QComboBox::NoInsert + + + false + + + + + + + Browse + + + false + + + + + + + Restrict results to files in subtree: + + + false + + + + + + + Invert + + + + + + + + - - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - - - - 1 - 0 - - - - Check this to enable filtering on file types - - - Restrict file types - - - - - - - false - - - - 1 - 0 - - - - Check this to use file categories instead of raw mime types - - - By categories - - - - - - - false - - - Save as default - - - false - - - - - - - - - - - 0 - - - - - Searched file types - - - false - - - - - - - false - - - - 200 - 20 - - - - QAbstractItemView::ExtendedSelection - - - - - - - - - 0 - - - - - false - - - All ----> - - - false - - - - - - - false - - - Sel -----> - - - false - - - - - - - false - - - <----- Sel - - - false - - - - - - - false - - - <----- All - - - false - - - - - - - - - 0 - - - - - Ignored file types - - - false - - - - - - - false - - - - 200 - 20 - - - - QAbstractItemView::ExtendedSelection - - - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - - - - 8 - 0 - - - - - 300 - 0 - - - - Enter top directory for search - - - true - - - 20 - - - QComboBox::NoInsert - - - false - - - - - - - Browse - - - false - - - - - - - Restrict results to files in subtree: - - - false - - - - - - - Invert - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index 843ef50a..ac899591 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -62,6 +62,10 @@ void AdvSearch::init() // signals and slots connections connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked())); connect(searchPB, SIGNAL(clicked()), this, SLOT(runSearch())); + connect(filterDatesCB, SIGNAL(toggled(bool)), + this, SLOT(filterDatesCB_toggled(bool))); + connect(filterSizesCB, SIGNAL(toggled(bool)), + this, SLOT(filterSizesCB_toggled(bool))); connect(restrictFtCB, SIGNAL(toggled(bool)), this, SLOT(restrictFtCB_toggled(bool))); connect(restrictCtCB, SIGNAL(toggled(bool)), @@ -101,6 +105,14 @@ void AdvSearch::init() } (*m_clauseWins.begin())->wordsLE->setFocus(); + // Initialize min/max mtime from extrem values in the index + int minyear, maxyear; + if (rcldb) { + rcldb->maxYearSpan(&minyear, &maxyear); + minDateDTE->setDate(QDate(minyear, 1, 1)); + maxDateDTE->setDate(QDate(maxyear, 12, 31)); + } + // Initialize lists of accepted and ignored mime types from config // and settings m_ignTypes = prefs.asearchIgnFilTyps; @@ -118,6 +130,10 @@ void AdvSearch::init() // don't want to see it. clauseline->close(); + bool calpop = 0; + minDateDTE->setCalendarPopup(calpop); + maxDateDTE->setCalendarPopup(calpop); + // Translations for known categories cat_translations[QString::fromUtf8("texts")] = tr("texts"); cat_rtranslations[tr("texts")] = QString::fromUtf8("texts"); @@ -248,6 +264,19 @@ void AdvSearch::restrictFtCB_toggled(bool on) saveFileTypesPB->setEnabled(on); } +// Activate file type selection +void AdvSearch::filterSizesCB_toggled(bool on) +{ + minSizeLE->setEnabled(on); + maxSizeLE->setEnabled(on); +} +// Activate file type selection +void AdvSearch::filterDatesCB_toggled(bool on) +{ + minDateDTE->setEnabled(on); + maxDateDTE->setEnabled(on); +} + void AdvSearch::restrictCtCB_toggled(bool on) { m_ignByCats = on; @@ -367,10 +396,24 @@ void AdvSearch::runSearch() } } - size_t size = stringToSize(minSizeLE->text()); - sdata->setMinSize(size); - size = stringToSize(maxSizeLE->text()); - sdata->setMaxSize(size); + if (filterDatesCB->isChecked()) { + QDate mindate = minDateDTE->date(); + QDate maxdate = maxDateDTE->date(); + DateInterval di; + di.y1 = mindate.year(); + di.m1 = mindate.month(); + di.d1 = mindate.day(); + di.y2 = maxdate.year(); + di.m2 = maxdate.month(); + di.d2 = maxdate.day(); + sdata->setDateSpan(&di); + } + if (filterSizesCB->isChecked()) { + size_t size = stringToSize(minSizeLE->text()); + sdata->setMinSize(size); + size = stringToSize(maxSizeLE->text()); + sdata->setMaxSize(size); + } if (!subtreeCMB->currentText().isEmpty()) { QString current = subtreeCMB->currentText(); diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h index cdd51abf..bc546874 100644 --- a/src/qtgui/advsearch_w.h +++ b/src/qtgui/advsearch_w.h @@ -48,6 +48,8 @@ public slots: virtual void addFiltypPB_clicked(); virtual void addAFiltypPB_clicked(); virtual void guiListsToIgnTypes(); + virtual void filterDatesCB_toggled(bool); + virtual void filterSizesCB_toggled(bool); virtual void restrictFtCB_toggled(bool); virtual void restrictCtCB_toggled(bool); virtual void runSearch();