Commit 8e68f518 authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Added destructor to cow_pn_gsdml_attr

parent 6e9a8354
......@@ -50,6 +50,8 @@
#include <QPushButton>
#include <QVBoxLayout>
CoWowRecall GsdAttrQt::value_recall;
void GsdAttrQt::message(char severity, const char* message)
{
msg_label->setText(fl(message));
......@@ -69,7 +71,7 @@ void GsdAttrQt::set_prompt(const char* prompt)
void GsdAttrQt::change_value()
{
if (input_open) {
cmd_input->setVisible(false);
cmd_entry->setVisible(false);
set_prompt("");
input_open = 0;
return;
......@@ -91,18 +93,18 @@ void GsdAttrQt::change_value()
return;
}
cmd_input->setVisible(true);
cmd_entry->setVisible(true);
message(' ', "");
cmd_input->setFocus();
cmd_entry->setFocus();
if (value) {
cmd_input->setText(fl(value));
cmd_entry->setText(fl(value));
// Select the text
cmd_input->selectAll();
cmd_entry->selectAll();
} else {
cmd_input->setText("");
cmd_entry->setText("");
}
set_prompt("value >");
input_open = 1;
......@@ -171,16 +173,16 @@ void GsdAttrQtWidget::activate_cmd_apply()
attr->activate_cmd_apply();
}
void GsdAttrQtWidget::activate_cmd_input()
void GsdAttrQtWidget::activate_cmd_entry()
{
attr->cmd_prompt->setVisible(false);
attr->cmd_input->setVisible(false);
attr->cmd_entry->setVisible(false);
attr->attrnav->set_inputfocus();
if (attr->input_open) {
attr->attrnav->set_attr_value(qPrintable(attr->cmd_input->text()));
attr->cmd_input->setVisible(false);
attr->attrnav->set_attr_value(qPrintable(attr->cmd_entry->text()));
attr->cmd_entry->setVisible(false);
attr->set_prompt("");
attr->input_open = 0;
}
......@@ -189,8 +191,8 @@ void GsdAttrQtWidget::activate_cmd_input()
void GsdAttrQtWidget::focusInEvent(QFocusEvent* event)
{
if (!attr->focustimer.disabled()) {
if (attr->cmd_input->isVisible()) {
attr->cmd_input->setFocus();
if (attr->cmd_entry->isVisible()) {
attr->cmd_entry->setFocus();
} else if (attr->attrnav) {
attr->attrnav->set_inputfocus();
}
......@@ -274,14 +276,14 @@ GsdAttrQt::GsdAttrQt(QWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
cmd_prompt = new QLabel("value > ");
cmd_prompt->setFixedHeight(25);
cmd_input = new QLineEdit();
cmd_input->setFixedHeight(25);
QObject::connect(cmd_input, SIGNAL(editingFinished()), toplevel,
SLOT(valchanged_cmd_input()));
cmd_entry = new CoWowEntryQt(&value_recall);
cmd_entry->setFixedHeight(25);
QObject::connect(cmd_entry, SIGNAL(returnPressed()), toplevel,
SLOT(valchanged_cmd_entry()));
statusbar->addWidget(msg_label);
statusbar->addWidget(cmd_prompt);
add_expanding(statusbar, cmd_input);
add_expanding(statusbar, cmd_entry);
// Apply and Ok buttons
QDialogButtonBox* buttons = new QDialogButtonBox();
......@@ -306,7 +308,7 @@ GsdAttrQt::GsdAttrQt(QWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
toplevel->show();
cmd_prompt->setVisible(false);
cmd_input->setVisible(false);
cmd_entry->setVisible(false);
if (!edit_mode) {
buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
......
......@@ -53,12 +53,13 @@ public:
QWidget* form_widget;
QLabel* msg_label;
QLabel* cmd_prompt;
QLineEdit* cmd_input;
QAction* menubutton_copy;
QAction* menubutton_cut;
QAction* menubutton_paste;
QAction* menubutton_changevalue;
CoWowFocusTimerQt focustimer;
static CoWowRecall value_recall;
CoWowEntryQt* cmd_entry;
GsdAttrQt(QWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
pb_gsd* a_gsd, int a_edit_mode);
......@@ -96,7 +97,7 @@ public slots:
void activate_zoom_out();
void activate_zoom_reset();
void activate_print();
void activate_cmd_input();
void activate_cmd_entry();
void activate_cmd_ok();
void activate_cmd_apply();
......
......@@ -38,10 +38,10 @@
#include "co_string.h"
#include "cow_qt_helpers.h"
#include "rt_pb_msg.h"
#include "cow_qt_helpers.h"
#include "cow_pn_gsdml_attr_qt.h"
#include "cow_pn_gsdml_attrnav_qt.h"
......@@ -60,6 +60,7 @@ void GsdmlAttrQt::message(char severity, const char* message)
void GsdmlAttrQt::attr_help_text(const char* text)
{
help_text->setText(fl(text));
help_text->setVisible(strlen(text) > 0);
}
void GsdmlAttrQt::set_prompt(const char* prompt)
......@@ -75,9 +76,6 @@ void GsdmlAttrQt::set_prompt(const char* prompt)
void GsdmlAttrQt::change_value()
{
int sts;
char* value;
if (input_open) {
cmd_entry->setVisible(false);
set_prompt("");
......@@ -90,7 +88,8 @@ void GsdmlAttrQt::change_value()
return;
}
sts = attrnav->check_attr_value(&value);
char* value;
int sts = attrnav->check_attr_value(&value);
if (EVEN(sts)) {
if (sts == PB__NOATTRSEL) {
message('E', "No attribute is selected");
......@@ -210,11 +209,6 @@ void GsdmlAttrQtWidget::activate_cmd_apply()
attr->activate_cmd_apply();
}
void GsdmlAttrQtWidget::activate_cmd_ca()
{
attr->activate_cmd_ca();
}
void GsdmlAttrQtWidget::activate_cmd_entry()
{
attr->cmd_prompt->setVisible(false);
......@@ -247,11 +241,15 @@ void GsdmlAttrQtWidget::focusInEvent(QFocusEvent* event)
void GsdmlAttrQtWidget::closeEvent(QCloseEvent* event)
{
debug_print("GsdmlAttrQtWidget::closeEvent\n");
attr->activate_exit();
QWidget::closeEvent(event);
}
GsdmlAttrQt::~GsdmlAttrQt()
{
delete attrnav;
}
GsdmlAttrQt::GsdmlAttrQt(QWidget* a_parent_wid, void* a_parent_ctx,
void* a_object, pn_gsdml* a_gsdml, int a_edit_mode,
const char* a_data_filename, pwr_tStatus* a_sts)
......@@ -352,7 +350,7 @@ GsdmlAttrQt::GsdmlAttrQt(QWidget* a_parent_wid, void* a_parent_ctx,
QObject::connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()),
toplevel, SLOT(activate_cmd_apply()));
QObject::connect(buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
toplevel, SLOT(activate_cmd_ca()));
toplevel, SLOT(close()));
QVBoxLayout* vbox = new QVBoxLayout(toplevel);
vbox->setMenuBar(menu_bar);
......@@ -367,6 +365,7 @@ GsdmlAttrQt::GsdmlAttrQt(QWidget* a_parent_wid, void* a_parent_ctx,
cmd_prompt->setVisible(false);
cmd_entry->setVisible(false);
help_text->setVisible(false);
if (!edit_mode) {
buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
......
......@@ -68,6 +68,7 @@ public:
GsdmlAttrQt(QWidget* a_parent_wid, void* a_parent_ctx, void* a_object,
pn_gsdml* a_gsdml, int a_edit_mode, const char* a_data_filename,
pwr_tStatus* a_sts);
~GsdmlAttrQt();
void message(char severity, const char* message);
void attr_help_text(const char* help_text);
......@@ -108,7 +109,6 @@ public slots:
void activate_cmd_entry();
void activate_cmd_ok();
void activate_cmd_apply();
void activate_cmd_ca();
void valchanged_cmd_entry(){}
......
......@@ -48,7 +48,6 @@ GsdmlAttrNavQt::GsdmlAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
pwr_tStatus* status)
: GsdmlAttrNav(xn_parent_ctx, xn_name, xn_gsdml, xn_edit_mode, status)
{
debug_print("creating a scrolledbrowwidgetqt\n");
form_widget = scrolledbrowwidgetqt_new(init_brow_cb, this, &brow_widget);
*w = form_widget;
......@@ -61,6 +60,7 @@ GsdmlAttrNavQt::GsdmlAttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
GsdmlAttrNavQt::~GsdmlAttrNavQt()
{
delete trace_timerid;
delete wow;
delete brow;
form_widget->close();
}
......
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