musredit 1.0.0
Loading...
Searching...
No Matches
PReplaceDialog.cpp
Go to the documentation of this file.
1/****************************************************************************
2
3 PReplaceDialog.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8*****************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2009-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
42
43#include <QPushButton>
44#include <QComboBox>
45#include <QCheckBox>
46
47#include "PReplaceDialog.h"
48
49//----------------------------------------------------------------------------------------------------
135PReplaceDialog::PReplaceDialog(PFindReplaceData *data, const bool selection, QWidget *parent) :
136 QDialog(parent), fData(data)
137{
138 setupUi(this);
139
140 setModal(true);
141
142 // if only empty text, disable find button
143 if (fData->findText == "") {
144 fReplace_pushButton->setEnabled(false);
145 }
146
147 // if there is no selection, disable that option
148 if (!selection) {
149 fSelectedText_checkBox->setChecked(false);
150 fSelectedText_checkBox->setEnabled(false);
151 }
152
153 fFind_comboBox->setItemText(0, fData->findText);
154 fReplacementText_comboBox->setItemText(0, fData->replaceText);
155 fCaseSensitive_checkBox->setChecked(fData->caseSensitive);
156 fWholeWordsOnly_checkBox->setChecked(fData->wholeWordsOnly);
157 fFromCursor_checkBox->setChecked(fData->fromCursor);
158 fFindBackwards_checkBox->setChecked(fData->findBackwards);
159 fPromptOnReplace_checkBox->setChecked(fData->promptOnReplace);
160
161 if (selection) {
162 fSelectedText_checkBox->setChecked(fData->selectedText);
163 }
164}
165
166//----------------------------------------------------------------------------------------------------
244{
245 fData->findText = fFind_comboBox->currentText();
246 fData->replaceText = fReplacementText_comboBox->currentText();
247 fData->caseSensitive = fCaseSensitive_checkBox->isChecked();
248 fData->wholeWordsOnly = fWholeWordsOnly_checkBox->isChecked();
249 fData->fromCursor = fFromCursor_checkBox->isChecked();
250 fData->findBackwards = fFindBackwards_checkBox->isChecked();
251 if (fSelectedText_checkBox->isEnabled())
252 fData->selectedText = fSelectedText_checkBox->isChecked();
253 fData->promptOnReplace = fPromptOnReplace_checkBox->isChecked();
254
255 return fData;
256}
257
258//----------------------------------------------------------------------------------------------------
323{
324 if (fFind_comboBox->currentText() != "")
325 fReplace_pushButton->setEnabled(true);
326 else
327 fReplace_pushButton->setEnabled(false);
328}
329
330//----------------------------------------------------------------------------------------------------
331// END
332//----------------------------------------------------------------------------------------------------
Find and replace dialog for the musredit text editor.
virtual PFindReplaceData * getData()
Retrieves updated find/replace parameters from the dialog.
PFindReplaceData * fData
Pointer to find/replace parameter structure storing all settings.
virtual void onFindTextAvailable(const QString &)
Slot: Handles changes to the find text input.
PReplaceDialog(PFindReplaceData *data, const bool selection, QWidget *parent=nullptr)
Constructs the find and replace dialog.
Configuration structure for find and replace operations.
Definition musredit.h:109