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
00033 class KateView;
00034 class QVBoxLayout;
00035 class QCheckBox;
00036 class QComboBox;
00037 class QStringListModel;
00038
00039 namespace Ui {
00040 class IncrementalSearchBar;
00041 class PowerSearchBar;
00042 }
00043
00044
00045
00046 class KateSearchBar : public KateViewBarWidget {
00047 Q_OBJECT
00048
00049 private:
00050 enum SearchMode {
00051
00052
00053 MODE_PLAIN_TEXT = 0,
00054 MODE_WHOLE_WORDS = 1,
00055 MODE_ESCAPE_SEQUENCES = 2,
00056 MODE_REGEX = 3
00057 };
00058
00059 public:
00060 explicit KateSearchBar(KateViewBar * viewBar, bool initAsPower);
00061 ~KateSearchBar();
00062
00063 public Q_SLOTS:
00064
00065 void findNext();
00066 void findPrevious();
00067
00068 void onIncPatternChanged(const QString & pattern, bool invokedByUserAction = true);
00069 void onIncNext();
00070 void onIncPrev();
00071 void onIncMatchCaseToggle(bool invokedByUserAction = true);
00072 void onIncHighlightAllToggle(bool checked, bool invokedByUserAction = true);
00073 void onIncFromCursorToggle(bool invokedByUserAction = true);
00074
00075 void onForAll(const QString & pattern, KTextEditor::Range inputRange,
00076 KTextEditor::Search::SearchOptions enabledOptions,
00077 const QString * replacement);
00078 bool onStep(bool replace, bool forwards = true);
00079 void onReturnPressed();
00080
00081 void onPowerPatternChanged(const QString & pattern);
00082 void onPowerFindNext();
00083 void onPowerFindPrev();
00084 void onPowerReplaceNext();
00085 void onPowerReplaceAll();
00086 void onPowerAddToPatternClicked();
00087 void onPowerAddToReplacementClicked();
00088 void onPowerUsePlaceholdersToggle(int state, bool invokedByUserAction = true);
00089 void onPowerMatchCaseToggle(bool invokedByUserAction = true);
00090 void onPowerHighlightAllToggle(int state, bool invokedByUserAction = true);
00091 void onPowerFromCursorToggle(bool invokedByUserAction = true);
00092 void onPowerModeChanged(int index, bool invokedByUserAction = true);
00093
00094 public:
00095
00096 static void nextMatchForSelection(KateView * view, bool forwards);
00097
00098 public Q_SLOTS:
00099
00100 void onMutatePower();
00101 void onMutateIncremental();
00102
00103 private:
00104
00105 bool isChecked(QCheckBox * checkbox);
00106 bool isChecked(QAction * menuAction);
00107 void setChecked(QCheckBox * checkbox, bool checked);
00108 void setChecked(QAction * menuAction, bool checked);
00109 void enableHighlights(bool enable);
00110 void resetHighlights();
00111
00112 void highlight(const KTextEditor::Range & range, const QColor & color);
00113 void highlightMatch(const KTextEditor::Range & range);
00114 void highlightReplacement(const KTextEditor::Range & range);
00115 void highlightAllMatches(const QString & pattern,
00116 KTextEditor::Search::SearchOptions searchOptions);
00117 void adjustBackground(QPalette & palette, KColorScheme::BackgroundRole newRole);
00118 void indicateMatch(bool wrapped);
00119 void indicateMismatch();
00120 void indicateNothing();
00121 static void selectRange(KateView * view, const KTextEditor::Range & range);
00122 void buildReplacement(QString & output, QList<ReplacementPart> & parts,
00123 const QVector<KTextEditor::Range> & details, int replacementCounter);
00124 void replaceMatch(const QVector<KTextEditor::Range> & match, const QString & replacement,
00125 int replacementCounter = 1);
00126
00127 QVector<QString> getCapturePatterns(const QString & pattern);
00128 void addMenuEntry(QMenu * menu, QVector<QString> & insertBefore,
00129 QVector<QString> & insertAfter, uint & walker,
00130 const QString & before, const QString after, const QString description,
00131 const QString & realBefore = QString(), const QString & realAfter = QString());
00132 void showAddMenu(bool forPattern);
00133
00134 void givePatternFeedback(const QString & pattern);
00135 void addCurrentTextToHistory(QComboBox * combo);
00136 void backupConfig(bool ofPower);
00137 void sendConfig();
00138 void fixForSingleLine(KTextEditor::Range & range, bool forwards);
00139
00140 private:
00141
00142 void showEvent(QShowEvent * event);
00143 void hideEvent(QHideEvent * event);
00144
00145 private:
00146
00147 KateView * m_view;
00148 KTextEditor::SmartRange * m_topRange;
00149 QVBoxLayout * m_layout;
00150 QWidget * m_widget;
00151 QRegExp m_patternTester;
00152
00153
00154 Ui::IncrementalSearchBar * m_incUi;
00155 QMenu * m_incMenu;
00156 QAction * m_incMenuMatchCase;
00157 QAction * m_incMenuFromCursor;
00158 QAction * m_incMenuHighlightAll;
00159 KTextEditor::Cursor m_incInitCursor;
00160
00161
00162 Ui::PowerSearchBar * m_powerUi;
00163
00164
00165 bool m_incHighlightAll : 1;
00166 bool m_incFromCursor : 1;
00167 bool m_incMatchCase : 1;
00168 bool m_powerMatchCase : 1;
00169 bool m_powerFromCursor : 1;
00170 bool m_powerHighlightAll : 1;
00171 bool m_powerUsePlaceholders : 1;
00172 unsigned int m_powerMode : 2;
00173
00174 };
00175
00176
00177
00178 #endif // KATE_SEARCH_BAR_H
00179