예제 #1
0
void ExportDialog::updateOptions(const QString & name)
{
		ApplicationWindow *app = dynamic_cast<ApplicationWindow *>(this->parent());
	if (!app)
        return;

    MdiSubWindow* w = app->window(name);
    if (!w)
		return;

    boxComments->setEnabled(w->inherits("Table"));
    boxNames->setEnabled(w->inherits("Table"));
	boxSelection->setEnabled(!w->isA("MantidMatrix"));
	boxSeparator->setEnabled(!w->isA("MantidMatrix"));
	boxAllTables->setEnabled(!w->isA("MantidMatrix"));
	sepText->setEnabled(!w->isA("MantidMatrix"));

}
void ImportASCIIDialog::initPreview(int previewMode)
{
	if (previewMode < NewTables || previewMode > Overwrite)
		return;

	ApplicationWindow *app = (ApplicationWindow *)parent();
	if (!app)
		return;

	if (d_preview_table){
		delete d_preview_table;
		d_preview_table = NULL;
	}

	if (d_preview_matrix){
		delete d_preview_matrix;
		d_preview_matrix = NULL;
	}

	switch(previewMode){
		case NewTables:
			d_preview_table = new PreviewTable(30, 2, this);
			d_preview_table->setNumericPrecision(app->d_decimal_digits);
			d_preview_stack->addWidget(d_preview_table);
			connect(d_preview_table, SIGNAL(modifiedColumnType()), this, SLOT(preview()));
			enableTableOptions(true);
		break;

		case NewMatrices:
			d_preview_matrix = new PreviewMatrix(app);
			d_preview_stack->addWidget(d_preview_matrix);
			enableTableOptions(false);
		break;

		case NewColumns:
		case NewRows:
		case Overwrite:
			MdiSubWindow *w = app->activeWindow();
			if (!w)
				return;

			if (w->inherits("Table")){
				d_preview_table = new PreviewTable(30, ((Table*)w)->numCols(), this);
				d_preview_table->setNumericPrecision(app->d_decimal_digits);
				d_preview_stack->addWidget(d_preview_table);
				connect(d_preview_table, SIGNAL(modifiedColumnType()), this, SLOT(preview()));
				enableTableOptions(true);
			} else if (w->isA("Matrix")){
				d_preview_matrix = new PreviewMatrix(app, (Matrix *)w);
				d_preview_stack->addWidget(d_preview_matrix);
				enableTableOptions(false);
			}
		break;
	}
	preview();
}