File indexing completed on 2024-04-28 16:26:19
0001 /* This file is part of the kile project 0002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 0003 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org> 0004 Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk> 0005 Copyright (C) 2003 Jan-Marek Glogowski <glogow@stud.fbi.fh-darmstadt.de> 0006 Copyright (C) 2008-2010 Michel Ludwig <michel.ludwig@kdemail.net> 0007 0008 This program is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU General Public License as 0010 published by the Free Software Foundation; either version 2 of 0011 the License, or (at your option) any later version. 0012 0013 This program is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 GNU General Public License for more details. 0017 0018 You should have received a copy of the GNU General Public License 0019 along with this program. If not, see <http://www.gnu.org/licenses/>. 0020 0021 Original from kdebase / kate 0022 */ 0023 0024 #ifndef FINDFILESDIALOG_H 0025 #define FINDFILESDIALOG_H 0026 0027 #include <QDialog> 0028 0029 #include <QStringList> 0030 0031 #include "kileinfo.h" 0032 #include "latexcmd.h" 0033 0034 class QCheckBox; 0035 class QEvent; 0036 class QLabel; 0037 class QLineEdit; 0038 class QListWidget; 0039 class QPushButton; 0040 0041 class KProcess; 0042 class KComboBox; 0043 class KUrlRequester; 0044 0045 #define KILEGREP_MAX 12 0046 0047 namespace KileGrep 0048 { 0049 enum Mode { Project = 0, Directory }; 0050 enum List { SearchItems = 0, SearchPaths, SearchTemplates }; 0051 enum TemplateMode { tmNormal = 0, tmCommand, tmCommandWithOption, tmEnv, tmGraphics, tmLabel, tmRefs, tmFiles }; 0052 } 0053 0054 namespace KileDialog { 0055 0056 class FindFilesDialog : public QDialog 0057 { 0058 Q_OBJECT 0059 0060 public: 0061 FindFilesDialog(QWidget *parent, KileInfo *ki, KileGrep::Mode mode, const char *name = 0); 0062 ~FindFilesDialog(); 0063 0064 void appendFilter(const QString &name, const QString &filter); 0065 0066 void appendTemplate(const QString &name, const QString ®exp); 0067 void clearTemplates(); 0068 0069 public Q_SLOTS: 0070 void slotSearchFor(const QString &pattern); 0071 0072 Q_SIGNALS: 0073 void itemSelected(const QString &abs_filename, int line); 0074 0075 private: 0076 KileInfo *m_ki; 0077 KileGrep::Mode m_mode; 0078 KProcess *m_proc; 0079 int m_grepJobs; 0080 0081 void readConfig(); 0082 void writeConfig(); 0083 0084 QStringList getListItems(KComboBox *combo); 0085 int findListItem(KComboBox *combo, const QString &s); 0086 void updateListItems(KComboBox *combo); 0087 0088 void processOutput(bool forceAll = false); 0089 void finish(); 0090 0091 void startGrep(); 0092 bool shouldRestart() { 0093 return (m_grepJobs > 0); 0094 } 0095 void clearGrepJobs() { 0096 m_grepJobs = 0; 0097 } 0098 QString buildFilesCommand(); 0099 QString buildProjectCommand(); 0100 QString getPattern(); 0101 QString getShellPattern(); 0102 QString getCommandList(KileDocument::CmdAttribute attrtype); 0103 0104 void setupDirectory(); 0105 void setupProject(); 0106 void setDirName(const QString &dir); 0107 void setFilter(const QString &filter); 0108 QStringList readList(KileGrep::List listtype); 0109 void updateLists(); 0110 void updateWidgets(); 0111 0112 QStringList m_projectfiles; 0113 QString m_projectdir; 0114 bool m_projectOpened; 0115 0116 QLabel *projectname_label, *projectdirname_label; 0117 QLineEdit *template_edit; 0118 KComboBox *filter_combo, *pattern_combo, *template_combo; 0119 KUrlRequester *dir_combo; 0120 QCheckBox *recursive_box; 0121 QListWidget *resultbox; 0122 QPushButton *search_button, *clear_button, *close_button; 0123 QString m_buf; 0124 QString m_errbuf; 0125 QStringList m_filterList; 0126 QStringList m_TemplateList; 0127 int m_lastTemplateIndex; 0128 0129 private Q_SLOTS: 0130 void processExited(int exitCode, QProcess::ExitStatus exitStatus); 0131 void processStandardOutputReady(); 0132 void processErrorOutputReady(); 0133 void slotItemSelected(const QString&); 0134 void slotSearch(); 0135 void slotClear(); 0136 void slotClose(); 0137 void slotPatternTextChanged(const QString &); 0138 void slotTemplateActivated(int index); 0139 }; 0140 0141 } 0142 0143 #endif