Commit a814e4fb authored by Christoffer Ackelman's avatar Christoffer Ackelman Committed by Esteban Blanc

QT: Since QLineEdit never returns a NULL string, we can simplify the code.

parent 817cf263
......@@ -210,7 +210,6 @@ void WAttQt::change_value_close()
if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) {
......@@ -219,7 +218,6 @@ void WAttQt::change_value_close()
}
wattnav->set_attr_value(input_node, input_name, text);
}
statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false);
set_prompt("");
......@@ -229,16 +227,8 @@ void WAttQt::change_value_close()
wattnav->redraw();
wattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else {
char* text = qPrintableLatin1(cmd_entry->text());
if (text) {
wattnav->set_attr_value(input_node, input_name, text);
}
wattnav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_entry->text()));
cmd_entry->setVisible(false);
set_prompt("");
input_open = 0;
......@@ -247,10 +237,6 @@ void WAttQt::change_value_close()
}
wattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
}
if (pending_close) {
......@@ -261,12 +247,8 @@ void WAttQt::change_value_close()
void WAttQtWidget::activate_cmd_entry()
{
char* text = qPrintableLatin1(watt->cmd_entry->text());
if (watt->input_open) {
if (text) {
watt->wattnav->set_attr_value(watt->input_node, watt->input_name, text);
}
watt->wattnav->set_attr_value(watt->input_node, watt->input_name, qPrintableLatin1(watt->cmd_entry->text()));
watt->cmd_entry->setVisible(false);
watt->set_prompt("");
watt->input_open = 0;
......@@ -280,10 +262,6 @@ void WAttQtWidget::activate_cmd_entry()
watt->wattnav->set_inputfocus();
if (!text) {
watt->message('E', "Input error, invalid character");
}
if (watt->pending_close) {
close();
}
......@@ -294,7 +272,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
if (watt->input_open) {
char* text = qPrintableLatin1(watt->cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) {
......@@ -303,7 +280,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
}
watt->wattnav->set_attr_value(watt->input_node, watt->input_name, text);
}
watt->statusbar->setMaximumHeight(25);
watt->cmd_scrolledinput->setVisible(false);
watt->set_prompt("");
......@@ -314,10 +290,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
watt->wattnav->redraw();
watt->wattnav->set_inputfocus();
if (!text) {
watt->message('E', "Input error, invalid character");
}
if (watt->pending_close) {
close();
}
......
......@@ -278,16 +278,8 @@ void WdaQt::change_value_close()
wdanav->redraw();
wdanav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else {
char* text = qPrintableLatin1(cmd_entry->text());
if (text) {
wdanav->set_attr_value(input_node, input_name, text);
}
wdanav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_entry->text()));
cmd_entry->setVisible(false);
set_prompt("");
input_open = 0;
......@@ -296,10 +288,6 @@ void WdaQt::change_value_close()
}
wdanav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
}
}
}
......@@ -311,22 +299,14 @@ void WdaQtWidget::activate_cmd_entry()
wda->wdanav->set_inputfocus();
char* text = qPrintableLatin1(wda->cmd_entry->text());
if (wda->input_open) {
if (text) {
wda->wdanav->set_attr_value(wda->input_node, wda->input_name, text);
}
wda->wdanav->set_attr_value(wda->input_node, wda->input_name, qPrintableLatin1(wda->cmd_entry->text()));
wda->cmd_entry->setVisible(false);
wda->set_prompt("");
wda->input_open = 0;
if (wda->redraw_cb) {
(wda->redraw_cb)(wda);
}
if (!text) {
wda->message('E', "Input error, invalid character");
}
}
}
......@@ -335,7 +315,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
if (wda->input_open) {
char* text = qPrintableLatin1(wda->cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) {
......@@ -344,7 +323,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
}
wda->wdanav->set_attr_value(wda->input_node, wda->input_name, text);
}
wda->statusbar->setMaximumHeight(25);
wda->cmd_scrolledinput->setVisible(false);
wda->set_prompt("");
......@@ -354,9 +332,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
wda->wdanav->redraw();
wda->wdanav->set_inputfocus();
if (!text) {
wda->message('E', "Input error, invalid character");
}
}
}
......
......@@ -519,20 +519,8 @@ void XttQtWidget::focusInEvent(QFocusEvent* event)
void XttQtWidget::valchanged_cmd_entry()
{
if (xtt->cmd_entry->text().isEmpty()) {
xtt->cmd_entry->setVisible(false);
xtt->set_prompt("");
xtt->input_open = 0;
xtt->command_open = 0;
xtt->xnav->set_inputfocus();
xtt->message('E', "Input error, invalid character");
return;
}
char* text = qPrintableLatin1(xtt->cmd_entry->text());
if (xtt->input_open) {
int sts = xtt->xnav->set_attr_value(text);
int sts = xtt->xnav->set_attr_value(qPrintableLatin1(xtt->cmd_entry->text()));
xtt->cmd_entry->setVisible(false);
xtt->set_prompt("");
xtt->input_open = 0;
......@@ -541,7 +529,7 @@ void XttQtWidget::valchanged_cmd_entry()
xtt->message('E', XNav::get_message(sts));
}
} else if (xtt->command_open) {
xtt->xnav->command(text);
xtt->xnav->command(qPrintableLatin1(xtt->cmd_entry->text()));
xtt->cmd_entry->setVisible(false);
xtt->set_prompt("");
xtt->command_open = 0;
......
......@@ -219,11 +219,7 @@ void XAttQt::change_value_close()
{
if (input_open) {
if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
xattnav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_scrolled_buffer->toPlainText()));
statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false);
......@@ -234,15 +230,8 @@ void XAttQt::change_value_close()
xattnav->redraw();
xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else {
char* text = qPrintableLatin1(cmd_entry->text());
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
xattnav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_entry->text()));
cmd_entry->setVisible(false);
set_prompt("");
input_open = 0;
......@@ -251,9 +240,6 @@ void XAttQt::change_value_close()
}
xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
}
}
}
......@@ -266,33 +252,20 @@ void XAttQtWidget::activate_cmd_entry()
xatt->xattnav->set_inputfocus();
if (xatt->input_open) {
char* text = qPrintableLatin1(xatt->cmd_entry->text());
if (text) {
xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name, text);
}
xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name, qPrintableLatin1(xatt->cmd_entry->text()));
xatt->cmd_entry->setVisible(false);
xatt->set_prompt("");
xatt->input_open = 0;
if (xatt->redraw_cb) {
(xatt->redraw_cb)(xatt);
}
if (!text) {
xatt->message('E', "Input error, invalid character");
}
}
}
void XAttQtWidget::activate_cmd_scrolled_ok()
{
if (xatt->input_open) {
char* text = qPrintableLatin1(xatt->cmd_scrolled_buffer->toPlainText());
if (text) {
xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name, text);
} else {
xatt->message('E', "Input error, invalid character");
}
xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name, qPrintableLatin1(xatt->cmd_scrolled_buffer->toPlainText()));
xatt->statusbar->setMaximumHeight(25);
xatt->cmd_scrolledinput->setVisible(false);
......
......@@ -85,11 +85,6 @@ int XAttOneQt::set_value()
textutf8 = cmd_entry->text();
}
if (textutf8.isEmpty()) {
message('E', "Input cannot be empty");
return 0;
}
char buff[1024];
int sts = XNav::attr_string_to_value(
atype, qPrintableLatin1(textutf8), buff, sizeof(buff), asize);
......
......@@ -279,11 +279,7 @@ void XColWindQt::change_value_close()
{
if (input_open) {
if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
xattnav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_scrolled_buffer->toPlainText()));
statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false);
......@@ -294,15 +290,8 @@ void XColWindQt::change_value_close()
xattnav->redraw();
xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else {
char* text = qPrintableLatin1(cmd_entry->text());
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
xattnav->set_attr_value(input_node, input_name, qPrintableLatin1(cmd_entry->text()));
cmd_entry->setVisible(false);
set_prompt("");
input_open = 0;
......@@ -311,9 +300,6 @@ void XColWindQt::change_value_close()
}
xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
}
}
}
......@@ -326,39 +312,22 @@ void XColWindQtWidget::activate_cmd_entry()
colwind->xattnav->set_inputfocus();
if (colwind->input_open) {
char* text = qPrintableLatin1(colwind->cmd_entry->text());
if (text) {
colwind->xattnav->set_attr_value(
colwind->input_node, colwind->input_name, text);
}
colwind->xattnav->set_attr_value(colwind->input_node, colwind->input_name,
qPrintableLatin1(colwind->cmd_entry->text()));
colwind->cmd_entry->setVisible(false);
colwind->set_prompt("");
colwind->input_open = 0;
if (colwind->redraw_cb) {
(colwind->redraw_cb)(colwind);
}
if (!text) {
colwind->message('E', "Input error, invalid character");
}
return;
}
}
void XColWindQtWidget::activate_cmd_scrolled_ok()
{
if (colwind->input_open) {
char* text = qPrintableLatin1(colwind->cmd_scrolled_buffer->toPlainText());
if (text) {
colwind->xattnav->set_attr_value(
colwind->input_node, colwind->input_name, text);
} else {
colwind->message('E', "Input error, invalid character");
}
colwind->xattnav->set_attr_value(
colwind->input_node, colwind->input_name, text);
colwind->xattnav->set_attr_value(colwind->input_node, colwind->input_name,
qPrintableLatin1(colwind->cmd_scrolled_buffer->toPlainText()));
colwind->statusbar->setMaximumHeight(25);
colwind->cmd_scrolledinput->setVisible(false);
colwind->set_prompt("");
......
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