parent
c5631d7a2d
commit
84bf4caa68
@ -1,2 +1,3 @@
|
|||||||
fix-metadata-for-trusting-executables.patch
|
fix-metadata-for-trusting-executables.patch
|
||||||
fix-uri-scheme-crash.patch
|
fix-uri-scheme-crash.patch
|
||||||
|
support-adding-pattern-lists.patch
|
||||||
|
@ -0,0 +1,124 @@
|
|||||||
|
From f66aa205c48a60378abcf0dac3d21b83d47aa2c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: tsujan <tsujan2000@gmail.com>
|
||||||
|
Date: Sat, 14 May 2022 01:17:14 +0430
|
||||||
|
Subject: [PATCH] Support adding of pattern lists to entries of search dialog
|
||||||
|
(#806)
|
||||||
|
|
||||||
|
Such lists will be used later for adding search history to `pcmanfm-qt`.
|
||||||
|
---
|
||||||
|
src/filesearch.ui | 13 ++++++++++---
|
||||||
|
src/filesearchdialog.cpp | 28 ++++++++++++++++++++++++++--
|
||||||
|
src/filesearchdialog.h | 6 ++++++
|
||||||
|
3 files changed, 42 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/filesearch.ui b/src/filesearch.ui
|
||||||
|
index 85e57556..a90456a5 100644
|
||||||
|
--- a/src/filesearch.ui
|
||||||
|
+++ b/src/filesearch.ui
|
||||||
|
@@ -36,8 +36,11 @@
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
- <widget class="QLineEdit" name="namePatterns">
|
||||||
|
- <property name="text">
|
||||||
|
+ <widget class="QComboBox" name="namePatterns">
|
||||||
|
+ <property name="editable">
|
||||||
|
+ <bool>true</bool>
|
||||||
|
+ </property>
|
||||||
|
+ <property name="currentText">
|
||||||
|
<string>*</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
@@ -218,7 +221,11 @@
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<item>
|
||||||
|
- <widget class="QLineEdit" name="contentPattern"/>
|
||||||
|
+ <widget class="QComboBox" name="contentPattern">
|
||||||
|
+ <property name="editable">
|
||||||
|
+ <bool>true</bool>
|
||||||
|
+ </property>
|
||||||
|
+ </widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="contentCaseSensitive">
|
||||||
|
diff --git a/src/filesearchdialog.cpp b/src/filesearchdialog.cpp
|
||||||
|
index 0216687f..267cc4c7 100644
|
||||||
|
--- a/src/filesearchdialog.cpp
|
||||||
|
+++ b/src/filesearchdialog.cpp
|
||||||
|
@@ -23,6 +23,7 @@
|
||||||
|
#include "ui_filesearch.h"
|
||||||
|
#include <limits>
|
||||||
|
#include <QFileDialog>
|
||||||
|
+#include <QCompleter>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace Fm {
|
||||||
|
@@ -43,6 +44,10 @@ FileSearchDialog::FileSearchDialog(QStringList paths, QWidget* parent, Qt::Windo
|
||||||
|
connect(ui->addPath, &QPushButton::clicked, this, &FileSearchDialog::onAddPath);
|
||||||
|
connect(ui->removePath, &QPushButton::clicked, this, &FileSearchDialog::onRemovePath);
|
||||||
|
|
||||||
|
+ // the default completer is case-insensitive
|
||||||
|
+ ui->namePatterns->completer()->setCaseSensitivity(Qt::CaseSensitive);
|
||||||
|
+ ui->contentPattern->completer()->setCaseSensitivity(Qt::CaseSensitive);
|
||||||
|
+
|
||||||
|
ui->namePatterns->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +55,25 @@ FileSearchDialog::~FileSearchDialog() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
+QString FileSearchDialog::namePattern() const {
|
||||||
|
+ return ui->namePatterns->currentText();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+QString FileSearchDialog::contentPattern() const {
|
||||||
|
+ return ui->contentPattern->currentText();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void FileSearchDialog::addNamePatterns(const QStringList& patterns) {
|
||||||
|
+ ui->namePatterns->addItems(patterns);
|
||||||
|
+ ui->namePatterns->setCurrentIndex(-1);
|
||||||
|
+ ui->namePatterns->setCurrentText(QLatin1String("*"));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void FileSearchDialog::addContentPatterns(const QStringList& patterns) {
|
||||||
|
+ ui->contentPattern->addItems(patterns);
|
||||||
|
+ ui->contentPattern->setCurrentIndex(-1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void FileSearchDialog::accept() {
|
||||||
|
// build the search:/// uri
|
||||||
|
int n = ui->listView->count();
|
||||||
|
@@ -62,11 +86,11 @@ void FileSearchDialog::accept() {
|
||||||
|
|
||||||
|
fm_search_set_recursive(search, ui->recursiveSearch->isChecked());
|
||||||
|
fm_search_set_show_hidden(search, ui->searchHidden->isChecked());
|
||||||
|
- fm_search_set_name_patterns(search, ui->namePatterns->text().toUtf8().constData());
|
||||||
|
+ fm_search_set_name_patterns(search, ui->namePatterns->currentText().toUtf8().constData());
|
||||||
|
fm_search_set_name_ci(search, !ui->nameCaseSensitive->isChecked());
|
||||||
|
fm_search_set_name_regex(search, ui->nameRegExp->isChecked());
|
||||||
|
|
||||||
|
- fm_search_set_content_pattern(search, ui->contentPattern->text().toUtf8().constData());
|
||||||
|
+ fm_search_set_content_pattern(search, ui->contentPattern->currentText().toUtf8().constData());
|
||||||
|
fm_search_set_content_ci(search, !ui->contentCaseSensitive->isChecked());
|
||||||
|
fm_search_set_content_regex(search, ui->contentRegExp->isChecked());
|
||||||
|
|
||||||
|
diff --git a/src/filesearchdialog.h b/src/filesearchdialog.h
|
||||||
|
index 504c1ed0..2aee1b57 100644
|
||||||
|
--- a/src/filesearchdialog.h
|
||||||
|
+++ b/src/filesearchdialog.h
|
||||||
|
@@ -59,6 +59,12 @@ class LIBFM_QT_API FileSearchDialog : public QDialog {
|
||||||
|
bool searchhHidden() const;
|
||||||
|
void setSearchhHidden(bool hidden);
|
||||||
|
|
||||||
|
+ QString namePattern() const;
|
||||||
|
+ QString contentPattern() const;
|
||||||
|
+
|
||||||
|
+ void addNamePatterns(const QStringList& patterns);
|
||||||
|
+ void addContentPatterns(const QStringList& patterns);
|
||||||
|
+
|
||||||
|
private Q_SLOTS:
|
||||||
|
void onAddPath();
|
||||||
|
void onRemovePath();
|
Loading…
Reference in new issue