some more work towards find and replace

This commit is contained in:
nemu 2009-05-08 07:14:08 +00:00
parent 93be382bb5
commit 8d75a68ad9
8 changed files with 307 additions and 1 deletions

View File

@ -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"
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PFindDialog::PFindDialog(PFindReplaceData *data, QWidget *parent, const char *name, bool modal, WFlags f) :
PFindDialogBase(parent, name, modal, f), fData(data)
{
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PFindReplaceData* PFindDialog::getData()
{
return fData;
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

53
src/musrgui/PFindDialog.h Normal file
View File

@ -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_

View File

@ -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"
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PReplaceDialog::PReplaceDialog(PFindReplaceData *data, QWidget *parent, const char *name, bool modal, WFlags f) :
PReplaceDialogBase(parent, name, modal, f), fData(data)
{
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PFindReplaceData* PReplaceDialog::getData()
{
return fData;
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -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_

View File

@ -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);
}

View File

@ -113,6 +113,7 @@ private:
int fDump;
PMsr2DataParam *fMsr2DataParam;
PFindReplaceData *fFindReplaceData;
QComboBox *fComboFont;
QComboBox *fComboSize;

View File

@ -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_

View File

@ -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 \