mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 22:55:55 +01:00
Fixed CSV preview.
This commit is contained in:
parent
00d6e0a628
commit
c228d921e4
@ -4,6 +4,7 @@
|
|||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/grid_container.h"
|
#include "scene/gui/grid_container.h"
|
||||||
|
#include "scene/gui/label.h"
|
||||||
#include "scene/gui/rich_text_label.h"
|
#include "scene/gui/rich_text_label.h"
|
||||||
|
|
||||||
#include "modules/regex/regex.h"
|
#include "modules/regex/regex.h"
|
||||||
@ -194,23 +195,30 @@ void TextEditorPreview::print_html(const String &p_content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorPreview::print_csv(const Array &rows) {
|
void TextEditorPreview::print_csv(const Array &rows) {
|
||||||
//TODO
|
if (rows.size() == 0) {
|
||||||
/*
|
return;
|
||||||
table_preview->set_columns(rows[0].size());
|
}
|
||||||
|
|
||||||
for (item in rows) {
|
Vector<String> r0 = rows[0];
|
||||||
for (string in item) {
|
|
||||||
Label *label = memnew(Label);
|
|
||||||
label->set_text(str(string));
|
|
||||||
label->set_h_size_flags(SIZE_EXPAND);
|
|
||||||
label->set_align(1);
|
|
||||||
label->set_valign(1);
|
|
||||||
table_preview->add_child(label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
table_preview->show();
|
table_preview->set_columns(r0.size());
|
||||||
*/
|
|
||||||
|
for (int i = 0; i < rows.size(); ++i) {
|
||||||
|
Vector<String> item = rows[i];
|
||||||
|
|
||||||
|
for (int j = 0; j < item.size(); ++j) {
|
||||||
|
String string = item[j];
|
||||||
|
|
||||||
|
Label *label = memnew(Label);
|
||||||
|
label->set_text(string);
|
||||||
|
label->set_h_size_flags(SIZE_EXPAND);
|
||||||
|
label->set_align(Label::ALIGN_CENTER);
|
||||||
|
label->set_valign(Label::VALIGN_CENTER);
|
||||||
|
table_preview->add_child(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
table_preview->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorPreview::_on_TextEditorPreview_popup_hide() {
|
void TextEditorPreview::_on_TextEditorPreview_popup_hide() {
|
||||||
|
@ -409,9 +409,9 @@ void TextFileEditor::csv_preview() {
|
|||||||
preview->popup();
|
preview->popup();
|
||||||
preview->set_title(" (" + current_file_path.get_file() + ")");
|
preview->set_title(" (" + current_file_path.get_file() + ")");
|
||||||
int lines = current_editor->text_editor->get_line_count();
|
int lines = current_editor->text_editor->get_line_count();
|
||||||
Array rows = Array();
|
Array rows;
|
||||||
|
|
||||||
for (int i = 0; i < lines - 1; ++i) { //i in range(0, lines-1)
|
for (int i = 0; i < lines; ++i) { //i in range(0, lines-1)
|
||||||
rows.append(current_editor->text_editor->get_line(i).rsplit(",", false));
|
rows.append(current_editor->text_editor->get_line(i).rsplit(",", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user