• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katesearchbar.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2007 Sebastian Pipping <webmaster@hartwork.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
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         // NOTE: Concrete values are important here
00055         // to work with the combobox index!
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     // Called for <F3> and <Shift>+<F3>
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     // Only used by KateView
00107     static void nextMatchForSelection(KateView * view, bool forwards);
00108 
00109 public Q_SLOTS:
00110     // Also used by KateView
00111     void onMutatePower();
00112     void onMutateIncremental();
00113 
00114 private Q_SLOTS:
00115     void rangeContentsChanged(KTextEditor::SmartRange* range);
00116 
00117 private:
00118     // Helpers
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 resetHighlights();
00124 
00125     void highlight(const KTextEditor::Range & range, const QColor & color);
00126     void highlightMatch(const KTextEditor::Range & range);
00127     void highlightReplacement(const KTextEditor::Range & range);
00128     void highlightAllMatches(const QString & pattern,
00129             KTextEditor::Search::SearchOptions searchOptions);
00130     void adjustBackground(QPalette & palette, KColorScheme::BackgroundRole newRole);
00131     void neutralMatch();
00132     void indicateMatch(bool wrapped);
00133     void indicateMismatch();
00134     void indicateNothing();
00135     static void selectRange(KateView * view, const KTextEditor::Range & range);
00136     void buildReplacement(QString & output, QList<ReplacementPart> & parts,
00137             const QVector<KTextEditor::Range> & details, int replacementCounter);
00138     void replaceMatch(const QVector<KTextEditor::Range> & match, const QString & replacement,
00139             int replacementCounter = 1);
00140 
00141     QVector<QString> getCapturePatterns(const QString & pattern);
00142     void showExtendedContextMenu(bool forPattern);
00143 
00144     void givePatternFeedback(const QString & pattern);
00145     void addCurrentTextToHistory(QComboBox * combo);
00146     void backupConfig(bool ofPower);
00147     void sendConfig();
00148     void fixForSingleLine(KTextEditor::Range & range, bool forwards);
00149 
00150 private:
00151     // Overridden
00152     void showEvent(QShowEvent * event);
00153     //void hideEvent(QHideEvent * event);
00154 public:
00155     void closed();
00156     void enableHighlights(bool enable);
00157 
00158 private:
00159     // Shared by both dialogs
00160     KTextEditor::SmartRange * m_topRange;
00161     KTextEditor::SmartRangeNotifier *m_rangeNotifier;
00162     QVBoxLayout * m_layout;
00163     QWidget * m_widget;
00164     QRegExp m_patternTester;
00165 
00166     // Incremental search related
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     // Power search related
00175     Ui::PowerSearchBar * m_powerUi;
00176     QMenu * m_powerMenu;
00177     QAction * m_powerMenuFromCursor;
00178     QAction * m_powerMenuHighlightAll;
00179     QAction * m_powerMenuSelectionOnly;
00180 
00181     // Status backup
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 

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal