msr2data global option handling completed.

This commit is contained in:
nemu 2010-06-28 06:31:35 +00:00
parent 20bb0e05a6
commit acc389a96d
4 changed files with 94 additions and 82 deletions

View File

@ -276,21 +276,6 @@ void PMsr2DataDialog::fitOnlyChanged(int buttonState)
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>SLOT: called when the 'Global' QCheckBox under 'Options' is activated.
* Sets at the same time the fit-only flag to false.
*
* \param buttonState state of the button.
*/
void PMsr2DataDialog::globalChanged(int buttonState)
{
if (buttonState == Qt::Checked) {
fFitOnly_checkBox->setChecked(false);
fOpenFilesAfterFitting_checkBox->setChecked(false);
}
}
//----------------------------------------------------------------------------------------------------
/**
* <p>Generates a help content window showing the description for msr2data.

View File

@ -60,7 +60,6 @@ class PMsr2DataDialog : public QDialog, private Ui::PMsr2DataDialog
void templateRunEntered(const QString&);
void createMsrFileOnlyChanged(int);
void fitOnlyChanged(int);
void globalChanged(int);
void helpContent();
private:

View File

@ -1904,6 +1904,8 @@ void PTextEdit::musrMsr2Data()
QFile *file;
QTextStream *stream;
if (!fMsr2DataParam->global) { // standard fits
switch(dlg->getRunTag()) {
case 0: // first run / last run list
if (fMsr2DataParam->firstRun != -1) {
@ -1944,7 +1946,7 @@ void PTextEdit::musrMsr2Data()
while ( !stream->atEnd() ) {
str = stream->readLine(); // line of text excluding '\n'
str.trimmed();
if (!str.isEmpty() && !str.startsWith("#")) {
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0);
if (fMsr2DataParam->msrFileExtension.isEmpty())
fln += ".msr";
@ -1964,6 +1966,48 @@ void PTextEdit::musrMsr2Data()
default:
break;
}
} else { // global tag set
// get the first run number needed to build the global fit file name
fln = QString("");
switch(dlg->getRunTag()) {
case 0: // first/last run
fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break;
case 1: // run list
fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
break;
case 2: // run list file name
file = new QFile(fMsr2DataParam->runListFileName);
if (!file->open(QIODevice::ReadOnly)) {
str = QString("Couldn't open run list file %1, sorry.").arg(fMsr2DataParam->runListFileName);
QMessageBox::critical(this, "**ERROR**", str.toLatin1(), QMessageBox::Ok, QMessageBox::NoButton);
return;
}
stream = new QTextStream(file);
while ( !stream->atEnd() ) {
str = stream->readLine(); // line of text excluding '\n'
str.trimmed();
if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) {
fln = str.section(' ', 0, 0);
break;
}
}
file->close();
fln += QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr");
// clean up
delete stream;
delete file;
break;
default:
break;
}
load(fln);
}
}
}

View File

@ -369,7 +369,7 @@
<property name="title">
<string>Options</string>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
@ -700,7 +700,7 @@
<hints>
<hint type="sourcelabel">
<x>547</x>
<y>442</y>
<y>440</y>
</hint>
<hint type="destinationlabel">
<x>150</x>
@ -708,22 +708,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>fGlobal_checkBox</sender>
<signal>stateChanged(int)</signal>
<receiver>PMsr2DataDialog</receiver>
<slot>globalChanged(int)</slot>
<hints>
<hint type="sourcelabel">
<x>398</x>
<y>479</y>
</hint>
<hint type="destinationlabel">
<x>372</x>
<y>520</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>helpContent()</slot>