Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/563a5b6eb954
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 07:55:25 2012
Кодировка:

# HG changeset patch
# User boris
# Date 1297890541 -10800
# Node ID 563a5b6eb954c0a292b8e47cb38b734ee0ce7321
# Parent 46d8caca3f47be759b145227380db35cf36ed7c0
blocks3d/wt: move all messages and other texts to xml file

this xml file can be usefull for localization

Other changes:
* render corformity file widgets, but then hide them
(to avoid possible memory leak)
* fix mistake in confirmity file label buddy

diff -r 46d8caca3f47 -r 563a5b6eb954 blocks3d/wt/blocks3d-wt-widget.C
--- a/blocks3d/wt/blocks3d-wt-widget.C Wed Feb 16 23:11:02 2011 +0300
+++ b/blocks3d/wt/blocks3d-wt-widget.C Thu Feb 17 00:09:01 2011 +0300
@@ -1,3 +1,10 @@
+
+#include
+#include
+#include
+#include
+#include
+#include

#include "config.h"
#include "blocks3d-wt-widget.h"
@@ -12,19 +19,12 @@
#include
#include

-#include
-#include
-#include
-#include
-#include
-#include
-
std::list current_taks;

Blocks3DWidget::Blocks3DWidget(Wt::WContainerWidget* parent) :
Wt::WContainerWidget(parent)
{
- Wt::WText* head = new Wt::WText("Blocks3D", this);
+ Wt::WText* head = new Wt::WText(tr("main_header"), this);
head->setStyleClass("header");

alignment_upload = new Wt::WFileUpload();
@@ -36,11 +36,11 @@
conformity_textarea->setColumns(40);
conformity_textarea->setRows(20);

- Wt::WLabel* alignment_label = new Wt::WLabel("Alignment:");
+ Wt::WLabel* alignment_label = new Wt::WLabel(tr("alignment"));
alignment_label->setBuddy(alignment_textarea);

- Wt::WLabel* conformity_label = new Wt::WLabel("Confiomity file:");
- conformity_label->setBuddy(alignment_textarea);
+ Wt::WLabel* conformity_label = new Wt::WLabel(tr("conformity_file"));
+ conformity_label->setBuddy(conformity_textarea);

new Wt::WBreak(this);
Wt::WTable* table = new Wt::WTable(this);
@@ -49,20 +49,29 @@
table->elementAt(1, 0)->addWidget(alignment_textarea);
table->elementAt(2, 0)->addWidget(alignment_upload);

+ table->elementAt(0, 1)->addWidget(conformity_label);
+ table->elementAt(1, 1)->addWidget(conformity_textarea);
+ table->elementAt(2, 1)->addWidget(conformity_upload);
+ conformity_upload->hide();
+ conformity_textarea->hide();
+ conformity_label->hide();
+
new Wt::WBreak(this);
delta_input = new Wt::WLineEdit(Malakite::defaults::delta, this);
- delta_validator = new Wt::WDoubleValidator(0.0, 10.0); // FIXME: not to allow empty
+ delta_validator = new Wt::WDoubleValidator(0.0, 10.0);
delta_validator->setMandatory(true);
delta_input->setValidator(delta_validator);
- Wt::WLabel* delta_label = new Wt::WLabel("Distance spreading", this);
+ Wt::WLabel* delta_label = new Wt::WLabel(tr("delta"), this);
delta_label->setBuddy(delta_input);

new Wt::WBreak(this);
- min_block_width_input = new Wt::WLineEdit(Malakite::defaults::min_block_width, this);
+ min_block_width_input =
+ new Wt::WLineEdit(Malakite::defaults::min_block_width, this);
min_block_width_validator = new Wt::WIntValidator(3, 9999);
min_block_width_validator->setMandatory(true);
min_block_width_input->setValidator(min_block_width_validator);
- Wt::WLabel* min_block_width_label = new Wt::WLabel("Min block width", this);
+ Wt::WLabel* min_block_width_label =
+ new Wt::WLabel(tr("min_block_width"), this);
min_block_width_label->setBuddy(min_block_width_input);

new Wt::WBreak(this);
@@ -70,8 +79,7 @@
timeout_validator = new Wt::WIntValidator(-1, 30*24*3600);
timeout_validator->setMandatory(true);
timeout_input->setValidator(timeout_validator);
- Wt::WLabel* timeout_label = new Wt::WLabel(
- "Bron-Kerbosh (couple cores) timeout", this);
+ Wt::WLabel* timeout_label = new Wt::WLabel(tr("timeout"), this);
timeout_label->setBuddy(timeout_input);

new Wt::WBreak(this);
@@ -79,25 +87,30 @@
timeout2_validator = new Wt::WIntValidator(-1, 30*24*3600);
timeout2_validator->setMandatory(true);
timeout2_input->setValidator(timeout2_validator);
- Wt::WLabel* timeout2_label = new Wt::WLabel(
- "Bron-Kerbosh (blocks) timeout", this);
+ Wt::WLabel* timeout2_label = new Wt::WLabel(tr("timeout2"), this);
timeout2_label->setBuddy(timeout2_input);


new Wt::WBreak(this);
- go_button = new Wt::WPushButton("Run", this);
+ go_button = new Wt::WPushButton(tr("Run"), this);

new Wt::WBreak(this);
results_panel = new Wt::WContainerWidget(this);

go_button->clicked().connect(this, &Blocks3DWidget::go_button_click);
- alignment_upload->uploaded().connect(this, &Blocks3DWidget::alignment_uploaded);
- conformity_upload->uploaded().connect(this, &Blocks3DWidget::conformity_uploaded);
- alignment_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
- conformity_upload->fileTooLarge().connect(this, &Blocks3DWidget::fileTooLarge);
+ alignment_upload->uploaded()
+ .connect(this, &Blocks3DWidget::alignment_uploaded);
+ conformity_upload->uploaded()
+ .connect(this, &Blocks3DWidget::conformity_uploaded);
+ alignment_upload->fileTooLarge()
+ .connect(this, &Blocks3DWidget::fileTooLarge);
+ conformity_upload->fileTooLarge()
+ .connect(this, &Blocks3DWidget::fileTooLarge);

- alignment_upload->changed().connect(alignment_upload, &Wt::WFileUpload::upload);
- conformity_upload->changed().connect(conformity_upload, &Wt::WFileUpload::upload);
+ alignment_upload->changed()
+ .connect(alignment_upload, &Wt::WFileUpload::upload);
+ conformity_upload->changed()
+ .connect(conformity_upload, &Wt::WFileUpload::upload);

timer = new Wt::WTimer(this);
timer->timeout().connect(this, &Blocks3DWidget::timeout);
@@ -177,31 +190,31 @@
if (alignment.empty())
{
new Wt::WBreak(results_panel);
- new Wt::WText("No alignment provided", results_panel);
+ new Wt::WText(tr("no_alignment"), results_panel);
return;
}
if (delta_input->validate() != Wt::WValidator::Valid)
{
new Wt::WBreak(results_panel);
- new Wt::WText("Enter delta parameter", results_panel);
+ new Wt::WText(tr("enter_delta"), results_panel);
return;
}
if (min_block_width_input->validate() != Wt::WValidator::Valid)
{
new Wt::WBreak(results_panel);
- new Wt::WText("Enter min block width parameter", results_panel);
+ new Wt::WText(tr("enter_min_block_width"), results_panel);
return;
}
if (timeout_input->validate() != Wt::WValidator::Valid)
{
new Wt::WBreak(results_panel);
- new Wt::WText("Enter timeout parameter", results_panel);
+ new Wt::WText(tr("enter_timeout"), results_panel);
return;
}
if (timeout2_input->validate() != Wt::WValidator::Valid)
{
new Wt::WBreak(results_panel);
- new Wt::WText("Enter timeout2 parameter", results_panel);
+ new Wt::WText(tr("enter_timeout2"), results_panel);
return;
}

@@ -256,10 +269,11 @@
// security???
system(str(boost::format("sh %s &") % tempfile_sh.c_str()).c_str());
new Wt::WBreak(results_panel);
- new Wt::WText("Task start", results_panel);
+ new Wt::WText(tr("task_start"), results_panel);

new Wt::WBreak(results_panel);
- new Wt::WText("Time elapsed: ", results_panel);
+ new Wt::WText(tr("time_elapsed"), results_panel);
+ new Wt::WText(": ", results_panel);
worktime = new Worktime(results_panel);

timer->start();
@@ -272,7 +286,6 @@
void Blocks3DWidget::timeout()
{
worktime->render();
- // FIXME: check status of task
if (!is_completed(tempfile_check))
{
return;
@@ -287,24 +300,25 @@
if (!tempfile_html_file)
{
new Wt::WBreak(results_panel);
- new Wt::WText("Task failed. Please contact developer", results_panel);
+ new Wt::WText(tr("task_failed"), results_panel);
return;
}
tempfile_html_file.close();

new Wt::WBreak(results_panel);
- new Wt::WText("Task finished", results_panel);
+ new Wt::WText(tr("task_finished"), results_panel);

new Wt::WText(" | ", results_panel);
Wt::WFileResource* html_view =
new Wt::WFileResource("text/html", tempfile_html, this);
- Wt::WAnchor* a_view = new Wt::WAnchor(html_view, "View", results_panel);
+ Wt::WAnchor* a_view =
+ new Wt::WAnchor(html_view, tr("View"), results_panel);
a_view->setTarget(Wt::TargetNewWindow);

new Wt::WText(" | ", results_panel);
Wt::WFileResource* html_download =
new Wt::WFileResource("application/html", tempfile_html, this);
- new Wt::WAnchor(html_download, "Download", results_panel);
+ new Wt::WAnchor(html_download, tr("Download"), results_panel);
}


diff -r 46d8caca3f47 -r 563a5b6eb954 blocks3d/wt/blocks3d-wt.C
--- a/blocks3d/wt/blocks3d-wt.C Wed Feb 16 23:11:02 2011 +0300
+++ b/blocks3d/wt/blocks3d-wt.C Thu Feb 17 00:09:01 2011 +0300
@@ -17,6 +17,8 @@
Blocks3DApplication::Blocks3DApplication(const Wt::WEnvironment& env) :
Wt::WApplication(env)
{
+ messageResourceBundle().use(Wt::WApplication::appRoot() +
+ "locales/blocks3d");
useStyleSheet("/css/1.css");
blocks3d_widget = new Blocks3DWidget(root());
}
diff -r 46d8caca3f47 -r 563a5b6eb954 blocks3d/wt/compile.sh
--- a/blocks3d/wt/compile.sh Wed Feb 16 23:11:02 2011 +0300
+++ b/blocks3d/wt/compile.sh Thu Feb 17 00:09:01 2011 +0300
@@ -1,6 +1,6 @@
mkdir -p build
cd build
+if [ ! -d ./locales ]; then ln -s ../locales ./locales; fi
qmake ../blocks3d-wt.pro && make VERBOSE=0
-#~ cmake .. && make VERBOSE=1


diff -r 46d8caca3f47 -r 563a5b6eb954 blocks3d/wt/locales/blocks3d.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/blocks3d/wt/locales/blocks3d.xml Thu Feb 17 00:09:01 2011 +0300
@@ -0,0 +1,30 @@
+
+
+ Blocks3D
+ Alignment
+ Conformity file
+ Distance spreading
+ Min block width
+ Bron-Kerbosh (couple cores) timeout
+ Bron-Kerbosh (blocks) timeout
+ Run
+ Enter delta parameter
+ No alignment provided
+ Enter timeout parameter
+ Enter timeout2 parameter
+
+ Enter min block width paramete
+

+
+ Task start
+ Task finished
+ Time elapsed
+
+ Task failed. Please contact developer
+

+ View
+ Download
+
+
+

+