From d043c1f562c6554f0fc37f16f3da0777e59b1898 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 2 Oct 2006 23:12:05 +0000 Subject: [PATCH] add updateTitle localize the code for updating the MussaWindow title. --- qui/MussaWindow.cpp | 21 +++++++++++++++++---- qui/MussaWindow.hpp | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index a079974..8fa878e 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -93,6 +93,7 @@ MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) : statusBar()->showMessage("Welcome to mussa", 2000); connect(analysis, SIGNAL(progress(const std::string&, int, int)), this, SLOT(updateProgress(const std::string&, int, int))); + updateTitle(); updateAnalysis(); } @@ -103,7 +104,7 @@ void MussaWindow::setAnalysis(Mussa *new_analysis) clear(); delete analysis; analysis = new_analysis; - setWindowTitle(analysis->get_name().c_str()); + updateTitle(); updateAnalysis(); } } @@ -482,7 +483,7 @@ void MussaWindow::loadMupa() m->load_mupa_file(converted_path); m->analyze(); setAnalysis(m); - setWindowTitle(converted_path.native_file_string().c_str()); + updateTitle(); // grab the path ignoring the mupa file portion default_dir = converted_path.branch_path(); } catch (mussa_load_error e) { @@ -522,11 +523,11 @@ void MussaWindow::loadSavedAnalysis() if (analysis->empty()) { // our current window is empty so load and replace. setAnalysis(m); - setWindowTitle(converted_path.native_file_string().c_str()); + updateTitle(); default_dir = converted_path.branch_path(); } else { MussaWindow *win = new MussaWindow(m); - win->setWindowTitle(converted_path.native_file_string().c_str()); + updateTitle(); win->default_dir = converted_path.branch_path(); win->show(); } @@ -715,3 +716,15 @@ MussaWindow::updateProgress(const string& description, int current, int max) } qApp->processEvents(); } + +void MussaWindow::updateTitle() +{ + if (analysis) { + fs::path analysis_path = analysis->get_analysis_path(); + if (not analysis_path.empty()) { + setWindowTitle(analysis_path.native_file_string().c_str()); + } else if (analysis->get_name().size() > 0) { + setWindowTitle(analysis->get_name().c_str()); + } + } +} diff --git a/qui/MussaWindow.hpp b/qui/MussaWindow.hpp index 83692d3..5adabde 100644 --- a/qui/MussaWindow.hpp +++ b/qui/MussaWindow.hpp @@ -56,6 +56,8 @@ public slots: void saveAnalysis(); //! save an analysis after prompting for new name void saveAnalysisAs(); + //! try to conver the mussa analysis_path to a title + void updateTitle(); //\@} //! \defgroup MotifHandling Handling of motif lists -- 2.30.2