summaryrefslogtreecommitdiff
path: root/utils/themeeditor/qtfindreplacedialog/findreplaceform.h
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-23 07:31:53 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-23 07:31:53 +0000
commite6fd3d0318d0f53c51cf4cc87ccdc8f9741957e7 (patch)
treeda29255f5c33ae915c28a1dbff5525fdf912fbe6 /utils/themeeditor/qtfindreplacedialog/findreplaceform.h
parentb21b7714209230cbadab1e709c6778c4cc214437 (diff)
downloadrockbox-e6fd3d0318d0f53c51cf4cc87ccdc8f9741957e7.tar.gz
rockbox-e6fd3d0318d0f53c51cf4cc87ccdc8f9741957e7.zip
Theme Editor: Switched back to Lorenzo Bettini's find/replace dialog (with some modifications) as he changed the license to LGPL v2.1
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27528 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/qtfindreplacedialog/findreplaceform.h')
-rw-r--r--utils/themeeditor/qtfindreplacedialog/findreplaceform.h149
1 files changed, 149 insertions, 0 deletions
diff --git a/utils/themeeditor/qtfindreplacedialog/findreplaceform.h b/utils/themeeditor/qtfindreplacedialog/findreplaceform.h
new file mode 100644
index 0000000000..5ed85a7d60
--- /dev/null
+++ b/utils/themeeditor/qtfindreplacedialog/findreplaceform.h
@@ -0,0 +1,149 @@
1/*
2 * Copyright (C) 2009 Lorenzo Bettini <http://www.lorenzobettini.it>
3 * See COPYING file that comes with this distribution
4 */
5
6#ifndef FINDREPLACEFORM_H
7#define FINDREPLACEFORM_H
8
9#include <QWidget>
10#include <QTextCursor>
11
12#include "findreplace_global.h"
13
14namespace Ui {
15 class FindReplaceForm;
16}
17
18class QTextEdit;
19class QPlainTextEdit;
20class QSettings;
21class VariantEditor;
22
23/**
24 * The form for the find/replace dialog. The form presents the typical
25 * widgets you find in standard find/replace dialogs, and it acts on a QTextEdit.
26 *
27 * \image html Screenshot-FindReplace.png
28 *
29 * You need to set the QTextEdit explicitly, using the method setTextEdit(QTextEdit *textEdit).
30 *
31 * For instance
32 * \code
33 * m_findReplaceDialog = new FindReplaceDialog(this);
34 * m_findReplaceDialog->setModal(false);
35 * m_findReplaceDialog->setTextEdit(ui->textEdit);
36 * \endcode
37 *
38 * The find functionalities is available even if the find dialog is not shown: if something
39 * to search for was already specified, the application can call the methods findNext() and
40 * findPrev() (e.g., by connecting them to menu items).
41 *
42 * In case a regular expression is used as the search term, the form also checks whether the
43 * expression is a valid regular expression (You may want to take a look at the syntax of regular expressions:
44 * http://doc.trolltech.com/qregexp.html).
45 *
46 * The form provides also functionalities to save and restore its state using a QSettings object (i.e.,
47 * the last word searched for, the options of the form, etc.) via the methods writeSettings()
48 * and readSettings().
49 *
50 * You can take a look at the \ref examples page.
51 */
52class FINDREPLACESHARED_EXPORT FindReplaceForm : public QWidget {
53 Q_OBJECT
54public:
55 FindReplaceForm(QWidget *parent = 0);
56 virtual ~FindReplaceForm();
57
58 /**
59 * Associates the text editor where to perform the search
60 * @param textEdit_
61 */
62 void setTextEdit(QTextEdit *textEdit_);
63
64 /**
65 * Associates the text editor where to perform the search
66 * @param textEdit_
67 */
68 void setTextEdit(QPlainTextEdit *textEdit_);
69
70 /// hides replace widgets from the form
71 void hideReplaceWidgets();
72
73 /**
74 * Writes the state of the form to the passed settings.
75 * @param settings
76 * @param prefix the prefix to insert in the settings
77 */
78 virtual void writeSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
79
80 /**
81 * Reads the state of the form from the passed settings.
82 * @param settings
83 * @param prefix the prefix to look for in the settings
84 */
85 virtual void readSettings(QSettings &settings, const QString &prefix = "FindReplaceDialog");
86
87public slots:
88 /**
89 * performs the find task
90 * @param down whether to find the next or the previous
91 * occurrence
92 */
93 void find(bool down);
94
95 /**
96 * Finds the next occurrence
97 */
98 void find();
99
100 /**
101 * Finds the next occurrence
102 */
103 void findNext() { find(true); }
104
105 /**
106 * Finds the previous occurrence
107 */
108 void findPrev() { find(false); }
109
110 /**
111 * Replaces the found occurrences and goes to the next occurrence
112 */
113 void replace();
114
115 /**
116 * Replaces all the found occurrences
117 */
118 void replaceAll();
119
120protected:
121 void changeEvent(QEvent *e);
122
123 /// shows an error in the dialog
124 void showError(const QString &error);
125
126 /// shows a message in the dialog
127 void showMessage(const QString &message);
128
129protected slots:
130 /// when the text edit contents changed
131 void textToFindChanged();
132
133 /// checks whether the passed text is a valid regexp
134 void validateRegExp(const QString &text);
135
136 /// the regexp checkbox was selected
137 void regexpSelected(bool sel);
138
139protected:
140 Ui::FindReplaceForm *ui;
141
142 /// for searching into the text
143 QTextCursor textCursor;
144
145 /// the text editor (possibly) associated with this form
146 VariantEditor *textEdit;
147};
148
149#endif // FINDREPLACEFORM_H