diff --git a/src/musrgui/PFindDialog.cpp b/src/musrgui/PFindDialog.cpp new file mode 100644 index 00000000..596e02ab --- /dev/null +++ b/src/musrgui/PFindDialog.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** + + PFindDialog.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +*****************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "PFindDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *
+ */ +PFindDialog::PFindDialog(PFindReplaceData *data, QWidget *parent, const char *name, bool modal, WFlags f) : + PFindDialogBase(parent, name, modal, f), fData(data) +{ +} + +//---------------------------------------------------------------------------------------------------- +/** + *
+ */ +PFindReplaceData* PFindDialog::getData() +{ + return fData; +} + +//---------------------------------------------------------------------------------------------------- +// END +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PFindDialog.h b/src/musrgui/PFindDialog.h new file mode 100644 index 00000000..86e330b6 --- /dev/null +++ b/src/musrgui/PFindDialog.h @@ -0,0 +1,53 @@ +/**************************************************************************** + + PFindDialog.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +*****************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _PFINDDIALOG_H_ +#define _PFINDDIALOG_H_ + +#include "musrgui.h" +#include "forms/PFindDialogBase.h" + +class PFindDialog : public PFindDialogBase +{ + Q_OBJECT + + public: + PFindDialog(PFindReplaceData *data, QWidget *parent = 0, const char *name = 0, + bool modal = TRUE, WFlags f = 0); + virtual ~PFindDialog() {} + + virtual PFindReplaceData *getData(); + + private: + PFindReplaceData *fData; +}; + +#endif // _PFINDDIALOG_H_ diff --git a/src/musrgui/PReplaceDialog.cpp b/src/musrgui/PReplaceDialog.cpp new file mode 100644 index 00000000..e198c5d9 --- /dev/null +++ b/src/musrgui/PReplaceDialog.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** + + PReplaceDialog.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +*****************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "PReplaceDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *
+ */ +PReplaceDialog::PReplaceDialog(PFindReplaceData *data, QWidget *parent, const char *name, bool modal, WFlags f) : + PReplaceDialogBase(parent, name, modal, f), fData(data) +{ +} + +//---------------------------------------------------------------------------------------------------- +/** + *
+ */ +PFindReplaceData* PReplaceDialog::getData() +{ + return fData; +} + +//---------------------------------------------------------------------------------------------------- +// END +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PReplaceDialog.h b/src/musrgui/PReplaceDialog.h new file mode 100644 index 00000000..2c91c1a1 --- /dev/null +++ b/src/musrgui/PReplaceDialog.h @@ -0,0 +1,53 @@ +/**************************************************************************** + + PReplaceDialog.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + + $Id$ + +*****************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009 by Andreas Suter * + * andreas.suter@psi.ch * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _PREPLACEDIALOG_H_ +#define _PREPLACEDIALOG_H_ + +#include "musrgui.h" +#include "forms/PReplaceDialogBase.h" + +class PReplaceDialog : public PReplaceDialogBase +{ + Q_OBJECT + + public: + PReplaceDialog(PFindReplaceData *data, QWidget *parent = 0, const char *name = 0, + bool modal = TRUE, WFlags f = 0); + virtual ~PReplaceDialog() {} + + virtual PFindReplaceData *getData(); + + private: + PFindReplaceData *fData; +}; + +#endif // _PREPLACEDIALOG_H_ diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp index c41d99c3..123a5947 100644 --- a/src/musrgui/PTextEdit.cpp +++ b/src/musrgui/PTextEdit.cpp @@ -59,6 +59,8 @@ using namespace std; #include "PTextEdit.h" #include "PSubTextEdit.h" #include "PAdmin.h" +#include "PFindDialog.h" +#include "PReplaceDialog.h" #include "PFitOutputHandler.h" #include "PPrefsDialog.h" #include "PGetDefaultDialog.h" @@ -104,6 +106,7 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name ) fAdmin = new PAdmin(); fMsr2DataParam = 0; + fFindReplaceData = 0, fKeepMinuit2Output = false; fDump = 0; // 0 = no dump, 1 = ascii dump, 2 = root dump @@ -142,6 +145,10 @@ PTextEdit::~PTextEdit() delete fMsr2DataParam; fMsr2DataParam = 0; } + if (fFindReplaceData) { + delete fFindReplaceData; + fFindReplaceData = 0; + } } //---------------------------------------------------------------------------------------------------- @@ -710,6 +717,40 @@ void PTextEdit::editPaste() */ void PTextEdit::editFind() { + if ( !currentEditor() ) + return; + + // check if first time called, and if yes create find and replace data structure + if (fFindReplaceData == 0) { + fFindReplaceData = new PFindReplaceData(); + fFindReplaceData->findText = QString(""); + fFindReplaceData->replaceText = QString(""); + fFindReplaceData->caseSensitive = true; + fFindReplaceData->wholeWordsOnly = false; + fFindReplaceData->fromCursor = true; + fFindReplaceData->findBackwards = false; + fFindReplaceData->selectedText = false; + fFindReplaceData->promptOnReplace = true; + } + + if (fFindReplaceData == 0) { + QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); + return; + } + + PFindDialog *dlg = new PFindDialog(fFindReplaceData); + + dlg->exec(); + + if (dlg->result() != QDialog::Accepted) { + delete dlg; + return; + } + + fFindReplaceData = dlg->getData(); + + delete dlg; + QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok); } @@ -737,6 +778,39 @@ void PTextEdit::editFindPrevious() */ void PTextEdit::editFindAndReplace() { + if ( !currentEditor() ) + return; + + // check if first time called, and if yes create find and replace data structure + if (fFindReplaceData == 0) { + fFindReplaceData = new PFindReplaceData(); + fFindReplaceData->findText = QString(""); + fFindReplaceData->replaceText = QString(""); + fFindReplaceData->caseSensitive = true; + fFindReplaceData->wholeWordsOnly = false; + fFindReplaceData->fromCursor = true; + fFindReplaceData->findBackwards = false; + fFindReplaceData->selectedText = false; + fFindReplaceData->promptOnReplace = true; + } + + if (fFindReplaceData == 0) { + QMessageBox::critical(this, "**ERROR**", "Couldn't invoke find&replace dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton); + return; + } + + PReplaceDialog *dlg = new PReplaceDialog(fFindReplaceData); + + dlg->exec(); + + if (dlg->result() != QDialog::Accepted) { + delete dlg; + return; + } + + fFindReplaceData = dlg->getData(); + + delete dlg; QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok); } diff --git a/src/musrgui/PTextEdit.h b/src/musrgui/PTextEdit.h index e87a08ef..92b5bfdb 100644 --- a/src/musrgui/PTextEdit.h +++ b/src/musrgui/PTextEdit.h @@ -113,6 +113,7 @@ private: int fDump; PMsr2DataParam *fMsr2DataParam; + PFindReplaceData *fFindReplaceData; QComboBox *fComboFont; QComboBox *fComboSize; diff --git a/src/musrgui/musrgui.h b/src/musrgui/musrgui.h index 742389c6..4c6fa7e2 100644 --- a/src/musrgui/musrgui.h +++ b/src/musrgui/musrgui.h @@ -50,4 +50,15 @@ typedef struct { bool chainFit; } PMsr2DataParam; +typedef struct { + QString findText; + QString replaceText; + bool caseSensitive; + bool wholeWordsOnly; + bool fromCursor; + bool findBackwards; + bool selectedText; + bool promptOnReplace; +} PFindReplaceData; + #endif // _MUSRGUI_H_ diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index 8648a4ea..79ca0c26 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -17,6 +17,8 @@ HEADERS = musrgui.h \ PTextEdit.h \ PSubTextEdit.h \ PAdmin.h \ + PFindDialog.h \ + PReplaceDialog.h \ PFitOutputHandler.h \ PPrefsDialog.h \ PGetDefaultDialog.h \ @@ -33,6 +35,8 @@ HEADERS = musrgui.h \ SOURCES = PTextEdit.cpp \ PSubTextEdit.cpp \ PAdmin.cpp \ + PFindDialog.cpp \ + PReplaceDialog.cpp \ PFitOutputHandler.cpp \ PPrefsDialog.cpp \ PGetDefaultDialog.cpp \ @@ -47,7 +51,9 @@ SOURCES = PTextEdit.cpp \ PMsr2DataDialog.cpp \ main.cpp -FORMS = forms/PGetDefaultDialogBase.ui \ +FORMS = forms/PFindDialogBase.ui \ + forms/PReplaceDialogBase.ui \ + forms/PGetDefaultDialogBase.ui \ forms/PMusrGuiAbout.ui \ forms/PPrefsDialogBase.ui \ forms/PGetTitleDialog.ui \