From 960e80998b060fd3c0f0d0cf6dce4e6fc219f16f Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Fri, 27 Oct 2006 17:57:05 +0000 Subject: [PATCH] implement set window state ticket:194 basically works, though I need to get mussa to notice when sequence information has been changed. --- alg/mussa.cpp | 30 +++++++++++++++++++----------- alg/mussa.hpp | 4 ++++ qui/MussaWindow.cpp | 11 ++++++++++- qui/MussaWindow.hpp | 2 ++ 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/alg/mussa.cpp b/alg/mussa.cpp index 6978ef2..58558ff 100644 --- a/alg/mussa.cpp +++ b/alg/mussa.cpp @@ -79,7 +79,15 @@ Mussa::clear() the_seqs.clear(); the_paths.clear(); analysis_path = fs::path(); - dirty = false; + set_dirty(false); +} + +void Mussa::set_dirty(bool new_state) +{ + if (dirty != new_state) { + dirty = new_state; + emit isModified(dirty); + } } bool Mussa::is_dirty() const @@ -100,7 +108,7 @@ void Mussa::set_name(string a_name) { analysis_name = a_name; - dirty = true; + set_dirty(true); } string Mussa::get_name() const @@ -133,7 +141,7 @@ void Mussa::set_window(int a_window) { window = a_window; - dirty = true; + set_dirty(true); } int Mussa::get_window() const @@ -145,7 +153,7 @@ void Mussa::set_threshold(int a_threshold) { threshold = a_threshold; - dirty = true; + set_dirty(true); if (a_threshold > soft_thres) { soft_thres = a_threshold; } @@ -177,7 +185,7 @@ void Mussa::set_analysis_mode(enum analysis_modes new_ana_mode) { ana_mode = new_ana_mode; - dirty = true; + set_dirty(true); } enum Mussa::analysis_modes Mussa::get_analysis_mode() const @@ -304,13 +312,13 @@ void Mussa::append_sequence(const Sequence& a_seq) { boost::shared_ptr seq_copy(new Sequence(a_seq)); the_seqs.push_back(seq_copy); - dirty = true; + set_dirty(true); } void Mussa::append_sequence(boost::shared_ptr a_seq) { the_seqs.push_back(a_seq); - dirty = true; + set_dirty(true); } @@ -333,7 +341,7 @@ void Mussa::load_sequence(fs::path seq_file, fs::path annot_file, aseq->set_species(*name); } the_seqs.push_back(aseq); - dirty = true; + set_dirty(true); } void @@ -449,7 +457,7 @@ Mussa::load_mupa_file(fs::path para_file_path) // << " threshold = " << threshold << endl; } // no file was loaded, signal error - dirty = true; + set_dirty(true); } @@ -602,7 +610,7 @@ Mussa::save(fs::path save_path) } } - dirty = false; + set_dirty(false); analysis_path = save_path; } @@ -752,7 +760,7 @@ void Mussa::add_motif(const Sequence& motif, const Color& color) { motif_sequences.insert(motif); color_mapper->appendInstanceColor("motif", motif.get_sequence(), color); - dirty = true; + set_dirty(true); } void Mussa::set_motifs(const vector& motifs, diff --git a/alg/mussa.hpp b/alg/mussa.hpp index 27cd239..e85055d 100644 --- a/alg/mussa.hpp +++ b/alg/mussa.hpp @@ -38,6 +38,8 @@ class Mussa : public QObject signals: //! call whatever signaling system we want void progress(const std::string& description, int cur, int max); + //! triggered when our state changes between unsaved(true) and saved(false) + void isModified(bool); public: typedef std::set motif_set; @@ -100,6 +102,8 @@ public: enum analysis_modes get_analysis_mode() const; //! return a string name for an analysis mode std::string get_analysis_mode_name() const; + //! set our current dirty state + void set_dirty(bool); //! return if we have unsaved changes bool is_dirty() const; //! is there anything loaded into this analysis? diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index df892af..1625984 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -100,6 +100,8 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) : if (analysis) { connect(analysis.get(), SIGNAL(progress(const std::string&, int, int)), this, SLOT(updateProgress(const std::string&, int, int))); + connect(analysis.get(), SIGNAL(isModified(bool)), + this, SLOT(updateAnalysisModified(bool))); } updateTitle(); updateAnalysis(); @@ -793,9 +795,16 @@ MussaWindow::updateProgress(const string& description, int current, int max) qApp->processEvents(); } +void MussaWindow::updateAnalysisModified(bool is_modified) +{ + setWindowModified(is_modified); +} + void MussaWindow::updateTitle() { if (analysis) { - setWindowTitle(analysis->get_title().c_str()); + QString title(analysis->get_title().c_str()); + title += "[*]"; + setWindowTitle(title); } } diff --git a/qui/MussaWindow.hpp b/qui/MussaWindow.hpp index efa3706..acec825 100644 --- a/qui/MussaWindow.hpp +++ b/qui/MussaWindow.hpp @@ -57,6 +57,8 @@ public slots: void saveAnalysis(); //! save an analysis after prompting for new name void saveAnalysisAs(); + //! set the window modified flag + void updateAnalysisModified(bool); //! try to conver the mussa analysis_path to a title void updateTitle(); //\@} -- 2.30.2