From b9dfb1bff573d064acf8cc9ee41f796a1efcaee1 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 13 Dec 2006 00:14:00 +0000 Subject: [PATCH] try to reduce number of moveToThread warnings I went off on a fools errand of trying to get rid of the QObject::moveToThread warnings that Qt was spitting out when trying to prepare an icon. Qt does prefer widgets to be dynamically constructed and to have their parent widget set, which is what I tried to do to cut down on the useless chatter. (Note the chatter only happens on OS X when the frameworks have been installed into the application bundle). --- qui/MussaWindow.cpp | 49 ++++++++++---------- qui/MussaWindow.hpp | 2 + qui/ThresholdWidget.cpp | 17 +++++-- qui/ThresholdWidget.hpp | 1 + qui/ZoomWidget.cpp | 5 +- qui/motif_editor/MotifEditor.cpp | 21 +++++++-- qui/motif_editor/MotifEditor.hpp | 2 + qui/mussa_setup_dialog/MussaSetupWidget.cpp | 8 +++- qui/mussa_setup_dialog/MussaSetupWidget.hpp | 1 - qui/mussagl.cpp | 10 ++-- qui/seqbrowser/ScrollableSequenceBrowser.cpp | 36 +++++++------- qui/seqbrowser/ScrollableSequenceBrowser.hpp | 8 ++-- qui/seqbrowser/SequenceBrowser.cpp | 13 ++++-- qui/seqbrowser/SequenceBrowserWidget.cpp | 19 +++++--- 14 files changed, 118 insertions(+), 74 deletions(-) diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index 11eb02f..2342ee7 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -35,14 +35,12 @@ using namespace std; MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) : QMainWindow(parent), analysis(analysis_), - default_dir(new QDir(QDir::home().absolutePath())), motif_editor(0), - setup_analysis_dialog(new MussaSetupDialog(this)), - subanalysis_window(new SubanalysisWindow(analysis)), - browser(new SequenceBrowserWidget(default_dir, this)), - mussaViewTB(new QToolBar("Path Views")), - zoom(new ZoomWidget), - threshold(new ThresholdWidget), + setup_analysis_dialog(0), + browser(0), + mussaViewTB(0), + zoom(0), + threshold(0), progress_dialog(0), aboutAction(0), closeAction(0), @@ -62,14 +60,14 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) : viewMussaAlignmentAction(0), manualAssistant(0) { + setupWidgets(); setupActions(); - setupMainMenu(); setupAssistant(); + setupMainMenu(); + + setWindowIcon(QIcon(":/icons/mussa.png")); + default_dir.reset(new QDir(QDir::home().absolutePath())); - //This next setWhatsThis function prevents - // a segfault when using WhatsThis feature with - // opengl widget. - //scene->setWhatsThis(tr("Mussa in OpenGL!")); setCentralWidget(browser); // well updatePosition isn't quite right as we really just need // to call update() @@ -77,19 +75,11 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) : connect(this, SIGNAL(changedMotifs()), this, SLOT(updateAnnotations())); connect(browser, SIGNAL(basepairsCopied(size_t)), this, SLOT(showBasePairsCopied(size_t))); - - //mussaViewTB->addAction(toggleMotifsAction); - mussaViewTB->addWidget(zoom); - connect(zoom, SIGNAL(valueChanged(double)), browser, SLOT(setZoom(double))); - - // threshold range is set in updateAnalysis - - //scene->setClipPlane(20); - // FIXME: for when we get the paths drawn at the appropriate depth - //connect(threshold, SIGNAL(thresholdChanged(int)), - // this, SLOT(setClipPlane(int))); + mussaViewTB->addWidget(zoom); + + // threshold range is set in updateAnalysis connect(threshold, SIGNAL(thresholdChanged(int)), this, SLOT(setSoftThreshold(int))); mussaViewTB->addWidget(threshold); @@ -97,6 +87,7 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) : addToolBar(mussaViewTB); statusBar()->showMessage("Welcome to mussa", 2000); + // FIXME: we should start refactoring the connect call to updateAnalysis or something if (analysis) { connect(analysis.get(), SIGNAL(progress(const QString&, int, int)), @@ -178,7 +169,7 @@ void MussaWindow::setupActions() mussaManualAssistantAction = new QAction(tr("Mussagl Manual..."), this); mussaManualAssistantAction->setIcon(QIcon(":/icons/contents.png")); connect(mussaManualAssistantAction, SIGNAL(triggered()), - this, SLOT(showManual())); + this, SLOT(showManual())); newMussaWindowAction = new QAction(tr("&New Mussa Window"), this); newMussaWindowAction->setStatusTip("open another mussa window to allow comparing results"); @@ -280,6 +271,16 @@ void MussaWindow::setupMainMenu() } } +void MussaWindow::setupWidgets() +{ + setup_analysis_dialog = new MussaSetupDialog; + subanalysis_window.reset(new SubanalysisWindow(analysis)); + browser = new SequenceBrowserWidget(default_dir); + mussaViewTB = new QToolBar("Path Views", this); + zoom = new ZoomWidget(mussaViewTB); + threshold = new ThresholdWidget(mussaViewTB); +} + void MussaWindow::setupAssistant() { #if defined(QT_QTASSISTANT_FOUND) diff --git a/qui/MussaWindow.hpp b/qui/MussaWindow.hpp index 1d6e274..f02f091 100644 --- a/qui/MussaWindow.hpp +++ b/qui/MussaWindow.hpp @@ -150,6 +150,8 @@ protected: void closeEvent(QCloseEvent *event); //! initialize this windows menu object void setupMainMenu(); + //! initialize all of our widgets + void setupWidgets(); //! initialize assistant client void setupAssistant(); //! stub function to fill in QActions diff --git a/qui/ThresholdWidget.cpp b/qui/ThresholdWidget.cpp index fc2444e..5c85696 100644 --- a/qui/ThresholdWidget.cpp +++ b/qui/ThresholdWidget.cpp @@ -9,11 +9,12 @@ // LCDRange.cpp ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max) : QWidget(parent), - layout(new QHBoxLayout(this)), - basepair_spinner(new QSpinBox(this)), - window_size_label(new QLabel(this)), - percent_label(new QLabel(this)) + layout(0), + basepair_spinner(0), + window_size_label(0), + percent_label(0) { + setupWidgets(); basepair_spinner->setWhatsThis("How many base pairs need to be conserved in the window size"); setRange(min, max); @@ -31,6 +32,14 @@ ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max) setLayout(layout); } +void ThresholdWidget::setupWidgets() +{ + layout = new QHBoxLayout(this); + basepair_spinner = new QSpinBox(this); + window_size_label = new QLabel(this); + percent_label = new QLabel(this); +} + void ThresholdWidget::setRange(int min, int max) { basepair_spinner->setRange(min, max); diff --git a/qui/ThresholdWidget.hpp b/qui/ThresholdWidget.hpp index e83c815..47a7778 100644 --- a/qui/ThresholdWidget.hpp +++ b/qui/ThresholdWidget.hpp @@ -38,6 +38,7 @@ signals: void thresholdChanged(int new_threshold); protected: + void setupWidgets(); QHBoxLayout *layout; QSpinBox *basepair_spinner; QLabel *window_size_label; diff --git a/qui/ZoomWidget.cpp b/qui/ZoomWidget.cpp index 2ceba40..f8f856a 100644 --- a/qui/ZoomWidget.cpp +++ b/qui/ZoomWidget.cpp @@ -8,9 +8,10 @@ using namespace std; ZoomWidget::ZoomWidget(QWidget *parent) : QWidget(parent), - zoom(new QDoubleSpinBox), + zoom(0), max_zoom_size(10000) { + zoom = new QDoubleSpinBox(this); zoom->setRange(0.01, max_zoom_size); zoom->setSingleStep(0.1); connect(zoom, SIGNAL(valueChanged(double)), this, SLOT(setValue(double))); @@ -20,7 +21,7 @@ ZoomWidget::ZoomWidget(QWidget *parent) QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(zoomLabel); layout->addWidget(zoom); - layout->addWidget(new QLabel("bp/pix")); + layout->addWidget(new QLabel("bp/pix", this)); setLayout(layout); setToolTip(tr("Zoom")); diff --git a/qui/motif_editor/MotifEditor.cpp b/qui/motif_editor/MotifEditor.cpp index ea10650..f984026 100644 --- a/qui/motif_editor/MotifEditor.cpp +++ b/qui/motif_editor/MotifEditor.cpp @@ -9,13 +9,15 @@ using namespace std; MotifEditor::MotifEditor(MussaRef m, QWidget *parent) : QWidget(parent), analysis(m), - editor_layout(new QVBoxLayout(parent)), - button_layout(new QHBoxLayout(parent)), - table(new QTableView(this)), - delegate(new MotifEditorDelegate(this)), - applyButton(new QPushButton("apply")), + editor_layout(0), + button_layout(0), + table(0), + delegate(0), + applyButton(0), model(0) { + setupWidgets(); + assert (m != 0); const set &motif = analysis->motifs(); vector motif_seq(motif.begin(), motif.end()); @@ -35,6 +37,15 @@ MotifEditor::MotifEditor(MussaRef m, QWidget *parent) updateModel(); } +void MotifEditor::setupWidgets() +{ + editor_layout = new QVBoxLayout(this); + button_layout = new QHBoxLayout(this); + table = new QTableView(this); + delegate = new MotifEditorDelegate(this); + applyButton = new QPushButton("apply"); +} + void MotifEditor::updateModel() { MotifModel *new_model = new MotifModel(analysis); diff --git a/qui/motif_editor/MotifEditor.hpp b/qui/motif_editor/MotifEditor.hpp index 6efe876..aaff9a7 100644 --- a/qui/motif_editor/MotifEditor.hpp +++ b/qui/motif_editor/MotifEditor.hpp @@ -35,6 +35,8 @@ signals: void changedMotifs(); private: + //! initialize all our gui widgets + void setupWidgets(); MussaRef analysis; QPushButton *applyButton; diff --git a/qui/mussa_setup_dialog/MussaSetupWidget.cpp b/qui/mussa_setup_dialog/MussaSetupWidget.cpp index 097e247..ad25e43 100644 --- a/qui/mussa_setup_dialog/MussaSetupWidget.cpp +++ b/qui/mussa_setup_dialog/MussaSetupWidget.cpp @@ -30,7 +30,13 @@ MussaSetupWidget::MussaSetupWidget(QWidget *parent) cancelPushButton(new QPushButton(tr("Cancel"))), seqSetupFrame(0) { - + analysisNameLineEdit = new QLineEdit; + windowEdit = new QSpinBox; + thresholdEdit = new QSpinBox; + numOfSequencesSpinBox = new QSpinBox; + createPushButton = new QPushButton(tr("Create")); + cancelPushButton = new QPushButton(tr("Cancel")); + // Analysis name QLabel *analysisNameLabel = new QLabel(tr("Analysis Name")); analysisNameLabel->setBuddy(analysisNameLineEdit); diff --git a/qui/mussa_setup_dialog/MussaSetupWidget.hpp b/qui/mussa_setup_dialog/MussaSetupWidget.hpp index 4e0a4fd..c63cd9f 100644 --- a/qui/mussa_setup_dialog/MussaSetupWidget.hpp +++ b/qui/mussa_setup_dialog/MussaSetupWidget.hpp @@ -30,7 +30,6 @@ private slots: void updateThreshold(int); private: - QLineEdit *analysisNameLineEdit; QSpinBox *windowEdit; QSpinBox *thresholdEdit; diff --git a/qui/mussagl.cpp b/qui/mussagl.cpp index 54d737b..0795a9a 100644 --- a/qui/mussagl.cpp +++ b/qui/mussagl.cpp @@ -52,18 +52,16 @@ int main(int argc, char **argv) //opts.doc_dir = get_doc_dir(); QApplication app(argc, argv, opts.useGUI); Q_INIT_RESOURCE(icons); - const QIcon mussa_icon(":/icons/mussa.png"); - app.setWindowIcon(mussa_icon); initialize_mussa(opts, argc, argv); if (opts.analysis == 0) { return 1; } - - ThreadManager &thread = ThreadManagerFactory(); + try { #ifdef USE_PYTHON if (opts.runAsPythonInterpeter) { + ThreadManager &thread = ThreadManagerFactory(); // allow the user to keep the interpreter open even after // closing all the windows app.setQuitOnLastWindowClosed(false); @@ -87,8 +85,8 @@ int main(int argc, char **argv) } else #endif /* USE_PYTHON */ if (opts.useGUI) { - MussaWindow win(opts.analysis); - win.show(); + MussaWindow *win = new MussaWindow(opts.analysis); + win->show(); app.exec(); } return 0; diff --git a/qui/seqbrowser/ScrollableSequenceBrowser.cpp b/qui/seqbrowser/ScrollableSequenceBrowser.cpp index ab4ce60..7357af1 100644 --- a/qui/seqbrowser/ScrollableSequenceBrowser.cpp +++ b/qui/seqbrowser/ScrollableSequenceBrowser.cpp @@ -4,17 +4,20 @@ ScrollableSequenceBrowser::ScrollableSequenceBrowser(QWidget *parent) : QWidget(parent), - viewportBar(Qt::Horizontal) + sequence_browser(0), + viewportBar(0) { + QVBoxLayout *layout = new QVBoxLayout(this); + sequence_browser = new SequenceBrowser; + viewportBar = new QScrollBar(Qt::Horizontal); // construct central opengl widget - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(&sequence_browser); - layout->addWidget(&viewportBar); + layout->addWidget(sequence_browser); + layout->addWidget(viewportBar); - connect(&viewportBar, SIGNAL(valueChanged(int)), + connect(viewportBar, SIGNAL(valueChanged(int)), this, SLOT(setViewportCenter(int))); - connect(&sequence_browser, SIGNAL(viewportChanged()), + connect(sequence_browser, SIGNAL(viewportChanged()), this, SLOT(updateScrollBar())); setLayout(layout); @@ -23,26 +26,25 @@ ScrollableSequenceBrowser::ScrollableSequenceBrowser(QWidget *parent) : updateScrollBar(); // enble keyboard input - viewportBar.setFocusPolicy(Qt::StrongFocus); + viewportBar->setFocusPolicy(Qt::StrongFocus); } void ScrollableSequenceBrowser::updateScrollBar() { - thumb = (int)sequence_browser.viewportCenter(); - viewportBar.setRange((int)sequence_browser.left(), - (int)sequence_browser.right()); - viewportBar.setValue(thumb); - viewportBar.setPageStep(static_cast(sequence_browser.viewportWidth())); - int step_size = static_cast(sequence_browser.zoom()); + thumb = (int)sequence_browser->viewportCenter(); + viewportBar->setRange((int)sequence_browser->left(), + (int)sequence_browser->right()); + viewportBar->setValue(thumb); + viewportBar->setPageStep(static_cast(sequence_browser->viewportWidth())); + int step_size = static_cast(sequence_browser->zoom()); step_size = step_size > 1 ? step_size : 1; - viewportBar.setSingleStep(static_cast( step_size )); + viewportBar->setSingleStep(static_cast( step_size )); } void ScrollableSequenceBrowser::setViewportCenter(int x) { if (x != thumb) { thumb = x; - sequence_browser.setViewportCenter(thumb); + sequence_browser->setViewportCenter(thumb); } -} - +} \ No newline at end of file diff --git a/qui/seqbrowser/ScrollableSequenceBrowser.hpp b/qui/seqbrowser/ScrollableSequenceBrowser.hpp index b8a470e..bd5e023 100644 --- a/qui/seqbrowser/ScrollableSequenceBrowser.hpp +++ b/qui/seqbrowser/ScrollableSequenceBrowser.hpp @@ -11,10 +11,10 @@ class ScrollableSequenceBrowser : public QWidget public: ScrollableSequenceBrowser(QWidget *parent=0); - SequenceBrowser sequence_browser; + SequenceBrowser *sequence_browser; - SequenceBrowser& browser() { return sequence_browser; } - const SequenceBrowser& browser() const { return sequence_browser; } + SequenceBrowser& browser() { return *sequence_browser; } + const SequenceBrowser& browser() const { return *sequence_browser; } public slots: //! update the scrollbar with current viewport information void updateScrollBar(); @@ -22,7 +22,7 @@ public slots: void setViewportCenter(int x); private: - QScrollBar viewportBar; + QScrollBar *viewportBar; int thumb; float range; diff --git a/qui/seqbrowser/SequenceBrowser.cpp b/qui/seqbrowser/SequenceBrowser.cpp index 0f2868e..0927cfd 100644 --- a/qui/seqbrowser/SequenceBrowser.cpp +++ b/qui/seqbrowser/SequenceBrowser.cpp @@ -20,11 +20,16 @@ using namespace std; SequenceBrowser::SequenceBrowser(QWidget *parent) : QGLWidget(parent), rubberBand(0), - popupMenu(new QMenu(this)), - copySelectedSequenceAsFastaAction(new QAction(tr("&Copy as Fasta"), this)), - copySelectedSequenceAsStringAction(new QAction(tr("&Copy Sequence"), this)), - editSequencePropertiesAction(new QAction(tr("Sequence &Properties"), this)) + popupMenu(0), + copySelectedSequenceAsFastaAction(0), + copySelectedSequenceAsStringAction(0), + editSequencePropertiesAction(0) { + popupMenu = new QMenu(this); + copySelectedSequenceAsFastaAction = new QAction(tr("&Copy as Fasta"), this); + copySelectedSequenceAsStringAction = new QAction(tr("&Copy Sequence"), this); + editSequencePropertiesAction = new QAction(tr("Sequence &Properties"), this); + connect(copySelectedSequenceAsFastaAction, SIGNAL(triggered()), this, SLOT(copySelectedSequenceAsFasta())); popupMenu->addAction(copySelectedSequenceAsFastaAction); diff --git a/qui/seqbrowser/SequenceBrowserWidget.cpp b/qui/seqbrowser/SequenceBrowserWidget.cpp index e8277d0..3b25b91 100644 --- a/qui/seqbrowser/SequenceBrowserWidget.cpp +++ b/qui/seqbrowser/SequenceBrowserWidget.cpp @@ -23,13 +23,20 @@ SequenceBrowserWidget::SequenceBrowserWidget( QWidget *parent ) : QScrollArea(parent), - default_dir(default_dir_), - left_sidebar(new SequenceBrowserSidebar), - scrollable_browser(new ScrollableSequenceBrowser), - right_sidebar(new SequenceBrowserSidebar), - layout(new QHBoxLayout), - layout_container(new QWidget(this)) + left_sidebar(0), + scrollable_browser(0), + right_sidebar(0), + layout(0), + layout_container(0) { + default_dir = default_dir_; + + layout_container = new QWidget(this); + layout = new QHBoxLayout(layout_container); + left_sidebar = new SequenceBrowserSidebar(layout_container); + scrollable_browser = new ScrollableSequenceBrowser(layout_container); + right_sidebar = new SequenceBrowserSidebar(layout_container); + layout->addWidget(left_sidebar, 0); layout->addWidget(scrollable_browser, 1); layout->addWidget(right_sidebar, 0); -- 2.30.2