Commit 845ab2c9 authored by Christoffer Ackelman's avatar Christoffer Ackelman

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

parent 58070b21
...@@ -210,7 +210,6 @@ void WAttQt::change_value_close() ...@@ -210,7 +210,6 @@ void WAttQt::change_value_close()
if (input_multiline) { if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText()); char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) { for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) { if (*s < ' ' && *s != 10 && *s != 13) {
...@@ -219,7 +218,6 @@ void WAttQt::change_value_close() ...@@ -219,7 +218,6 @@ void WAttQt::change_value_close()
} }
wattnav->set_attr_value(input_node, input_name, text); wattnav->set_attr_value(input_node, input_name, text);
}
statusbar->setMaximumHeight(25); statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
set_prompt(""); set_prompt("");
...@@ -229,16 +227,9 @@ void WAttQt::change_value_close() ...@@ -229,16 +227,9 @@ void WAttQt::change_value_close()
wattnav->redraw(); wattnav->redraw();
wattnav->set_inputfocus(); wattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else { } else {
char* text = qPrintableLatin1(cmd_entry->text()); wattnav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_entry->text()));
if (text) {
wattnav->set_attr_value(input_node, input_name, text);
}
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
set_prompt(""); set_prompt("");
input_open = 0; input_open = 0;
...@@ -247,10 +238,6 @@ void WAttQt::change_value_close() ...@@ -247,10 +238,6 @@ void WAttQt::change_value_close()
} }
wattnav->set_inputfocus(); wattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} }
if (pending_close) { if (pending_close) {
...@@ -261,12 +248,9 @@ void WAttQt::change_value_close() ...@@ -261,12 +248,9 @@ void WAttQt::change_value_close()
void WAttQtWidget::activate_cmd_entry() void WAttQtWidget::activate_cmd_entry()
{ {
char* text = qPrintableLatin1(watt->cmd_entry->text());
if (watt->input_open) { if (watt->input_open) {
if (text) { watt->wattnav->set_attr_value(watt->input_node, watt->input_name,
watt->wattnav->set_attr_value(watt->input_node, watt->input_name, text); qPrintableLatin1(watt->cmd_entry->text()));
}
watt->cmd_entry->setVisible(false); watt->cmd_entry->setVisible(false);
watt->set_prompt(""); watt->set_prompt("");
watt->input_open = 0; watt->input_open = 0;
...@@ -280,10 +264,6 @@ void WAttQtWidget::activate_cmd_entry() ...@@ -280,10 +264,6 @@ void WAttQtWidget::activate_cmd_entry()
watt->wattnav->set_inputfocus(); watt->wattnav->set_inputfocus();
if (!text) {
watt->message('E', "Input error, invalid character");
}
if (watt->pending_close) { if (watt->pending_close) {
close(); close();
} }
...@@ -294,7 +274,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok() ...@@ -294,7 +274,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
if (watt->input_open) { if (watt->input_open) {
char* text = qPrintableLatin1(watt->cmd_scrolled_buffer->toPlainText()); char* text = qPrintableLatin1(watt->cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) { for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) { if (*s < ' ' && *s != 10 && *s != 13) {
...@@ -303,7 +282,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok() ...@@ -303,7 +282,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
} }
watt->wattnav->set_attr_value(watt->input_node, watt->input_name, text); watt->wattnav->set_attr_value(watt->input_node, watt->input_name, text);
}
watt->statusbar->setMaximumHeight(25); watt->statusbar->setMaximumHeight(25);
watt->cmd_scrolledinput->setVisible(false); watt->cmd_scrolledinput->setVisible(false);
watt->set_prompt(""); watt->set_prompt("");
...@@ -314,10 +292,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok() ...@@ -314,10 +292,6 @@ void WAttQtWidget::activate_cmd_scrolled_ok()
watt->wattnav->redraw(); watt->wattnav->redraw();
watt->wattnav->set_inputfocus(); watt->wattnav->set_inputfocus();
if (!text) {
watt->message('E', "Input error, invalid character");
}
if (watt->pending_close) { if (watt->pending_close) {
close(); close();
} }
......
...@@ -278,16 +278,9 @@ void WdaQt::change_value_close() ...@@ -278,16 +278,9 @@ void WdaQt::change_value_close()
wdanav->redraw(); wdanav->redraw();
wdanav->set_inputfocus(); wdanav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else { } else {
char* text = qPrintableLatin1(cmd_entry->text()); wdanav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_entry->text()));
if (text) {
wdanav->set_attr_value(input_node, input_name, text);
}
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
set_prompt(""); set_prompt("");
input_open = 0; input_open = 0;
...@@ -296,10 +289,6 @@ void WdaQt::change_value_close() ...@@ -296,10 +289,6 @@ void WdaQt::change_value_close()
} }
wdanav->set_inputfocus(); wdanav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} }
} }
} }
...@@ -311,22 +300,15 @@ void WdaQtWidget::activate_cmd_entry() ...@@ -311,22 +300,15 @@ void WdaQtWidget::activate_cmd_entry()
wda->wdanav->set_inputfocus(); wda->wdanav->set_inputfocus();
char* text = qPrintableLatin1(wda->cmd_entry->text());
if (wda->input_open) { if (wda->input_open) {
if (text) { wda->wdanav->set_attr_value(wda->input_node, wda->input_name,
wda->wdanav->set_attr_value(wda->input_node, wda->input_name, text); qPrintableLatin1(wda->cmd_entry->text()));
}
wda->cmd_entry->setVisible(false); wda->cmd_entry->setVisible(false);
wda->set_prompt(""); wda->set_prompt("");
wda->input_open = 0; wda->input_open = 0;
if (wda->redraw_cb) { if (wda->redraw_cb) {
(wda->redraw_cb)(wda); (wda->redraw_cb)(wda);
} }
if (!text) {
wda->message('E', "Input error, invalid character");
}
} }
} }
...@@ -335,7 +317,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok() ...@@ -335,7 +317,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
if (wda->input_open) { if (wda->input_open) {
char* text = qPrintableLatin1(wda->cmd_scrolled_buffer->toPlainText()); char* text = qPrintableLatin1(wda->cmd_scrolled_buffer->toPlainText());
if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
for (unsigned char* s = (unsigned char*)text; *s; s++) { for (unsigned char* s = (unsigned char*)text; *s; s++) {
if (*s < ' ' && *s != 10 && *s != 13) { if (*s < ' ' && *s != 10 && *s != 13) {
...@@ -344,7 +325,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok() ...@@ -344,7 +325,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
} }
wda->wdanav->set_attr_value(wda->input_node, wda->input_name, text); wda->wdanav->set_attr_value(wda->input_node, wda->input_name, text);
}
wda->statusbar->setMaximumHeight(25); wda->statusbar->setMaximumHeight(25);
wda->cmd_scrolledinput->setVisible(false); wda->cmd_scrolledinput->setVisible(false);
wda->set_prompt(""); wda->set_prompt("");
...@@ -354,9 +334,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok() ...@@ -354,9 +334,6 @@ void WdaQtWidget::activate_cmd_scrolled_ok()
wda->wdanav->redraw(); wda->wdanav->redraw();
wda->wdanav->set_inputfocus(); wda->wdanav->set_inputfocus();
if (!text) {
wda->message('E', "Input error, invalid character");
}
} }
} }
......
...@@ -519,20 +519,9 @@ void XttQtWidget::focusInEvent(QFocusEvent* event) ...@@ -519,20 +519,9 @@ void XttQtWidget::focusInEvent(QFocusEvent* event)
void XttQtWidget::valchanged_cmd_entry() 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) { 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->cmd_entry->setVisible(false);
xtt->set_prompt(""); xtt->set_prompt("");
xtt->input_open = 0; xtt->input_open = 0;
...@@ -541,7 +530,7 @@ void XttQtWidget::valchanged_cmd_entry() ...@@ -541,7 +530,7 @@ void XttQtWidget::valchanged_cmd_entry()
xtt->message('E', XNav::get_message(sts)); xtt->message('E', XNav::get_message(sts));
} }
} else if (xtt->command_open) { } else if (xtt->command_open) {
xtt->xnav->command(text); xtt->xnav->command(qPrintableLatin1(xtt->cmd_entry->text()));
xtt->cmd_entry->setVisible(false); xtt->cmd_entry->setVisible(false);
xtt->set_prompt(""); xtt->set_prompt("");
xtt->command_open = 0; xtt->command_open = 0;
......
...@@ -219,11 +219,8 @@ void XAttQt::change_value_close() ...@@ -219,11 +219,8 @@ void XAttQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText()); xattnav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_scrolled_buffer->toPlainText()));
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
statusbar->setMaximumHeight(25); statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
...@@ -234,15 +231,9 @@ void XAttQt::change_value_close() ...@@ -234,15 +231,9 @@ void XAttQt::change_value_close()
xattnav->redraw(); xattnav->redraw();
xattnav->set_inputfocus(); xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else { } else {
char* text = qPrintableLatin1(cmd_entry->text()); xattnav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_entry->text()));
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
set_prompt(""); set_prompt("");
input_open = 0; input_open = 0;
...@@ -251,9 +242,6 @@ void XAttQt::change_value_close() ...@@ -251,9 +242,6 @@ void XAttQt::change_value_close()
} }
xattnav->set_inputfocus(); xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} }
} }
} }
...@@ -266,33 +254,22 @@ void XAttQtWidget::activate_cmd_entry() ...@@ -266,33 +254,22 @@ void XAttQtWidget::activate_cmd_entry()
xatt->xattnav->set_inputfocus(); xatt->xattnav->set_inputfocus();
if (xatt->input_open) { if (xatt->input_open) {
char* text = qPrintableLatin1(xatt->cmd_entry->text()); xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name,
qPrintableLatin1(xatt->cmd_entry->text()));
if (text) {
xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name, text);
}
xatt->cmd_entry->setVisible(false); xatt->cmd_entry->setVisible(false);
xatt->set_prompt(""); xatt->set_prompt("");
xatt->input_open = 0; xatt->input_open = 0;
if (xatt->redraw_cb) { if (xatt->redraw_cb) {
(xatt->redraw_cb)(xatt); (xatt->redraw_cb)(xatt);
} }
if (!text) {
xatt->message('E', "Input error, invalid character");
}
} }
} }
void XAttQtWidget::activate_cmd_scrolled_ok() void XAttQtWidget::activate_cmd_scrolled_ok()
{ {
if (xatt->input_open) { if (xatt->input_open) {
char* text = qPrintableLatin1(xatt->cmd_scrolled_buffer->toPlainText()); xatt->xattnav->set_attr_value(xatt->input_node, xatt->input_name,
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->statusbar->setMaximumHeight(25); xatt->statusbar->setMaximumHeight(25);
xatt->cmd_scrolledinput->setVisible(false); xatt->cmd_scrolledinput->setVisible(false);
......
...@@ -85,11 +85,6 @@ int XAttOneQt::set_value() ...@@ -85,11 +85,6 @@ int XAttOneQt::set_value()
textutf8 = cmd_entry->text(); textutf8 = cmd_entry->text();
} }
if (textutf8.isEmpty()) {
message('E', "Input cannot be empty");
return 0;
}
char buff[1024]; char buff[1024];
int sts = XNav::attr_string_to_value( int sts = XNav::attr_string_to_value(
atype, qPrintableLatin1(textutf8), buff, sizeof(buff), asize); atype, qPrintableLatin1(textutf8), buff, sizeof(buff), asize);
......
...@@ -279,11 +279,8 @@ void XColWindQt::change_value_close() ...@@ -279,11 +279,8 @@ void XColWindQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText()); xattnav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_scrolled_buffer->toPlainText()));
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
statusbar->setMaximumHeight(25); statusbar->setMaximumHeight(25);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
...@@ -294,15 +291,9 @@ void XColWindQt::change_value_close() ...@@ -294,15 +291,9 @@ void XColWindQt::change_value_close()
xattnav->redraw(); xattnav->redraw();
xattnav->set_inputfocus(); xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} else { } else {
char* text = qPrintableLatin1(cmd_entry->text()); xattnav->set_attr_value(input_node, input_name,
qPrintableLatin1(cmd_entry->text()));
if (text) {
xattnav->set_attr_value(input_node, input_name, text);
}
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
set_prompt(""); set_prompt("");
input_open = 0; input_open = 0;
...@@ -311,9 +302,6 @@ void XColWindQt::change_value_close() ...@@ -311,9 +302,6 @@ void XColWindQt::change_value_close()
} }
xattnav->set_inputfocus(); xattnav->set_inputfocus();
if (!text) {
message('E', "Input error, invalid character");
}
} }
} }
} }
...@@ -326,21 +314,14 @@ void XColWindQtWidget::activate_cmd_entry() ...@@ -326,21 +314,14 @@ void XColWindQtWidget::activate_cmd_entry()
colwind->xattnav->set_inputfocus(); colwind->xattnav->set_inputfocus();
if (colwind->input_open) { if (colwind->input_open) {
char* text = qPrintableLatin1(colwind->cmd_entry->text()); colwind->xattnav->set_attr_value(colwind->input_node, colwind->input_name,
qPrintableLatin1(colwind->cmd_entry->text()));
if (text) {
colwind->xattnav->set_attr_value(
colwind->input_node, colwind->input_name, text);
}
colwind->cmd_entry->setVisible(false); colwind->cmd_entry->setVisible(false);
colwind->set_prompt(""); colwind->set_prompt("");
colwind->input_open = 0; colwind->input_open = 0;
if (colwind->redraw_cb) { if (colwind->redraw_cb) {
(colwind->redraw_cb)(colwind); (colwind->redraw_cb)(colwind);
} }
if (!text) {
colwind->message('E', "Input error, invalid character");
}
return; return;
} }
} }
...@@ -348,17 +329,8 @@ void XColWindQtWidget::activate_cmd_entry() ...@@ -348,17 +329,8 @@ void XColWindQtWidget::activate_cmd_entry()
void XColWindQtWidget::activate_cmd_scrolled_ok() void XColWindQtWidget::activate_cmd_scrolled_ok()
{ {
if (colwind->input_open) { if (colwind->input_open) {
char* text = qPrintableLatin1(colwind->cmd_scrolled_buffer->toPlainText()); colwind->xattnav->set_attr_value(colwind->input_node, colwind->input_name,
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->statusbar->setMaximumHeight(25); colwind->statusbar->setMaximumHeight(25);
colwind->cmd_scrolledinput->setVisible(false); colwind->cmd_scrolledinput->setVisible(false);
colwind->set_prompt(""); 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