Commit cc5abd78 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Added a helper macro for converting a QString to a Latin1 encoded char array.

parent 67899f69
...@@ -191,8 +191,7 @@ void PnViewerQt::open_change_value() ...@@ -191,8 +191,7 @@ void PnViewerQt::open_change_value()
void PnViewerQtWidget::valchanged_cmd_entry() void PnViewerQtWidget::valchanged_cmd_entry()
{ {
if (viewer->input_open) { if (viewer->input_open) {
QByteArray text = viewer->cmd_entry->text().toLatin1(); viewer->viewernav->set_attr_value(qPrintableLatin1(viewer->cmd_entry->text()));
viewer->viewernav->set_attr_value(text.data());
viewer->cmd_entry->setVisible(false); viewer->cmd_entry->setVisible(false);
viewer->set_prompt(""); viewer->set_prompt("");
viewer->input_open = 0; viewer->input_open = 0;
......
...@@ -225,9 +225,7 @@ void XttTblQt::set_prompt(const char* prompt) ...@@ -225,9 +225,7 @@ void XttTblQt::set_prompt(const char* prompt)
void XttTblQtWidget::valchanged_cmd_input() void XttTblQtWidget::valchanged_cmd_input()
{ {
QByteArray text = tbl->cmd_entry->text().toLatin1(); tbl->command(qPrintableLatin1(tbl->cmd_entry->text()));
tbl->command(text.data());
tbl->cmd_entry->setVisible(false); tbl->cmd_entry->setVisible(false);
tbl->set_prompt(""); tbl->set_prompt("");
tbl->command_open = 0; tbl->command_open = 0;
......
...@@ -478,16 +478,14 @@ void WFoeQtWidget::valchanged_textinput() ...@@ -478,16 +478,14 @@ void WFoeQtWidget::valchanged_textinput()
return; return;
} }
QByteArray value = foe->textinput->text().toLatin1(); strcpy(foe->searchstring, qPrintableLatin1(foe->textinput->text()));
strcpy(foe->searchstring, value.data());
foe->message(""); foe->message("");
foe->textinput->setText(""); foe->textinput->setText("");
foe->textinput->setVisible(false); foe->textinput->setVisible(false);
/* Call the specified function */ /* Call the specified function */
sts = (foe->textinput_func)(foe, value.data()); sts = (foe->textinput_func)(foe, foe->searchstring);
foe->error_msg(sts); foe->error_msg(sts);
} }
......
...@@ -314,8 +314,7 @@ WUtedQt::~WUtedQt() ...@@ -314,8 +314,7 @@ WUtedQt::~WUtedQt()
// Get value from textentry with specified index // Get value from textentry with specified index
void WUtedQt::get_value(int idx, char* str, int len) void WUtedQt::get_value(int idx, char* str, int len)
{ {
QByteArray ba = value[idx]->text().toLatin1(); strncpy(str, qPrintableLatin1(value[idx]->text()), len);
strncpy(str, ba.data(), len);
} }
// Hide all qualifiers. // Hide all qualifiers.
......
...@@ -55,6 +55,9 @@ CoWowRecall WAttQt::value_recall; ...@@ -55,6 +55,9 @@ CoWowRecall WAttQt::value_recall;
void WAttQt::message(char severity, const char* message) void WAttQt::message(char severity, const char* message)
{ {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void WAttQt::set_prompt(const char* prompt) void WAttQt::set_prompt(const char* prompt)
...@@ -195,8 +198,7 @@ void WAttQt::change_value_close() ...@@ -195,8 +198,7 @@ void WAttQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
QByteArray ba = cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
...@@ -221,8 +223,7 @@ void WAttQt::change_value_close() ...@@ -221,8 +223,7 @@ void WAttQt::change_value_close()
message('E', "Input error, invalid character"); message('E', "Input error, invalid character");
} }
} else { } else {
QByteArray ba = cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(cmd_entry->text());
char* text = ba.data();
if (text) { if (text) {
wattnav->set_attr_value(input_node, input_name, text); wattnav->set_attr_value(input_node, input_name, text);
...@@ -251,8 +252,7 @@ void WAttQtWidget::activate_cmd_entry() ...@@ -251,8 +252,7 @@ void WAttQtWidget::activate_cmd_entry()
{ {
watt->wattnav->set_inputfocus(); watt->wattnav->set_inputfocus();
QByteArray ba = watt->cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(watt->cmd_entry->text());
char* text = ba.data();
if (watt->input_open) { if (watt->input_open) {
if (text) { if (text) {
...@@ -281,8 +281,7 @@ void WAttQtWidget::activate_cmd_entry() ...@@ -281,8 +281,7 @@ void WAttQtWidget::activate_cmd_entry()
void WAttQtWidget::activate_cmd_scrolled_ok() void WAttQtWidget::activate_cmd_scrolled_ok()
{ {
if (watt->input_open) { if (watt->input_open) {
QByteArray ba = watt->cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(watt->cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
...@@ -461,6 +460,7 @@ WAttQt::WAttQt(QWidget* wa_parent_wid, void* wa_parent_ctx, ...@@ -461,6 +460,7 @@ WAttQt::WAttQt(QWidget* wa_parent_wid, void* wa_parent_ctx,
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
......
...@@ -152,8 +152,7 @@ void WAttTextQt::set_editmode(int editmode, ldh_tSesContext ldhses) ...@@ -152,8 +152,7 @@ void WAttTextQt::set_editmode(int editmode, ldh_tSesContext ldhses)
void WAttTextQt::set_attr_value() void WAttTextQt::set_attr_value()
{ {
if (editmode) { if (editmode) {
QByteArray ba = textbuffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(textbuffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
......
...@@ -55,6 +55,9 @@ CoWowRecall WdaQt::value_recall; ...@@ -55,6 +55,9 @@ CoWowRecall WdaQt::value_recall;
void WdaQt::message(char severity, const char* message) void WdaQt::message(char severity, const char* message)
{ {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void WdaQt::set_prompt(const char* prompt) void WdaQt::set_prompt(const char* prompt)
...@@ -197,12 +200,9 @@ void WdaQtWidget::class_activate_ok() ...@@ -197,12 +200,9 @@ void WdaQtWidget::class_activate_ok()
int sts; int sts;
pwr_tClassId new_classid; pwr_tClassId new_classid;
QByteArray ba = wda->wdaclass_hiervalue->text().toLatin1(); char* hiername = qPrintableLatin1(wda->wdaclass_hiervalue->text());
char* hiername = ba.data(); char* searchname = qPrintableLatin1(wda->wdaclass_namevalue->text());
ba = wda->wdaclass_namevalue->text().toLatin1(); char* classname = qPrintableLatin1(wda->wdaclass_classvalue->text());
char* searchname = ba.data();
ba = wda->wdaclass_classvalue->text().toLatin1();
char* classname = ba.data();
wda->attrobjects = wda->wdaclass_attrobjects->isChecked(); wda->attrobjects = wda->wdaclass_attrobjects->isChecked();
...@@ -264,8 +264,7 @@ void WdaQt::change_value_close() ...@@ -264,8 +264,7 @@ void WdaQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
QByteArray ba = cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
// 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++) {
...@@ -288,8 +287,7 @@ void WdaQt::change_value_close() ...@@ -288,8 +287,7 @@ void WdaQt::change_value_close()
message('E', "Input error, invalid character"); message('E', "Input error, invalid character");
} }
} else { } else {
QByteArray ba = cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(cmd_entry->text());
char* text = ba.data();
if (text) { if (text) {
wdanav->set_attr_value(input_node, input_name, text); wdanav->set_attr_value(input_node, input_name, text);
...@@ -317,8 +315,7 @@ void WdaQtWidget::activate_cmd_entry() ...@@ -317,8 +315,7 @@ void WdaQtWidget::activate_cmd_entry()
wda->wdanav->set_inputfocus(); wda->wdanav->set_inputfocus();
QByteArray ba = wda->cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(wda->cmd_entry->text());
char* text = ba.data();
if (wda->input_open) { if (wda->input_open) {
if (text) { if (text) {
...@@ -340,8 +337,7 @@ void WdaQtWidget::activate_cmd_entry() ...@@ -340,8 +337,7 @@ void WdaQtWidget::activate_cmd_entry()
void WdaQtWidget::activate_cmd_scrolled_ok() void WdaQtWidget::activate_cmd_scrolled_ok()
{ {
if (wda->input_open) { if (wda->input_open) {
QByteArray ba = wda->cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(wda->cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
// Replace ctrl characters with space // Replace ctrl characters with space
...@@ -513,6 +509,7 @@ WdaQt::WdaQt(QWidget* wa_parent_wid, void* wa_parent_ctx, ...@@ -513,6 +509,7 @@ WdaQt::WdaQt(QWidget* wa_parent_wid, void* wa_parent_ctx,
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
......
...@@ -493,8 +493,7 @@ int WNavQt::prompt_dialog(char* title, char* text, char** value) ...@@ -493,8 +493,7 @@ int WNavQt::prompt_dialog(char* title, char* text, char** value)
QString str = QInputDialog::getText(toplevel, translate_utf8(title), QString str = QInputDialog::getText(toplevel, translate_utf8(title),
translate_utf8(text), QLineEdit::Normal, "", &ok); translate_utf8(text), QLineEdit::Normal, "", &ok);
if (ok) { if (ok) {
QByteArray ba = str.toLatin1(); strcpy(*value, qPrintableLatin1(str));
strcpy(*value, ba.data());
} else { } else {
strcpy(*value, ""); strcpy(*value, "");
} }
......
...@@ -246,13 +246,10 @@ void WRevInputDialog::closeEvent(QCloseEvent* event) ...@@ -246,13 +246,10 @@ void WRevInputDialog::closeEvent(QCloseEvent* event)
void WRevInputDialog::activate_ok() void WRevInputDialog::activate_ok()
{ {
QByteArray text1 = india_text1->text().toLatin1();
QByteArray text2 = india_text2->text().toLatin1();
rev->dialog_count--; rev->dialog_count--;
rev->india_widget = 0; rev->india_widget = 0;
(rev->india_ok_cb)(rev, text1.data(), text2.data()); (rev->india_ok_cb)(rev, qPrintableLatin1(india_text1->text()), qPrintableLatin1(india_text2->text()));
close(); close();
} }
......
...@@ -717,6 +717,9 @@ void WttQt::set_twowindows(int two, int display_wnav, int display_wnavnode) ...@@ -717,6 +717,9 @@ void WttQt::set_twowindows(int two, int display_wnav, int display_wnavnode)
void WttQt::message(char severity, const char* message) void WttQt::message(char severity, const char* message)
{ {
msg_label->setText(QString::fromLatin1(message)); msg_label->setText(QString::fromLatin1(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void WttQt::set_prompt(const char* prompt) void WttQt::set_prompt(const char* prompt)
...@@ -1362,11 +1365,8 @@ void WttQtWidget::valchanged_cmd_entry() ...@@ -1362,11 +1365,8 @@ void WttQtWidget::valchanged_cmd_entry()
{ {
int sts; int sts;
QByteArray text = wtt->cmd_entry->text().toLatin1(); if (wtt->cmd_entry->text().isEmpty()) {
debug_print("text=%s\n", text.data()); wtt->wnav->wow->DisplayError("Input error", "Input cannot be empty");
if (!text.data()) {
wtt->wnav->wow->DisplayError("Input error", "Invalid character");
return; return;
} }
...@@ -1375,7 +1375,7 @@ void WttQtWidget::valchanged_cmd_entry() ...@@ -1375,7 +1375,7 @@ void WttQtWidget::valchanged_cmd_entry()
case wtt_eInputMode_Attribute: case wtt_eInputMode_Attribute:
wtt->input_wnav->select_object(wtt->input_node); wtt->input_wnav->select_object(wtt->input_node);
sts = wtt->input_wnav->set_attr_value( sts = wtt->input_wnav->set_attr_value(
wtt->input_node, wtt->input_objid, text.data()); wtt->input_node, wtt->input_objid, qPrintableLatin1(wtt->cmd_entry->text()));
if (EVEN(sts)) { if (EVEN(sts)) {
wtt->message('E', wnav_get_message(sts)); wtt->message('E', wnav_get_message(sts));
} }
...@@ -1383,7 +1383,7 @@ void WttQtWidget::valchanged_cmd_entry() ...@@ -1383,7 +1383,7 @@ void WttQtWidget::valchanged_cmd_entry()
case wtt_eInputMode_ObjectName: case wtt_eInputMode_ObjectName:
wtt->input_wnav->select_object(wtt->input_node); wtt->input_wnav->select_object(wtt->input_node);
sts = wtt->input_wnav->set_object_name( sts = wtt->input_wnav->set_object_name(
wtt->input_node, wtt->input_objid, text.data()); wtt->input_node, wtt->input_objid, qPrintableLatin1(wtt->cmd_entry->text()));
if (EVEN(sts)) { if (EVEN(sts)) {
wtt->message('E', wnav_get_message(sts)); wtt->message('E', wnav_get_message(sts));
} }
...@@ -1400,7 +1400,7 @@ void WttQtWidget::valchanged_cmd_entry() ...@@ -1400,7 +1400,7 @@ void WttQtWidget::valchanged_cmd_entry()
wtt->set_focus_default(); wtt->set_focus_default();
} }
wtt->set_clock_cursor(); wtt->set_clock_cursor();
wtt->focused_wnav->command(text.data()); wtt->focused_wnav->command(qPrintableLatin1(wtt->cmd_entry->text()));
wtt->reset_cursor(); wtt->reset_cursor();
wtt->cmd_entry->setVisible(false); wtt->cmd_entry->setVisible(false);
wtt->set_prompt(""); wtt->set_prompt("");
...@@ -1438,10 +1438,7 @@ void WttQt::open_input_dialog(const char* text, const char* title, ...@@ -1438,10 +1438,7 @@ void WttQt::open_input_dialog(const char* text, const char* title,
QString str = QInputDialog::getText(toplevel, translate_utf8(title), QString str = QInputDialog::getText(toplevel, translate_utf8(title),
translate_utf8(text), QLineEdit::Normal, fl(init_text), &ok); translate_utf8(text), QLineEdit::Normal, fl(init_text), &ok);
if (ok) { if (ok) {
QByteArray ba = str.toLatin1(); (ok_cb)(this, qPrintableLatin1(str));
char* text = ba.data();
(ok_cb)(this, text);
} }
} }
...@@ -2270,6 +2267,7 @@ WttQt::WttQt(void* wt_parent_ctx, QWidget* wt_parent_wid, const char* wt_name, ...@@ -2270,6 +2267,7 @@ WttQt::WttQt(void* wt_parent_ctx, QWidget* wt_parent_wid, const char* wt_name,
if (!editmode) { if (!editmode) {
palette_widget->setVisible(false); palette_widget->setVisible(false);
} }
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
set_pane_position(wnav_paned, window_width / 2); set_pane_position(wnav_paned, window_width / 2);
......
...@@ -892,7 +892,6 @@ void Wtt::close(void* ctx) ...@@ -892,7 +892,6 @@ void Wtt::close(void* ctx)
void Wtt::change_value(void* ctx) void Wtt::change_value(void* ctx)
{ {
fprintf(stderr, "Wtt::change_value\n");
((Wtt*)ctx)->open_change_value(); ((Wtt*)ctx)->open_change_value();
} }
......
...@@ -89,16 +89,16 @@ void XttQt::open_input_dialog(const char* text, const char* title, ...@@ -89,16 +89,16 @@ void XttQt::open_input_dialog(const char* text, const char* title,
QString str = QInputDialog::getText(toplevel, translate_utf8(title), QString str = QInputDialog::getText(toplevel, translate_utf8(title),
translate_utf8(text), QLineEdit::Normal, fl(init_text), &ok); translate_utf8(text), QLineEdit::Normal, fl(init_text), &ok);
if (ok) { if (ok) {
QByteArray ba = str.toLatin1(); (ok_cb)(this, qPrintableLatin1(str));
char* text = ba.data();
(ok_cb)(this, text);
} }
} }
void XttQt::message(char severity, const char* msg) void XttQt::message(char severity, const char* msg)
{ {
msg_label->setText(QString::fromLatin1(msg)); msg_label->setText(QString::fromLatin1(msg));
if (strcmp(msg, "") != 0) {
msg_label->setVisible(true);
}
} }
void XttQt::close(void* ctx, int terminate) void XttQt::close(void* ctx, int terminate)
...@@ -517,10 +517,7 @@ void XttQtWidget::focusInEvent(QFocusEvent* event) ...@@ -517,10 +517,7 @@ void XttQtWidget::focusInEvent(QFocusEvent* event)
void XttQtWidget::valchanged_cmd_entry() void XttQtWidget::valchanged_cmd_entry()
{ {
QByteArray ba = xtt->cmd_entry->text().toLatin1(); if (xtt->cmd_entry->text().isEmpty()) {
char* text = ba.data();
if (!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;
...@@ -530,6 +527,8 @@ void XttQtWidget::valchanged_cmd_entry() ...@@ -530,6 +527,8 @@ void XttQtWidget::valchanged_cmd_entry()
return; 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(text);
xtt->cmd_entry->setVisible(false); xtt->cmd_entry->setVisible(false);
...@@ -766,6 +765,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts) ...@@ -766,6 +765,7 @@ XttQt::XttQt(int argc, char* argv[], int* return_sts)
toplevel->setLayout(vbox); toplevel->setLayout(vbox);
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
......
...@@ -70,6 +70,10 @@ void dbg_print(const char* file, int line, QString str); ...@@ -70,6 +70,10 @@ void dbg_print(const char* file, int line, QString str);
* Qt Helper functions * Qt Helper functions
*/ */
QString fl(const char* text); QString fl(const char* text);
#ifndef qPrintableLatin1
#define qPrintableLatin1(string) (string).toLatin1().data()
#endif
QString convert_utf8(const char* str); QString convert_utf8(const char* str);
QString translate_utf8(const char* str); QString translate_utf8(const char* str);
void pop(QWidget* w); void pop(QWidget* w);
......
...@@ -345,18 +345,8 @@ void NodelistQt::open_add_input_dialog(const char* text, const char* text2, ...@@ -345,18 +345,8 @@ void NodelistQt::open_add_input_dialog(const char* text, const char* text2,
void NodelistInputDialogQt::activate_ok() void NodelistInputDialogQt::activate_ok()
{ {
char *txt, *txt2, *txt3; (nodelist->add_india_ok_cb)(nodelist, qPrintableLatin1(text->text()),
qPrintableLatin1(text2->text()), qPrintableLatin1(text3->text()));
QByteArray ba = text->text().toLatin1();
txt = ba.data();
ba = text2->text().toLatin1();
txt2 = ba.data();
ba = text3->text().toLatin1();
txt3 = ba.data();
(nodelist->add_india_ok_cb)(nodelist, txt, txt2, txt3);
accept(); accept();
} }
......
...@@ -134,11 +134,8 @@ void CoWowQt::CreateInputDialog(void* ctx, const char* title, const char* text, ...@@ -134,11 +134,8 @@ void CoWowQt::CreateInputDialog(void* ctx, const char* title, const char* text,
QString str = QInputDialog::getText(object->parent_wid, translate_utf8(title), QString str = QInputDialog::getText(object->parent_wid, translate_utf8(title),
translate_utf8(text), QLineEdit::Normal, temp_txt, &ok); translate_utf8(text), QLineEdit::Normal, temp_txt, &ok);
if (ok) { if (ok) {
QByteArray ba = str.toLatin1();
char* text = ba.data();
if (inputdialogbox_ok) { if (inputdialogbox_ok) {
(inputdialogbox_ok)(ctx, data, text); (inputdialogbox_ok)(ctx, data, qPrintableLatin1(str));
} }
} else { } else {
if (inputdialogbox_cancel) { if (inputdialogbox_cancel) {
...@@ -214,10 +211,7 @@ void CoWowListWidgetQt::list_apply_cb() ...@@ -214,10 +211,7 @@ void CoWowListWidgetQt::list_apply_cb()
selected_text = item->text(0); selected_text = item->text(0);
} }
if (action_cb) { if (action_cb) {
QByteArray ba = selected_text.toLatin1(); (action_cb)(parent_ctx, qPrintableLatin1(selected_text), ok_pressed);
char* text = ba.data();
(action_cb)(parent_ctx, text, ok_pressed);
} }
} }
...@@ -842,9 +836,7 @@ wow_sModalInputDialog* CoWowQt::CreateModalInputDialog(const char* title, ...@@ -842,9 +836,7 @@ wow_sModalInputDialog* CoWowQt::CreateModalInputDialog(const char* title,
wow_sModalInputDialog* ret = new wow_sModalInputDialog(); wow_sModalInputDialog* ret = new wow_sModalInputDialog();
ret->status = status; ret->status = status;
QString valueutf8 = dialog_w->text(); strncpy(ret->input_str, qPrintableLatin1(dialog_w->text()), sizeof(ret->input_str));
QByteArray ba = valueutf8.toLatin1();
strncpy(ret->input_str, ba.data(), sizeof(ret->input_str));
return ret; return ret;
} }
......
...@@ -50,10 +50,7 @@ void CoXHelpQt::open_input_dialog(const char* text, const char* title, ...@@ -50,10 +50,7 @@ void CoXHelpQt::open_input_dialog(const char* text, const char* title,
QString str = QInputDialog::getText(toplevel, fl("Input Dialog"), QString str = QInputDialog::getText(toplevel, fl("Input Dialog"),
fl("Graph Name"), QLineEdit::Normal, fl(init_text), &ok); fl("Graph Name"), QLineEdit::Normal, fl(init_text), &ok);
if (ok) { if (ok) {
QByteArray ba = str.toLatin1(); (ok_cb)(this, qPrintableLatin1(str));
char* text = ba.data();
(ok_cb)(this, text);
} }
} }
......
...@@ -54,6 +54,9 @@ void AttrQt::message(char severity, const char* message) ...@@ -54,6 +54,9 @@ void AttrQt::message(char severity, const char* message)
{ {
if (msg_label) { if (msg_label) {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
} }
...@@ -217,11 +220,9 @@ void AttrQtWidget::attr_activate_cmd_entry() ...@@ -217,11 +220,9 @@ void AttrQtWidget::attr_activate_cmd_entry()
attr->attrnav->set_inputfocus(); attr->attrnav->set_inputfocus();
QByteArray ba = attr->cmd_entry->text().toLatin1();
char* text = ba.data();
if (attr->input_open) { if (attr->input_open) {
attr->attrnav->set_attr_value(text, 0, 0); attr->attrnav->set_attr_value(
qPrintableLatin1(attr->cmd_entry->text()), 0, 0);
attr->cmd_entry->setVisible(false); attr->cmd_entry->setVisible(false);
attr->set_prompt(""); attr->set_prompt("");
attr->input_open = 0; attr->input_open = 0;
...@@ -235,10 +236,8 @@ void AttrQtWidget::attr_activate_cmd_entry() ...@@ -235,10 +236,8 @@ void AttrQtWidget::attr_activate_cmd_entry()
void AttrQtWidget::attr_activate_cmd_scrolled_ok() void AttrQtWidget::attr_activate_cmd_scrolled_ok()
{ {
if (attr->input_open) { if (attr->input_open) {
QByteArray ba = attr->cmd_scrolled_buffer->toPlainText().toLatin1(); attr->attrnav->set_attr_value(
char* text = ba.data(); qPrintableLatin1(attr->cmd_scrolled_buffer->toPlainText()), 0, 0);
attr->attrnav->set_attr_value(text, 0, 0);
attr->cmd_scrolledinput->setVisible(false); attr->cmd_scrolledinput->setVisible(false);
attr->set_prompt(""); attr->set_prompt("");
attr->input_open = 0; attr->input_open = 0;
...@@ -407,6 +406,7 @@ AttrQt::AttrQt(QWidget* a_parent_wid, void* a_parent_ctx, attr_eType a_type, ...@@ -407,6 +406,7 @@ AttrQt::AttrQt(QWidget* a_parent_wid, void* a_parent_ctx, attr_eType a_type,
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
......
...@@ -105,8 +105,7 @@ void GeQt::open_input_dialog(const char* text, const char* title, ...@@ -105,8 +105,7 @@ void GeQt::open_input_dialog(const char* text, const char* title,
QString txt = QInputDialog::getText( QString txt = QInputDialog::getText(
toplevel, fl(title), fl(text), QLineEdit::Normal, fl(init_text), &ok); toplevel, fl(title), fl(text), QLineEdit::Normal, fl(init_text), &ok);
if (ok && !txt.isEmpty()) { if (ok && !txt.isEmpty()) {
QByteArray ba = txt.toLatin1(); activate_india_ok(qPrintableLatin1(txt));
activate_india_ok(ba.data());
} }
} }
...@@ -1141,22 +1140,20 @@ void GeQtWidget::activate_help_subgraph() ...@@ -1141,22 +1140,20 @@ void GeQtWidget::activate_help_subgraph()
void GeQtWidget::valchanged_cmd_entry() void GeQtWidget::valchanged_cmd_entry()
{ {
QByteArray text = ge->recall_entry->text().toLatin1();
if (ge->text_input_open) { if (ge->text_input_open) {
ge->graph->change_text(ge->current_text_object, text.data()); ge->graph->change_text(ge->current_text_object, qPrintableLatin1(ge->recall_entry->text()));
ge->text_input_open = 0; ge->text_input_open = 0;
} else if (ge->name_input_open) { } else if (ge->name_input_open) {
ge->graph->change_name(ge->current_text_object, text.data()); ge->graph->change_name(ge->current_text_object, qPrintableLatin1(ge->recall_entry->text()));
ge->name_input_open = 0; ge->name_input_open = 0;
} else if (ge->value_input_open) { } else if (ge->value_input_open) {
ge->graph->change_value(ge->current_value_object, text.data()); ge->graph->change_value(ge->current_value_object, qPrintableLatin1(ge->recall_entry->text()));
ge->value_input_open = 0; ge->value_input_open = 0;
} else if (ge->objectnav_input_open) { } else if (ge->objectnav_input_open) {
ge->objectnav->set_attr_value(text.data()); ge->objectnav->set_attr_value(qPrintableLatin1(ge->recall_entry->text()));
ge->objectnav_input_open = 0; ge->objectnav_input_open = 0;
} else if (ge->command_open) { } else if (ge->command_open) {
ge->graph->command(text.data()); ge->graph->command(qPrintableLatin1(ge->recall_entry->text()));
ge->command_open = 0; ge->command_open = 0;
} }
......
...@@ -77,16 +77,14 @@ void XttFileviewQtWidget::list_ok_cb(const QString& file) ...@@ -77,16 +77,14 @@ void XttFileviewQtWidget::list_ok_cb(const QString& file)
if (fileview->type == fileview_eType_Open) { if (fileview->type == fileview_eType_Open) {
char selected_text[80]; char selected_text[80];
QByteArray textiso = file.toLatin1(); strcpy(selected_text, qPrintableLatin1(file));
strcpy(selected_text, textiso.data());
fileview->execute(selected_text); fileview->execute(selected_text);
} else { } else {
bool file_exist = false; bool file_exist = false;
char input_text[200]; char input_text[200];
QByteArray text = file.toLatin1(); strncpy(input_text, qPrintableLatin1(file), sizeof(input_text));
strncpy(input_text, text.data(), sizeof(input_text));
/* /*
if (strcmp(filetype, "") != 0) { if (strcmp(filetype, "") != 0) {
......
...@@ -368,16 +368,10 @@ void HistQtWidget::ok_btn() ...@@ -368,16 +368,10 @@ void HistQtWidget::ok_btn()
hist->eventPrio_C = hist->prioC_toggle_w->isChecked(); hist->eventPrio_C = hist->prioC_toggle_w->isChecked();
hist->eventPrio_D = hist->prioD_toggle_w->isChecked(); hist->eventPrio_D = hist->prioD_toggle_w->isChecked();
QByteArray ba = hist->start_time_entry_w->text().toLatin1(); hist->minTime_str = qPrintableLatin1(hist->start_time_entry_w->text());
hist->minTime_str = ba.data(); hist->maxTime_str = qPrintableLatin1(hist->stop_time_entry_w->text());
ba = hist->stop_time_entry_w->text().toLatin1(); hist->eventText_str = qPrintableLatin1(hist->event_text_entry_w->text());
hist->maxTime_str = ba.data(); hist->eventName_str = qPrintableLatin1(hist->event_name_entry_w->text());
ba = hist->event_text_entry_w->text().toLatin1();
hist->eventText_str = ba.data();
ba = hist->event_name_entry_w->text().toLatin1();
hist->eventName_str = ba.data();
hist->get_hist_list(); hist->get_hist_list();
......
...@@ -59,6 +59,9 @@ CoWowRecall XAttQt::value_recall; ...@@ -59,6 +59,9 @@ CoWowRecall XAttQt::value_recall;
void XAttQt::message(char severity, const char* message) void XAttQt::message(char severity, const char* message)
{ {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void XAttQt::set_prompt(const char* prompt) void XAttQt::set_prompt(const char* prompt)
...@@ -213,8 +216,7 @@ void XAttQt::change_value_close() ...@@ -213,8 +216,7 @@ void XAttQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
QByteArray ba = cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
xattnav->set_attr_value(input_node, input_name, text); xattnav->set_attr_value(input_node, input_name, text);
...@@ -232,8 +234,7 @@ void XAttQt::change_value_close() ...@@ -232,8 +234,7 @@ void XAttQt::change_value_close()
message('E', "Input error, invalid character"); message('E', "Input error, invalid character");
} }
} else { } else {
QByteArray ba = cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(cmd_entry->text());
char* text = ba.data();
if (text) { if (text) {
xattnav->set_attr_value(input_node, input_name, text); xattnav->set_attr_value(input_node, input_name, text);
...@@ -260,10 +261,9 @@ void XAttQtWidget::activate_cmd_entry() ...@@ -260,10 +261,9 @@ void XAttQtWidget::activate_cmd_entry()
xatt->xattnav->set_inputfocus(); xatt->xattnav->set_inputfocus();
QByteArray ba = xatt->cmd_entry->text().toLatin1();
char* text = ba.data();
if (xatt->input_open) { if (xatt->input_open) {
char* text = qPrintableLatin1(xatt->cmd_entry->text());
if (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, text);
} }
...@@ -282,8 +282,7 @@ void XAttQtWidget::activate_cmd_entry() ...@@ -282,8 +282,7 @@ void XAttQtWidget::activate_cmd_entry()
void XAttQtWidget::activate_cmd_scrolled_ok() void XAttQtWidget::activate_cmd_scrolled_ok()
{ {
if (xatt->input_open) { if (xatt->input_open) {
QByteArray ba = xatt->cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(xatt->cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (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, text);
...@@ -450,6 +449,7 @@ XAttQt::XAttQt(QWidget* xa_parent_wid, void* xa_parent_ctx, ...@@ -450,6 +449,7 @@ XAttQt::XAttQt(QWidget* xa_parent_wid, void* xa_parent_ctx,
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
......
...@@ -58,6 +58,9 @@ CoWowRecall XAttOneQt::value_recall; ...@@ -58,6 +58,9 @@ CoWowRecall XAttOneQt::value_recall;
void XAttOneQt::message(char severity, const char* message) void XAttOneQt::message(char severity, const char* message)
{ {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void XAttOneQt::set_prompt(char* prompt) void XAttOneQt::set_prompt(char* prompt)
...@@ -81,16 +84,14 @@ int XAttOneQt::set_value() ...@@ -81,16 +84,14 @@ int XAttOneQt::set_value()
textutf8 = cmd_entry->text(); textutf8 = cmd_entry->text();
} }
QByteArray text = textutf8.toLatin1(); if (textutf8.isEmpty()) {
message('E', "Input cannot be empty");
if (!text.data()) {
message('E', "Input error, invalid character");
return 0; return 0;
} }
char buff[1024]; char buff[1024];
int sts = XNav::attr_string_to_value( int sts = XNav::attr_string_to_value(
atype, text.data(), buff, sizeof(buff), asize); atype, qPrintableLatin1(textutf8), buff, sizeof(buff), asize);
if (EVEN(sts)) { if (EVEN(sts)) {
message('E', "Input syntax error"); message('E', "Input syntax error");
return sts; return sts;
...@@ -327,6 +328,7 @@ XAttOneQt::XAttOneQt(QWidget* xa_parent_wid, void* xa_parent_ctx, ...@@ -327,6 +328,7 @@ XAttOneQt::XAttOneQt(QWidget* xa_parent_wid, void* xa_parent_ctx,
access_rw = 0; access_rw = 0;
} }
msg_label->setVisible(false);
if (access_rw) { if (access_rw) {
cmd_label->setVisible(false); cmd_label->setVisible(false);
} else { } else {
......
...@@ -57,6 +57,9 @@ CoWowRecall XColWindQt::value_recall; ...@@ -57,6 +57,9 @@ CoWowRecall XColWindQt::value_recall;
void XColWindQt::message(char severity, const char* message) void XColWindQt::message(char severity, const char* message)
{ {
msg_label->setText(fl(message)); msg_label->setText(fl(message));
if (strcmp(message, "") != 0) {
msg_label->setVisible(true);
}
} }
void XColWindQt::set_prompt(const char* prompt) void XColWindQt::set_prompt(const char* prompt)
...@@ -272,8 +275,7 @@ void XColWindQt::change_value_close() ...@@ -272,8 +275,7 @@ void XColWindQt::change_value_close()
{ {
if (input_open) { if (input_open) {
if (input_multiline) { if (input_multiline) {
QByteArray ba = cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
xattnav->set_attr_value(input_node, input_name, text); xattnav->set_attr_value(input_node, input_name, text);
...@@ -291,8 +293,7 @@ void XColWindQt::change_value_close() ...@@ -291,8 +293,7 @@ void XColWindQt::change_value_close()
message('E', "Input error, invalid character"); message('E', "Input error, invalid character");
} }
} else { } else {
QByteArray ba = cmd_entry->text().toLatin1(); char* text = qPrintableLatin1(cmd_entry->text());
char* text = ba.data();
if (text) { if (text) {
xattnav->set_attr_value(input_node, input_name, text); xattnav->set_attr_value(input_node, input_name, text);
...@@ -319,10 +320,9 @@ void XColWindQtWidget::activate_cmd_entry() ...@@ -319,10 +320,9 @@ void XColWindQtWidget::activate_cmd_entry()
colwind->xattnav->set_inputfocus(); colwind->xattnav->set_inputfocus();
QByteArray ba = colwind->cmd_entry->text().toLatin1();
char* text = ba.data();
if (colwind->input_open) { if (colwind->input_open) {
char* text = qPrintableLatin1(colwind->cmd_entry->text());
if (text) { if (text) {
colwind->xattnav->set_attr_value( colwind->xattnav->set_attr_value(
colwind->input_node, colwind->input_name, text); colwind->input_node, colwind->input_name, text);
...@@ -343,8 +343,7 @@ void XColWindQtWidget::activate_cmd_entry() ...@@ -343,8 +343,7 @@ 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) {
QByteArray ba = colwind->cmd_scrolled_buffer->toPlainText().toLatin1(); char* text = qPrintableLatin1(colwind->cmd_scrolled_buffer->toPlainText());
char* text = ba.data();
if (text) { if (text) {
colwind->xattnav->set_attr_value( colwind->xattnav->set_attr_value(
...@@ -577,6 +576,7 @@ XColWindQt::XColWindQt(QWidget* xa_parent_wid, void* xa_parent_ctx, ...@@ -577,6 +576,7 @@ XColWindQt::XColWindQt(QWidget* xa_parent_wid, void* xa_parent_ctx,
toplevel->show(); toplevel->show();
msg_label->setVisible(false);
cmd_prompt->setVisible(false); cmd_prompt->setVisible(false);
cmd_entry->setVisible(false); cmd_entry->setVisible(false);
cmd_scrolledinput->setVisible(false); cmd_scrolledinput->setVisible(false);
......
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