diff --git a/Viewer/ecflowUI/src/SessionDialog.cpp b/Viewer/ecflowUI/src/SessionDialog.cpp
index ee97e606b..156ad15b1 100644
--- a/Viewer/ecflowUI/src/SessionDialog.cpp
+++ b/Viewer/ecflowUI/src/SessionDialog.cpp
@@ -30,18 +30,20 @@ SessionDialog::SessionDialog(QWidget* parent) : QDialog(parent) {
// what was saved last time?
std::string lastSessionName = SessionHandler::instance()->lastSessionName();
int index = SessionHandler::instance()->indexFromName(lastSessionName);
- if (index != -1)
+ if (index != -1) {
savedSessionsList_->setCurrentItem(savedSessionsList_->topLevelItem(index)); // select this one in the table
+ }
- if (SessionHandler::instance()->loadLastSessionAtStartup())
+ if (SessionHandler::instance()->loadLastSessionAtStartup()) {
restoreLastSessionCb_->setCheckState(Qt::Checked);
- else
+ }
+ else {
restoreLastSessionCb_->setCheckState(Qt::Unchecked);
+ }
newButton_->setVisible(false); // XXX TODO: enable New Session functionality
// ensure the correct state of the Save button
- on_sessionNameEdit__textChanged();
setButtonsEnabledStatus();
}
@@ -101,39 +103,7 @@ void SessionDialog::setButtonsEnabledStatus() {
cloneButton_->setEnabled(true);
}
}
-
-bool SessionDialog::validSaveName(const std::string& /*name*/) {
- /*
- QString boxName(QObject::tr("Save session"));
- // name empty?
- if (name.empty())
- {
- QMessageBox::critical(0,boxName, tr("Please enter a name for the session"));
- return false;
- }
-
-
- // is there already a session with this name?
- bool sessionWithThisName = (SessionHandler::instance()->find(name) != NULL);
-
- if (sessionWithThisName)
- {
- QMessageBox::critical(0,boxName, tr("A session with that name already exists - please choose another
- name")); return false;
- }
- else
- {
- return true;
- }*/
- return true;
-}
-
-void SessionDialog::on_sessionNameEdit__textChanged() {
- // only allow to save a non-empty session name
- // saveButton_->setEnabled(!sessionNameEdit_->text().isEmpty());
-}
-
-void SessionDialog::on_savedSessionsList__currentRowChanged(int /*currentRow*/) {
+void SessionDialog::on_savedSessionsList__currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous) {
setButtonsEnabledStatus();
}
@@ -142,6 +112,7 @@ void SessionDialog::on_cloneButton__clicked() {
assert(!sessionName.empty()); // it should not be possible for the name to be empty
SessionRenameDialog renameDialog;
+ renameDialog.setWindowTitle("Clone Session");
renameDialog.exec();
int result = renameDialog.result();
@@ -176,6 +147,7 @@ void SessionDialog::on_renameButton__clicked() {
assert(item); // it should not be possible for the name to be empty
SessionRenameDialog renameDialog;
+ renameDialog.setWindowTitle("Rename Session");
renameDialog.exec();
int result = renameDialog.result();
@@ -202,25 +174,3 @@ void SessionDialog::on_switchToButton__clicked() {
accept(); // close the dialogue and continue loading the main user interface
}
-
-void SessionDialog::on_saveButton__clicked() {
- /*
- std::string name = sessionNameEdit_->text().toStdString();
-
- if (validSaveName(name))
- {
- SessionItem* newSession =
- SessionHandler::instance()->copySession(SessionHandler::instance()->current(), name); if (newSession)
- {
- //SessionHandler::instance()->add(name);
- refreshListOfSavedSessions();
- SessionHandler::instance()->current(newSession);
- QMessageBox::information(0,tr("Session"), tr("Session saved"));
- }
- else
- {
- QMessageBox::critical(0,tr("Session"), tr("Failed to save session"));
- }
- close();
- }*/
-}
diff --git a/Viewer/ecflowUI/src/SessionDialog.hpp b/Viewer/ecflowUI/src/SessionDialog.hpp
index 7eb0266e6..d5772bfcd 100644
--- a/Viewer/ecflowUI/src/SessionDialog.hpp
+++ b/Viewer/ecflowUI/src/SessionDialog.hpp
@@ -28,9 +28,7 @@ class SessionDialog : public QDialog, protected Ui::SessionDialog {
~SessionDialog() override;
public Q_SLOTS:
- void on_saveButton__clicked();
- void on_sessionNameEdit__textChanged();
- void on_savedSessionsList__currentRowChanged(int currentRow);
+ void on_savedSessionsList__currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void on_cloneButton__clicked();
void on_deleteButton__clicked();
void on_renameButton__clicked();
@@ -39,7 +37,6 @@ public Q_SLOTS:
private:
// Ui::SaveSessionAsDialog *ui;
void addSessionToTable(SessionItem* s);
- bool validSaveName(const std::string& name);
void refreshListOfSavedSessions();
void setButtonsEnabledStatus();
std::string selectedSessionName();
diff --git a/Viewer/ecflowUI/src/SessionHandler.cpp b/Viewer/ecflowUI/src/SessionHandler.cpp
index cd46cec57..d96498efe 100644
--- a/Viewer/ecflowUI/src/SessionHandler.cpp
+++ b/Viewer/ecflowUI/src/SessionHandler.cpp
@@ -36,6 +36,13 @@ SessionItem::~SessionItem() {
}
}
+void SessionItem::name(const std::string& name) {
+ name_ = name;
+ // Since the name changes, we need to update the related directory paths
+ dirPath_ = SessionHandler::sessionDirName(name_);
+ qtPath_ = SessionHandler::sessionQtDirName(name_);
+}
+
void SessionItem::checkDir() {
dirPath_ = SessionHandler::sessionDirName(name_);
DirectoryHandler::createDir(dirPath_);
diff --git a/Viewer/ecflowUI/src/SessionHandler.hpp b/Viewer/ecflowUI/src/SessionHandler.hpp
index 47fa68c48..e114c21ad 100644
--- a/Viewer/ecflowUI/src/SessionHandler.hpp
+++ b/Viewer/ecflowUI/src/SessionHandler.hpp
@@ -21,7 +21,7 @@ class SessionItem {
explicit SessionItem(const std::string&);
virtual ~SessionItem();
- void name(const std::string& name) { name_ = name; }
+ void name(const std::string& name);
const std::string& name() const { return name_; }
std::string sessionFile() const;
diff --git a/Viewer/ecflowUI/src/SessionRenameDialog.ui b/Viewer/ecflowUI/src/SessionRenameDialog.ui
index a82d3c899..b30228fd4 100644
--- a/Viewer/ecflowUI/src/SessionRenameDialog.ui
+++ b/Viewer/ecflowUI/src/SessionRenameDialog.ui
@@ -11,7 +11,7 @@
- Add variable
+
true
@@ -26,7 +26,7 @@
- New name:
+