Kate
katesearchbar.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KATE_SEARCH_BAR_H
00020 #define KATE_SEARCH_BAR_H 1
00021
00022 #include "kateviewhelpers.h"
00023 #include "katesmartrange.h"
00024 #include "katedocument.h"
00025 #include "katehistorymodel.h"
00026
00027 #include <kcolorscheme.h>
00028
00029 #include <QtCore/QRegExp>
00030
00031
00032 namespace KTextEditor {
00033 class SmartRangeNotifier;
00034 }
00035
00036 class KateView;
00037 class QVBoxLayout;
00038 class QCheckBox;
00039 class QComboBox;
00040 class QStringListModel;
00041
00042 namespace Ui {
00043 class IncrementalSearchBar;
00044 class PowerSearchBar;
00045 }
00046
00047
00048
00049 class KateSearchBar : public KateViewBarWidget {
00050 Q_OBJECT
00051
00052 private:
00053 enum SearchMode {
00054
00055
00056 MODE_PLAIN_TEXT = 0,
00057 MODE_WHOLE_WORDS = 1,
00058 MODE_ESCAPE_SEQUENCES = 2,
00059 MODE_REGEX = 3
00060 };
00061
00062 public:
00063 explicit KateSearchBar(bool initAsPower, KateView* view, QWidget* parent=0);
00064 ~KateSearchBar();
00065
00066 public Q_SLOTS:
00067
00068 void findNext();
00069 void findPrevious();
00070
00071 void onIncPatternChanged(const QString & pattern, bool invokedByUserAction = true);
00072 void onIncNext();
00073 void onIncPrev();
00074 void onIncMatchCaseToggle(bool invokedByUserAction = true);
00075 void onIncHighlightAllToggle(bool checked, bool invokedByUserAction = true);
00076 void onIncFromCursorToggle(bool invokedByUserAction = true);
00077
00078 void onForAll(const QString & pattern, KTextEditor::Range inputRange,
00079 KTextEditor::Search::SearchOptions enabledOptions,
00080 const QString * replacement);
00081 bool onStep(bool replace, bool forwards = true);
00082 void onReturnPressed();
00083 void onSelectionChanged();
00084 void onCursorPositionChanged();
00085
00086 void onPowerPatternChanged(const QString & pattern);
00087 void onPowerFindNext();
00088 void onPowerFindPrev();
00089 void onPowerReplaceNext();
00090 void onPowerReplaceAll();
00091 void onPowerMatchCaseToggle(bool invokedByUserAction = true);
00092 void onPowerHighlightAllToggle(bool checked, bool invokedByUserAction = true);
00093 void onPowerFromCursorToggle(bool invokedByUserAction = true);
00094 void onPowerModeChangedPlainText();
00095 void onPowerModeChangedWholeWords();
00096 void onPowerModeChangedEscapeSequences();
00097 void onPowerModeChangedRegularExpression();
00098 private:
00099 void onPowerModeChanged();
00100 public Q_SLOTS:
00101 void onPowerModeChanged(int index, bool invokedByUserAction = true);
00102 void onPowerPatternContextMenuRequest();
00103 void onPowerReplacmentContextMenuRequest();
00104
00105 public:
00106
00107 static void nextMatchForSelection(KateView * view, bool forwards);
00108
00109 public Q_SLOTS:
00110
00111 void onMutatePower();
00112 void onMutateIncremental();
00113
00114 private Q_SLOTS:
00115 void rangeContentsChanged(KTextEditor::SmartRange* range);
00116
00117 private:
00118
00119 bool isChecked(QCheckBox * checkbox);
00120 bool isChecked(QAction * menuAction);
00121 void setChecked(QCheckBox * checkbox, bool checked);
00122 void setChecked(QAction * menuAction, bool checked);
00123 void enableHighlights(bool enable);
00124 void resetHighlights();
00125
00126 void highlight(const KTextEditor::Range & range, const QColor & color);
00127 void highlightMatch(const KTextEditor::Range & range);
00128 void highlightReplacement(const KTextEditor::Range & range);
00129 void highlightAllMatches(const QString & pattern,
00130 KTextEditor::Search::SearchOptions searchOptions);
00131 void adjustBackground(QPalette & palette, KColorScheme::BackgroundRole newRole);
00132 void neutralMatch();
00133 void indicateMatch(bool wrapped);
00134 void indicateMismatch();
00135 void indicateNothing();
00136 static void selectRange(KateView * view, const KTextEditor::Range & range);
00137 void buildReplacement(QString & output, QList<ReplacementPart> & parts,
00138 const QVector<KTextEditor::Range> & details, int replacementCounter);
00139 void replaceMatch(const QVector<KTextEditor::Range> & match, const QString & replacement,
00140 int replacementCounter = 1);
00141
00142 QVector<QString> getCapturePatterns(const QString & pattern);
00143 void showExtendedContextMenu(bool forPattern);
00144
00145 void givePatternFeedback(const QString & pattern);
00146 void addCurrentTextToHistory(QComboBox * combo);
00147 void backupConfig(bool ofPower);
00148 void sendConfig();
00149 void fixForSingleLine(KTextEditor::Range & range, bool forwards);
00150
00151 private:
00152
00153 void showEvent(QShowEvent * event);
00154
00155 public:
00156 void closed();
00157
00158 private:
00159
00160 KTextEditor::SmartRange * m_topRange;
00161 KTextEditor::SmartRangeNotifier *m_rangeNotifier;
00162 QVBoxLayout * m_layout;
00163 QWidget * m_widget;
00164 QRegExp m_patternTester;
00165
00166
00167 Ui::IncrementalSearchBar * m_incUi;
00168 QMenu * m_incMenu;
00169 QAction * m_incMenuMatchCase;
00170 QAction * m_incMenuFromCursor;
00171 QAction * m_incMenuHighlightAll;
00172 KTextEditor::Cursor m_incInitCursor;
00173
00174
00175 Ui::PowerSearchBar * m_powerUi;
00176 QMenu * m_powerMenu;
00177 QAction * m_powerMenuFromCursor;
00178 QAction * m_powerMenuHighlightAll;
00179 QAction * m_powerMenuSelectionOnly;
00180
00181
00182 bool m_incHighlightAll : 1;
00183 bool m_incFromCursor : 1;
00184 bool m_incMatchCase : 1;
00185 bool m_powerMatchCase : 1;
00186 bool m_powerFromCursor : 1;
00187 bool m_powerHighlightAll : 1;
00188 unsigned int m_powerMode : 2;
00189
00190 };
00191
00192
00193
00194 #endif // KATE_SEARCH_BAR_H
00195