• Skip to content
  • Skip to link menu
KDE 4.1 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 
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         // NOTE: Concrete values are important here
00052         // to work with the combobox index!
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     // Called for <F3> and <Shift>+<F3>
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     // Only used by KateView
00096     static void nextMatchForSelection(KateView * view, bool forwards);
00097 
00098 public Q_SLOTS:
00099     // Also used by KateView
00100     void onMutatePower();
00101     void onMutateIncremental();
00102 
00103 private:
00104     // Helpers
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     // Overridden
00142     void showEvent(QShowEvent * event);
00143     void hideEvent(QHideEvent * event);
00144 
00145 private:
00146     // Shared by both dialogs
00147     KateView * m_view;
00148     KTextEditor::SmartRange * m_topRange;
00149     QVBoxLayout * m_layout;
00150     QWidget * m_widget;
00151     QRegExp m_patternTester;
00152 
00153     // Incremental search related
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     // Power search related
00162     Ui::PowerSearchBar * m_powerUi;
00163 
00164     // Status backup
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 

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
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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