• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Kate

katesearchbar.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries and the Kate part.
00002  *
00003  *  Copyright (C) 2009-2010 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
00004  *  Copyright (C) 2007 Sebastian Pipping <webmaster@hartwork.org>
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Library General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Library General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Library General Public License
00017  *  along with this library; see the file COPYING.LIB.  If not, write to
00018  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #ifndef KATE_SEARCH_BAR_H
00023 #define KATE_SEARCH_BAR_H 1
00024 
00025 #include "kateviewhelpers.h"
00026 #include "katepartprivate_export.h"
00027 
00028 #include <ktexteditor/attribute.h>
00029 #include <ktexteditor/searchinterface.h>
00030 
00031 class KateView;
00032 class KateViewConfig;
00033 class QVBoxLayout;
00034 class QComboBox;
00035 
00036 namespace Ui {
00037     class IncrementalSearchBar;
00038     class PowerSearchBar;
00039 }
00040 
00041 namespace KTextEditor {
00042     class MovingRange;
00043 }
00044 
00045 
00046 class KATEPART_TESTS_EXPORT KateSearchBar : public KateViewBarWidget {
00047     Q_OBJECT
00048 
00049     friend class SearchBarTest;
00050 
00051 public:
00052     enum SearchMode {
00053         // NOTE: Concrete values are important here
00054         // to work with the combobox index!
00055         MODE_PLAIN_TEXT = 0,
00056         MODE_WHOLE_WORDS = 1,
00057         MODE_ESCAPE_SEQUENCES = 2,
00058         MODE_REGEX = 3
00059     };
00060 
00061     enum MatchResult {
00062         MatchFound,
00063         MatchWrappedForward,
00064         MatchWrappedBackward,
00065         MatchMismatch,
00066         MatchNothing,
00067         MatchNeutral
00068     };
00069 
00070     enum SearchDirection {
00071       SearchForward,
00072       SearchBackward
00073     };
00074 
00075 public:
00076     explicit KateSearchBar(bool initAsPower, KateView* view, KateViewConfig *config);
00077     ~KateSearchBar();
00078 
00079     bool isPower() const;
00080 
00081     QString searchPattern() const;
00082     QString replacementPattern() const;
00083 
00084     bool selectionOnly() const;
00085     bool matchCase() const;
00086 
00087     // Only used by KateView
00088     static void nextMatchForSelection(KateView * view, SearchDirection searchDirection);
00089 
00090 public Q_SLOTS:
00091     void setSearchPattern(const QString &searchPattern);
00092     void setReplacePattern(const QString &replacePattern);
00093     void setSearchMode(SearchMode mode);
00094 
00095     void setSelectionOnly(bool selectionOnly);
00096     void setMatchCase(bool matchCase);
00097 
00098     // Called for <F3> and <Shift>+<F3>
00099     void findNext();
00100     void findPrevious();
00101     void findAll();
00102 
00103     void replaceNext();
00104     void replaceAll();
00105 
00106     // Also used by KateView
00107     void enterPowerMode();
00108     void enterIncrementalMode();
00109 
00110     void clearHighlights();
00111 
00112 protected:
00113     // Overridden
00114     virtual void showEvent(QShowEvent * event);
00115 
00116 private Q_SLOTS:
00117     void onIncPatternChanged(const QString & pattern);
00118     void onMatchCaseToggled(bool matchCase);
00119 
00120     void onReturnPressed();
00121     void updateSelectionOnly();
00122     void updateIncInitCursor();
00123 
00124     void onPowerPatternChanged(const QString & pattern);
00125 
00126     void onPowerModeChanged(int index);
00127     void onPowerPatternContextMenuRequest();
00128     void onPowerPatternContextMenuRequest(const QPoint&);
00129     void onPowerReplacmentContextMenuRequest();
00130     void onPowerReplacmentContextMenuRequest(const QPoint&);
00131 
00132 private:
00133     // Helpers
00134     bool find(SearchDirection searchDirection = SearchForward, const QString * replacement = 0);
00135     int findAll(KTextEditor::Range inputRange, const QString * replacement);
00136 
00137     bool isPatternValid() const;
00138 
00139     KTextEditor::Search::SearchOptions searchOptions(SearchDirection searchDirection = SearchForward) const;
00140 
00141     void highlightMatch(const KTextEditor::Range & range);
00142     void highlightReplacement(const KTextEditor::Range & range);
00143     void indicateMatch(MatchResult matchResult);
00144     static void selectRange(KateView * view, const KTextEditor::Range & range);
00145     void selectRange2(const KTextEditor::Range & range);
00146 
00147     QVector<QString> getCapturePatterns(const QString & pattern) const;
00148     void showExtendedContextMenu(bool forPattern, const QPoint& pos);
00149 
00150     void givePatternFeedback();
00151     void addCurrentTextToHistory(QComboBox * combo);
00152     void backupConfig(bool ofPower);
00153     void sendConfig();
00154     void fixForSingleLine(KTextEditor::Range & range, SearchDirection searchDirection);
00155 
00156 private:
00157     KateView *const m_view;
00158     KateViewConfig *const m_config;
00159     QList<KTextEditor::MovingRange*> m_hlRanges;
00160 
00161     // Shared by both dialogs
00162     QVBoxLayout *const m_layout;
00163     QWidget * m_widget;
00164 
00165     // Incremental search related
00166     Ui::IncrementalSearchBar * m_incUi;
00167     KTextEditor::Cursor m_incInitCursor;
00168 
00169     // Power search related
00170     Ui::PowerSearchBar * m_powerUi;
00171 
00172     // attribute to highlight matches with
00173     KTextEditor::Attribute::Ptr highlightMatchAttribute;
00174     KTextEditor::Attribute::Ptr highlightReplacementAttribute;
00175 
00176     // Status backup
00177     bool m_incHighlightAll : 1;
00178     bool m_incFromCursor : 1;
00179     bool m_incMatchCase : 1;
00180     bool m_powerMatchCase : 1;
00181     bool m_powerFromCursor : 1;
00182     bool m_powerHighlightAll : 1;
00183     unsigned int m_powerMode : 2;
00184 };
00185 
00186 
00187 
00188 #endif // KATE_SEARCH_BAR_H
00189 
00190 // kate: space-indent on; indent-width 4; replace-tabs on;

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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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