Commit 0c24b729 authored by Stan Hammon's avatar Stan Hammon
Browse files

Jobs Panel is now shown / hidden based on whether a Project is currently loaded

parent ac4d443d
......@@ -11,6 +11,7 @@
#include "plugin/pqACE3PSaveBehavior.h"
#include "plugin/pqACE3PStagesBehavior.h"
#include "plugin/pqACE3PJobsBehavior.h"
#include "smtk/simulation/ace3p/qt/qtProjectRuntime.h"
// SMTK
......@@ -95,8 +96,9 @@ void pqACE3PCloseBehavior::closeProject()
return;
}
// hide the Stages panel when no project is active
// hide the Stages & Jobs panels when no project is active
pqACE3PStagesBehavior::instance()->setPanelVisible(false);
pqACE3PJobsBehavior::instance()->setPanelVisible(false);
// Check if project is modified
if (!project->clean())
......
......@@ -10,6 +10,7 @@
#include "pqACE3PJobsBehavior.h"
#include "smtk/simulation/ace3p/qt/qtJobsWidget.h"
#include "plugin/pqACE3PJobsPanel.h"
#include "pqCoreUtilities.h"
......@@ -62,6 +63,16 @@ pqACE3PJobsBehavior::~pqACE3PJobsBehavior()
QObject::disconnect(this);
}
void pqACE3PJobsBehavior::hideJobsPanel()
{
this->setPanelVisible(false);
}
void pqACE3PJobsBehavior::setPanelVisible(bool bVisible)
{
m_jobsPanel->setVisible(bVisible);
}
void pqACE3PJobsBehavior::showWidget()
{
m_jobsWidget->show();
......
......@@ -16,6 +16,8 @@
// Qt includes
#include <QObject>
class pqACE3PJobsPanel;
namespace smtk
{
namespace simulation
......@@ -55,6 +57,12 @@ public:
static pqACE3PJobsBehavior* instance(QObject* parent = nullptr);
~pqACE3PJobsBehavior() override;
/** \brief Sets pointer for the Jobs Panel (used to change its visibility). */
void setJobsPanelPointer(pqACE3PJobsPanel * jobsPanel){ m_jobsPanel = jobsPanel; }
/** \brief Shows/hides Stages widget panel. */
void setPanelVisible(bool bVisible);
/** \brief Opens or raises the Jobs widget. */
void showWidget();
......@@ -64,6 +72,9 @@ public slots:
/** \brief Notifies jobs widget that a job's data has been overwritten */
void onJobOverwritten(const QString& jobId);
/** \brief Hides the Jobs Panel - a special case of setPanelVisible(). */
void hideJobsPanel();
protected:
pqACE3PJobsBehavior(QObject* parent = nullptr);
......@@ -71,6 +82,8 @@ protected:
private:
Q_DISABLE_COPY(pqACE3PJobsBehavior);
pqACE3PJobsPanel * m_jobsPanel;
};
#endif
......@@ -47,57 +47,41 @@ pqACE3PJobsPanel::pqACE3PJobsPanel(QWidget* parent)
m_jobWidget = jobsBehavior->jobsWidget();
this->setWidget(m_jobWidget);
jobsBehavior->setJobsPanelPointer(this);
auto smtkBehavior = pqSMTKBehavior::instance();
// Now listen for future connections.
QObject::connect(
smtkBehavior,
SIGNAL(removingManagerFromServer(pqSMTKWrapper*, pqServer*)),
this,
SLOT(sourceRemoved(pqSMTKWrapper*, pqServer*)));
QObject::connect(smtkBehavior, SIGNAL(removingManagerFromServer(pqSMTKWrapper*, pqServer*)),
this, SLOT(sourceRemoved(pqSMTKWrapper*, pqServer*)));
auto creater = pqACE3PNewProjectBehavior::instance();
QObject::connect(
creater,
&pqACE3PNewProjectBehavior::projectCreated,
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::setProject);
QObject::connect(creater, &pqACE3PNewProjectBehavior::projectCreated,
m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::setProject);
auto loader = pqACE3PProjectLoader::instance();
QObject::connect(
loader,
&pqACE3PProjectLoader::projectOpened,
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::setProject);
QObject::connect(loader, &pqACE3PProjectLoader::projectOpened,
m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::setProject);
auto exporter = pqACE3PExportBehavior::instance();
auto closer = pqACE3PCloseBehavior::instance();
QObject::connect(
closer,
&pqACE3PCloseBehavior::projectClosed,
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::onProjectClosed);
QObject::connect(
exporter,
&pqACE3PExportBehavior::jobAdded,
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::onJobAdded);
QObject::connect(closer, &pqACE3PCloseBehavior::projectClosed,
m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::onProjectClosed);
QObject::connect(exporter, &pqACE3PExportBehavior::jobAdded,
m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::onJobAdded);
// connect navigation buttons to nersc file browser
auto nerscBrowserInstance = pqNerscFileBrowserBehavior::instance();
auto nerscBrowserWidget = nerscBrowserInstance->getBrowser();
QObject::connect(
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::requestNavigateDir,
nerscBrowserWidget,
&newt::qtNewtFileBrowserWidget::onRequestNavigate);
QObject::connect(m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::requestNavigateDir,
nerscBrowserWidget, &newt::qtNewtFileBrowserWidget::onRequestNavigate);
auto jobLoader = pqACE3PJobLoader::instance();
QObject::connect(
m_jobWidget,
&smtk::simulation::ace3p::qtJobsWidget::requestLoadJob,
jobLoader,
&pqACE3PJobLoader::openModeSelectDialog);
QObject::connect( m_jobWidget, &smtk::simulation::ace3p::qtJobsWidget::requestLoadJob,
jobLoader, &pqACE3PJobLoader::openModeSelectDialog);
// hide the panel upon startup (only really required once - upon very first program load)
QTimer::singleShot( 50, jobsBehavior, &pqACE3PJobsBehavior::hideJobsPanel);
}
pqACE3PJobsPanel::~pqACE3PJobsPanel()
......
......@@ -10,6 +10,7 @@
#include "plugin/pqACE3PNewProjectBehavior.h"
#include "plugin/pqACE3PStagesBehavior.h"
#include "plugin/pqACE3PJobsBehavior.h"
// Local includes
#include "smtk/simulation/ace3p/Metadata.h"
......@@ -263,5 +264,8 @@ void pqACE3PNewProjectBehavior::newProject()
// set visibility of the Stages panel based on number of Stages present
pqACE3PStagesBehavior::instance()->updateStagesPanelVisibility(project);
// set the Jobs panel visible
pqACE3PJobsBehavior::instance()->setPanelVisible(true);
return;
} // newProject()
......@@ -13,6 +13,7 @@
#include "smtk/simulation/ace3p/Metadata.h"
#include "smtk/simulation/ace3p/operations/Read.h"
#include "plugin/pqACE3PStagesBehavior.h"
#include "plugin/pqACE3PJobsBehavior.h"
#include "smtk/simulation/ace3p/qt/qtProjectRuntime.h"
#include "smtk/simulation/ace3p/qt/qtStagesWidget.h"
......@@ -137,6 +138,9 @@ bool pqACE3PProjectLoader::load(pqServer* server, const QString& directoryPath)
auto ace3pProject = std::dynamic_pointer_cast<smtk::simulation::ace3p::Project>(project);
pqACE3PStagesBehavior::instance()->updateStagesPanelVisibility(ace3pProject);
// set the Jobs panel visible
pqACE3PJobsBehavior::instance()->setPanelVisible(true);
qInfo() << "Opened project" << project->name().c_str();
emit this->projectOpened(project);
......
......@@ -333,6 +333,8 @@ void qtJobsModel::addTestJob()
<< "to stage" << m_project->currentStageIndex() << done;
this->endInsertRows();
m_project->setClean(false);
for (int i=0; i<m_project->numberOfStages(); i++)
{
qDebug() << "Stage" << i << "number of jobs" << m_project->stage(i)->jobIds().size();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment