diff --git a/src/musrgui/PAdmin.cpp b/src/musrgui/PAdmin.cpp index 987ce5af..46305472 100644 --- a/src/musrgui/PAdmin.cpp +++ b/src/musrgui/PAdmin.cpp @@ -80,10 +80,6 @@ bool PAdminXMLParser::startElement( const QString&, const QString&, fKeyWord = eFileFormat; } else if (qName == "msr_default_file_path") { fKeyWord = eMsrDefaultFilePath; - } else if (qName == "show_mlog") { - fKeyWord = eShowMlog; - } else if (qName == "open_mlog_after_fit") { - fKeyWord = eOpenMlogAfterFit; } return true; @@ -127,18 +123,6 @@ bool PAdminXMLParser::characters(const QString& str) case eMsrDefaultFilePath: fAdmin->setMsrDefaultFilePath(QString(str.ascii()).stripWhiteSpace()); break; - case eShowMlog: - if (str == "n") - fAdmin->setShowMlog(false); - else - fAdmin->setShowMlog(true); - break; - case eOpenMlogAfterFit: - if (str == "n") - fAdmin->setOpenMlogAfterFit(false); - else - fAdmin->setOpenMlogAfterFit(true); - break; default: break; } @@ -172,9 +156,6 @@ PAdmin::PAdmin() fInstitute = QString(""); fFileFormat = QString(""); - fShowMlog = true; - fOpenMlogAfterFit = true; - // XML Parser part QString path = getenv("MUSRFITPATH"); if (path.isEmpty()) diff --git a/src/musrgui/PAdmin.h b/src/musrgui/PAdmin.h index 54762508..71c67190 100644 --- a/src/musrgui/PAdmin.h +++ b/src/musrgui/PAdmin.h @@ -47,7 +47,7 @@ class PAdminXMLParser : public QXmlDefaultHandler private: enum EAdminKeyWords {eEmpty, eExecPath, eDefaultSavePath, eBeamline, eInstitute, eFileFormat, - eMsrDefaultFilePath, eShowMlog, eOpenMlogAfterFit}; + eMsrDefaultFilePath}; bool startDocument(); bool startElement( const QString&, const QString&, const QString& , @@ -74,8 +74,6 @@ class PAdmin QString getInstitute() { return fInstitute; } QString getFileFormat() { return fFileFormat; } QString getMsrDefaultFilePath() { return fMsrDefaultFilePath; } - bool getShowMlog() { return fShowMlog; } - bool getOpenMlogAfterFit() { return fOpenMlogAfterFit; } protected: void setExecPath(const QString str) { fExecPath = str; } @@ -84,8 +82,6 @@ class PAdmin void setInstitute(const QString str) { fInstitute = str; } void setFileFormat(const QString str) { fFileFormat = str; } void setMsrDefaultFilePath(const QString str) { fMsrDefaultFilePath = str; } - void setShowMlog(const bool flag) { fShowMlog = flag; } - void setOpenMlogAfterFit(const bool flag) { fOpenMlogAfterFit = flag; } private: friend class PAdminXMLParser; @@ -98,8 +94,6 @@ class PAdmin QString fFileFormat; QString fMsrDefaultFilePath; - bool fShowMlog; - bool fOpenMlogAfterFit; }; #endif // _PADMIN_H_ diff --git a/src/musrgui/PPrefsDialog.cpp b/src/musrgui/PPrefsDialog.cpp index b7b9cb80..a473e173 100644 --- a/src/musrgui/PPrefsDialog.cpp +++ b/src/musrgui/PPrefsDialog.cpp @@ -35,18 +35,13 @@ /** *
*/ -PPrefsDialog::PPrefsDialog(const bool keep_mn2_output, const bool open_mlog_after_fit, const int dump_tag) +PPrefsDialog::PPrefsDialog(const bool keep_mn2_output, const int dump_tag) { if (keep_mn2_output) fKeepMn2Output_checkBox->setChecked(true); else fKeepMn2Output_checkBox->setChecked(false); - if (open_mlog_after_fit) - fOpenMlogAfterFit_checkBox->setChecked(true); - else - fOpenMlogAfterFit_checkBox->setChecked(false); - if (dump_tag == 1) { fDumpAscii_checkBox->setChecked(true); fDumpRoot_checkBox->setChecked(false); diff --git a/src/musrgui/PPrefsDialog.h b/src/musrgui/PPrefsDialog.h index bb1671e3..0b67289d 100644 --- a/src/musrgui/PPrefsDialog.h +++ b/src/musrgui/PPrefsDialog.h @@ -39,10 +39,9 @@ class PPrefsDialog : public PPrefsDialogBase { public: - PPrefsDialog(const bool keep_mn2_output, const bool open_mlog_after_fit, const int dump_tag); + PPrefsDialog(const bool keep_mn2_output, const int dump_tag); bool keepMinuit2Output() { return fKeepMn2Output_checkBox->isChecked(); } - bool openMlogAfterFit() { return fOpenMlogAfterFit_checkBox->isChecked(); } int getDump(); public slots: diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp index 19683a40..d7a4f739 100644 --- a/src/musrgui/PTextEdit.cpp +++ b/src/musrgui/PTextEdit.cpp @@ -103,8 +103,6 @@ PTextEdit::PTextEdit( QWidget *parent, const char *name ) { fAdmin = new PAdmin(); - fShowMlog = fAdmin->getShowMlog(); - fOpenMlogAfterFit = fAdmin->getOpenMlogAfterFit(); fKeepMinuit2Output = false; fDump = 0; // 0 = no dump, 1 = ascii dump, 2 = root dump @@ -272,6 +270,11 @@ void PTextEdit::setupMusrActions() a->addTo( tb ); a->addTo( menu ); + a = new QAction( QPixmap::fromMimeSource( "musrswap.xpm" ), tr( "&Swap Msr <-> Mlog" ), ALT + Key_S, this, "musrSwapMsrMlog" ); + connect( a, SIGNAL( activated() ), this, SLOT( musrSwapMsrMlog() ) ); + a->addTo( tb ); + a->addTo( menu ); + a = new QAction( QPixmap::fromMimeSource( "musrmlog2db.xpm" ), tr( "&Mlog2dB" ), ALT + Key_M, this, "musrMlog2Db" ); connect( a, SIGNAL( activated() ), this, SLOT( musrMlog2Db() ) ); a->addTo( tb ); @@ -293,17 +296,6 @@ void PTextEdit::setupMusrActions() connect( a, SIGNAL( activated() ), this, SLOT( musrPrefs() ) ); a->addTo( tb ); a->addTo( menu ); - - fComboShowMlog = new QComboBox( TRUE, tb ); - fComboShowMlog->setEditable(false); - fComboShowMlog->insertItem("view mlog"); - fComboShowMlog->insertItem("view msr"); - connect( fComboShowMlog, SIGNAL( activated( const QString & ) ), - this, SLOT( musrShowMlog( const QString & ) ) ); - if (fShowMlog) - fComboShowMlog->setCurrentItem(0); - else - fComboShowMlog->setCurrentItem(1); } //---------------------------------------------------------------------------------------------------- @@ -870,6 +862,8 @@ void PTextEdit::musrFit() fitOutputHandler.setModal(true); fitOutputHandler.exec(); + musrSwapMsrMlog(); +/* if (fOpenMlogAfterFit) { // get current file name and replace the msr-extension through mlog str = fTabWidget->label(fTabWidget->currentPageIndex()); @@ -888,6 +882,7 @@ void PTextEdit::musrFit() // open mlog files load(str); } +*/ } //---------------------------------------------------------------------------------------------------- @@ -1059,11 +1054,6 @@ void PTextEdit::musrView() cmd = str + " "; str = *fFilenames.find( currentEditor() ); - if (fShowMlog) { - int idx = str.find(".msr"); - if (idx > 0) - str.replace(idx, 4, ".mlog"); - } cmd += str + " &"; system(cmd.latin1()); @@ -1089,11 +1079,10 @@ void PTextEdit::musrT0() */ void PTextEdit::musrPrefs() { - PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fOpenMlogAfterFit, fDump); + PPrefsDialog *dlg = new PPrefsDialog(fKeepMinuit2Output, fDump); if (dlg->exec() == QDialog::Accepted) { fKeepMinuit2Output = dlg->keepMinuit2Output(); - fOpenMlogAfterFit = dlg->openMlogAfterFit(); fDump = dlg->getDump(); } } @@ -1102,12 +1091,74 @@ void PTextEdit::musrPrefs() /** *
*/
-void PTextEdit::musrShowMlog( const QString &str )
+void PTextEdit::musrSwapMsrMlog()
{
- if (str.find("mlog") > 0)
- fShowMlog = true;
- else
- fShowMlog = false;
+ if ( !currentEditor() )
+ return;
+
+ // get current file name
+ QString currentFileName = *fFilenames.find( currentEditor() );
+ QString swapFileName;
+ QString tempFileName = QString("__swap__.msr");
+
+ // check if it is a msr-, mlog-, or another file
+ int idx;
+ if ((idx = currentFileName.find(".msr")) > 0) { // msr-file
+ swapFileName = currentFileName;
+ swapFileName.replace(idx, 5, ".mlog");
+ } else if ((idx = currentFileName.find(".mlog")) > 0) { // mlog-file
+ swapFileName = currentFileName;
+ swapFileName.replace(idx, 5, ".msr ").stripWhiteSpace();
+ } else { // neither a msr- nor a mlog-file
+ QMessageBox::information( this, "musrSwapMsrMlog",
+ "This is neither a msr- nor a mlog-file, hence nothing to be swapped.\n",
+ QMessageBox::Ok );
+ return;
+ }
+
+ // check if the swapFile exists
+ if (!QFile::exists(swapFileName)) {
+ QString msg = "swap file '" + swapFileName + "' doesn't exist.\nCannot swap anything.";
+ QMessageBox::warning( this, "musrSwapMsrMlog",
+ msg, QMessageBox::Ok, QMessageBox::NoButton );
+ return;
+ }
+
+ // check if the file needs to be saved
+ if (fTabWidget->label(fTabWidget->currentPageIndex()).find("*") > 0) { // needs to be saved first
+ fileSave();
+ }
+
+ // swap files
+ QString cmd;
+ cmd = QString("cp ") + currentFileName + QString(" ") + tempFileName;
+ system(cmd.latin1());
+ cmd = QString("cp ") + swapFileName + QString(" ") + currentFileName;
+ system(cmd.latin1());
+ cmd = QString("cp ") + tempFileName + QString(" ") + swapFileName;
+ system(cmd.latin1());
+ cmd = QString("rm ") + tempFileName;
+ system(cmd.latin1());
+
+ // reload current file
+ fileClose();
+ load(currentFileName);
+
+ // check if swap file is open as well, and if yes, reload it
+ idx = -1;
+ for (int i=0; i