File indexing completed on 2024-05-05 17:57:23

0001 /*
0002     SPDX-FileCopyrightText: 2001 Shie Erlich <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2001 Rafi Yanai <krusader@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRSEARCHDIALOG_H
0010 #define KRSEARCHDIALOG_H
0011 
0012 // QtCore
0013 #include <QString>
0014 #include <QStringList>
0015 // QtWidgets
0016 #include <QCheckBox>
0017 #include <QDialog>
0018 #include <QLabel>
0019 #include <QTabWidget>
0020 
0021 class FileItem;
0022 class FilterTabs;
0023 class GeneralFilter;
0024 class KrSearchBar;
0025 class KrSqueezedTextLabel;
0026 class KrView;
0027 class KrViewItem;
0028 class KrQuery;
0029 class KrSearchMod;
0030 class KSqueezedTextLabel;
0031 class ProfileManager;
0032 class SearchResultContainer;
0033 
0034 class KrSearchDialog : public QDialog
0035 {
0036     Q_OBJECT
0037 public:
0038     explicit KrSearchDialog(const QString &profile = QString(), QWidget *parent = nullptr);
0039     ~KrSearchDialog() override;
0040 
0041     void prepareGUI();
0042 
0043     static KrSearchDialog *SearchDialog;
0044 
0045 public slots:
0046     void startSearch();
0047     void stopSearch();
0048     void feedToListBox();
0049     void slotFound(const FileItem &file, const QString &foundText);
0050     void closeDialog(bool isAccept = true);
0051     void executed(const QString &name);
0052     void currentChanged(KrViewItem *item);
0053     void contextMenu(const QPoint &);
0054 
0055     void keyPressEvent(QKeyEvent *e) override;
0056     void closeEvent(QCloseEvent *e) override;
0057     void resizeEvent(QResizeEvent *e) override;
0058 
0059 protected slots:
0060     void reject() override;
0061 
0062 private slots:
0063     void editCurrent();
0064     void viewCurrent();
0065     void compareByContent();
0066     void copyToClipBoard();
0067 
0068 private:
0069     bool gui2query();
0070 
0071     /**
0072      * Placing search query to clipboard is optional (opt-in).
0073      * So user has clipboard untact by default when opening found documents,
0074      * but can enable it persistently by checking "Query to clipboard" checkbox.
0075      */
0076     void tryPlaceSearchQueryToClipboard();
0077 
0078 private:
0079     ProfileManager *profileManager;
0080     QCheckBox *searchTextToClipboard;
0081 
0082     FilterTabs *filterTabs;
0083     GeneralFilter *generalFilter;
0084 
0085     QPushButton *mainSearchBtn;
0086     QPushButton *mainStopBtn;
0087     QPushButton *mainCloseBtn;
0088     QPushButton *mainFeedToListBoxBtn;
0089 
0090     QTabWidget *searcherTabs;
0091     QLabel *foundLabel;
0092     KrSqueezedTextLabel *foundTextLabel;
0093     KSqueezedTextLabel *searchingLabel;
0094 
0095     SearchResultContainer *result;
0096     KrView *resultView;
0097     KrSearchBar *searchBar;
0098     QFrame *foundTextFrame;
0099 
0100     KrQuery *query;
0101     KrSearchMod *searcher;
0102     bool isBusy;
0103     bool closed;
0104 
0105     QAction *viewAction;
0106     QAction *editAction;
0107     QAction *compareAction;
0108     QAction *copyAction;
0109 
0110     static QString lastSearchText;
0111     static int lastSearchType;
0112     static bool lastSearchForCase;
0113     static bool lastContainsWholeWord;
0114     static bool lastContainsWithCase;
0115     static bool lastSearchInSubDirs;
0116     static bool lastSearchInArchives;
0117     static bool lastFollowSymLinks;
0118     static bool lastContainsRegExp;
0119 
0120     int sizeX;
0121     int sizeY;
0122 };
0123 
0124 #endif