File: qsearchreplacepanel.h

package info (click to toggle)
texstudio 2.11.2%2Bdebian-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 41,292 kB
  • ctags: 12,405
  • sloc: cpp: 93,072; xml: 10,217; ansic: 4,153; sh: 145; makefile: 56
file content (153 lines) | stat: -rw-r--r-- 4,700 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/****************************************************************************
**
** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr>
**
** This file is part of the Edyuk project <http://edyuk.org>
** 
** This file may be used under the terms of the GNU General Public License
** version 3 as published by the Free Software Foundation and appearing in the
** file GPL.txt included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/

#ifndef _QSEARCH_REPLACE_PANEL_H_
#define _QSEARCH_REPLACE_PANEL_H_

#include "mostQtHeaders.h"

#include "qpanel.h"

/*!
	\file qsearchreplacepanel.h
	\brief Definition of the QSearchReplacePanel class.
	
	\see QSearchReplacePanel
*/


class QDocumentCursor;
class QDocumentLine;
class QDocumentSearch;

class QCE_EXPORT QSearchReplacePanel : public QPanel //, private Ui::SearchReplace
{
	Q_OBJECT
	
	public:
		Q_PANEL(QSearchReplacePanel, "Search Replace Panel")
		
		QSearchReplacePanel(QWidget *p = 0);
		virtual ~QSearchReplacePanel();
		
		virtual QString type() const;
		bool isReplaceModeActive() const;
		QDocumentCursor getSearchScope() const;
		QDocumentSearch * search(){
			return m_search;
		}

		void setUseLineForSearch(bool b);
		bool getUseLineForSearch() const;
		void setSearchOnlyInSelection(bool b);
		bool getSearchOnlyInSelection() const;
        QString getSearchText() const;
        QString getReplaceText() const;
        bool getSearchIsCase() const;
        bool getSearchIsRegExp() const;
        bool getSearchIsWords() const;
		
		
	public slots:
		void display(int mode, bool replace);
		void closeSomething(bool closeTogether);
		
		void findNext();
		void findReplace(bool backward, bool replace=false, bool replaceAll=false, bool countOnly = false);
		void find(QString text, bool backward, bool highlight, bool regex, bool word, bool caseSensitive);
		void find(QString text, bool backward, bool highlight, bool regex, bool word, bool caseSensitive, bool fromCursor, bool selection);
		void selectAllMatches();
		void setOptions(int searchOptions, bool cursor, bool selection);
	signals:
		void onClose();
        void showExtendedSearch();
	protected:
		virtual bool forward(QMouseEvent *e);
		virtual void editorChange(QEditor *e);
		
		virtual bool eventFilter(QObject *o, QEvent *e);
		
		virtual void hideEvent(QHideEvent *e);
		virtual void closeEvent(QCloseEvent *e);


	private slots:
		void cFind_textEdited(const QString& text);
		void cReplace_textEdited(const QString& text);
		
		void on_cbReplace_toggled(bool on);
		
		void on_cbCase_toggled(bool on);
		void on_cbWords_toggled(bool on);
		void on_cbRegExp_toggled(bool on);
		void on_cbCursor_toggled(bool on);
		void on_cbHighlight_toggled(bool on);
		void on_cbSelection_toggled(bool on);
		void on_cbEscapeSeq_toggled(bool on);
		void on_cbPrompt_toggled(bool on);
		

		void on_bNext_clicked();
		void on_bPrevious_clicked();
		void on_bCount_clicked();

		void on_bReplaceNext_clicked();
		void on_bReplacePrevious_clicked();
		void on_bReplaceAll_clicked();
		
		void cursorPositionChanged();
		void updateReplacementHint();

	private:
		void init();
		void updateSearchOptions(bool replace, bool replaceAll);
		void on_cFind_returnPressed(bool backward);
		void on_cReplace_returnPressed(bool backward);
		QDocumentSearch *m_search;
		bool m_lastDirection;
		int minimum_width;

	protected:
		QStringList getHistory(bool findHistory = true);
		void setHistory(const QStringList& newHistory, bool findHistory = true);
		void rememberLastSearch(QStringList& history, const QString& str, bool incremental);
		//protected to give unit tests access
		//find
		QToolButton *bClose;
		QComboBox *cFind;
		QToolButton *bNext, *bPrevious, *bCount;
		QGridLayout *layoutFindOptions;
        QToolButton *cbCase;
        QToolButton *cbWords;
        QToolButton *cbRegExp;
        QToolButton *cbHighlight;
        QToolButton *cbCursor;
        QToolButton *cbSelection;
        QToolButton *bExtend;
		// replace
		QCheckBox *cbReplace;
		QComboBox *cReplace;
		QToolButton *bReplaceNext;
		QToolButton *bReplacePrevious;
		QToolButton *bReplaceAll;
		QGridLayout *layoutReplaceOptions;
        QToolButton *cbPrompt;
        QToolButton *cbEscapeSeq;
        QLabel *lReplacementText;
		
		bool useLineForSearch, searchOnlyInSelection;
};

#endif // _QSEARCH_REPLACE_PANEL_H_