Skip to content

Commit

Permalink
Enable editor for RepeatDateTime
Browse files Browse the repository at this point in the history
Re ECFLOW-1988
  • Loading branch information
marcosbento committed Nov 20, 2024
1 parent 0108071 commit f089f07
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Viewer/ecflowUI/src/RepeatEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,65 @@ void RepeatDateEditor::apply() {
CommandHandler::run(info_, cmd);
}

//================================================================
//
// RepeatDateTimeEditor
//
//================================================================

RepeatDateTimeEditor::RepeatDateTimeEditor(VInfo_ptr info, QWidget* parent) : RepeatEditor(info, parent) {
// if(!repeat_)
// return;

w_->hideRow(w_->valueSpin_);
w_->valueLe_->setText(oriVal_);

connect(w_->valueLe_, SIGNAL(textEdited(QString)), this, SLOT(slotValueEdited(QString)));

checkButtonStatus();
}

void RepeatDateTimeEditor::setValue(QString val) {
w_->valueLe_->setText(val);
}

void RepeatDateTimeEditor::slotValueEdited(QString txt) {
if (isListMode()) {
int row = modelData_.indexOf(txt);
if (row != -1) {
w_->valueView_->setCurrentIndex(model_->index(row, 0));
}
else {
w_->valueView_->clearSelection();
w_->valueView_->setCurrentIndex(QModelIndex());
}
}
checkButtonStatus();
}

void RepeatDateTimeEditor::resetValue() {
w_->valueLe_->setText(oriVal_);
slotValueEdited(oriVal_);
checkButtonStatus();
}

bool RepeatDateTimeEditor::isValueChanged() {
return (oriVal_ != w_->valueLe_->text());
}

void RepeatDateTimeEditor::apply() {
std::string val = w_->valueLe_->text().toStdString();
// std::string name=w_->nameLabel_->text().toStdString();

std::vector<std::string> cmd;
VAttribute::buildAlterCommand(cmd, "change", "repeat", val);
CommandHandler::run(info_, cmd);
}


static AttributeEditorMaker<RepeatIntEditor> makerStr1("repeat_integer");
static AttributeEditorMaker<RepeatStringEditor> makerStr2("repeat_string");
static AttributeEditorMaker<RepeatStringEditor> makerStr3("repeat_enumerated");
static AttributeEditorMaker<RepeatDateEditor> makerStr4("repeat_date");
static AttributeEditorMaker<RepeatStringEditor> makerStr5("repeat_datelist");
static AttributeEditorMaker<RepeatDateTimeEditor> makerStr6("repeat_datetime");
16 changes: 16 additions & 0 deletions Viewer/ecflowUI/src/RepeatEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RepeatEditorWidget : public QWidget, protected Ui::RepeatEditorWidget {
friend class RepeatIntEditor;
friend class RepeatStringEditor;
friend class RepeatDateEditor;
friend class RepeatDateTimeEditor;

public:
explicit RepeatEditorWidget(QWidget* parent = nullptr);
Expand Down Expand Up @@ -105,4 +106,19 @@ protected Q_SLOTS:
bool isValueChanged() override;
};

class RepeatDateTimeEditor : public RepeatEditor {
Q_OBJECT
public:
explicit RepeatDateTimeEditor(VInfo_ptr, QWidget* parent = nullptr);

protected Q_SLOTS:
void slotValueEdited(QString);

protected:
void apply() override;
void setValue(QString val) override;
void resetValue() override;
bool isValueChanged() override;
};

#endif /* ecflow_viewer_RepeatEditor_HPP */

0 comments on commit f089f07

Please sign in to comment.